Skip to content

Commit

Permalink
Simple build attempt with actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Coulthard committed Dec 11, 2023
1 parent ec8db1b commit 2b74aab
Show file tree
Hide file tree
Showing 13 changed files with 1,099 additions and 129 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Node CI

on: [push]

jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: npm install, build, and test
run: |
npm install
npm run build
npm run test:unit || exit 0
129 changes: 129 additions & 0 deletions __tests__/__resources__/CurrentDirectory/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{
"name": "zowe-cli-cics-deploy-plugin",
"version": "1.1.0",
"description": "IBM CICS Bundle generation and deployment for Zowe CLI",
"repository": {
"type": "git",
"url": "https://github.com/IBM/zowe-cli-cics-deploy-plugin"
},
"keywords": [
"cics",
"cli",
"mainframe",
"nodejs",
"zos",
"z/os",
"zowe"
],
"main": "lib/index.js",
"files": [
"lib",
"NOTICES.md"
],
"bin": {
"zowe-cli-cics-deploy": "./lib/main.js"
},
"scripts": {
"build": "tsc --pretty && npm run checkTestsCompile && gulp doc",
"checkTestsCompile": "echo \"Checking that test source compiles...\" && tsc --project __tests__/test-tsconfig.json --noEmit ",
"prebuild": "npm run clean && npm run lint && echo Using TypeScript && tsc --version",
"clean": "rimraf lib",
"watch": "tsc --pretty --watch",
"prepublishOnly": "npm run build",
"lint": "tslint \"src/**/*.ts\" && tslint \"**/__tests__/**/*.ts\"",
"test": "npm run test:unit && npm run test:system",
"test:system": "env-cmd __tests__/__resources__/env/system.env jest .*/__system__/.* --coverage false",
"test:unit": "env-cmd __tests__/__resources__/env/unit.env jest --runInBand --detectOpenHandles --coverage --testPathIgnorePatterns \".*/__system__/.*\"",
"installPlugin": "npm install && npm run clean && npm run build && zowe plugins install .",
"doc": "gulp doc"
},
"imperative": {
"configurationModule": "lib/imperative.js"
},
"dependencies": {
"@zowe/cics-for-zowe-cli": "^4.0.8",
"fast-xml-parser": "^3.16.0"
},
"devDependencies": {
"@zowe/cli": "^6.0.0",
"@zowe/imperative": "^4.7.3",
"@types/fs-extra": "^8.0.1",
"@types/jest": "^29.5.11",
"@types/node": "^12.12.24",
"@types/yargs": "^13.0.4",
"clear-require": "^2.0.0",
"env-cmd": "^8.0.2",
"fs-extra": "^8.1.0",
"gulp": "^4.0.2",
"gulp-cli": "^2.2.1",
"gulp-debug": "^4.0.0",
"gulp-plumber": "^1.2.1",
"gulp-replace": "^1.0.0",
"gulp-util": "^3.0.8",
"jest": "^29.7.0",
"jest-cli": "^29.7.0",
"jest-environment-node": "^29.7.0",
"jest-environment-node-debug": "^2.0.0",
"jest-html-reporter": "^3.10.2",
"jest-junit": "^16.0.0",
"js-yaml": "^3.14.0",
"mustache": "^4.0.1",
"rimraf": "^3.0.2",
"ts-jest": "^29.1.1",
"ts-node": "^8.10.2",
"tslint": "^6.1.2",
"typedoc": "^0.17.7",
"typescript": "^5.3.3",
"uuid": "^3.3.2"
},
"peerDependencies": {
"@zowe/cli": "^6.0.0",
"@zowe/imperative": "^4.7.3"
},
"jest": {
"modulePathIgnorePatterns": [
"__tests__/__snapshots__/"
],
"reporters": [ "default", "jest-junit" ],
"transform": {
".(ts)": "ts-jest"
},
"testRegex": "(test|spec)\\.ts$",
"moduleFileExtensions": [
"ts",
"js"
],
"testPathIgnorePatterns": [
"<rootDir>/__tests__/__results__"
],
"testEnvironment": "node",
"collectCoverageFrom": [
"src/**/*.ts",
"!**/__tests__/**",
"!**/index.ts",
"!**/main.ts"
],
"collectCoverage": false,
"coverageReporters": [
"json",
"lcov",
"text",
"cobertura"
],
"coverageDirectory": "<rootDir>/__tests__/__results__/unit/coverage"
},
"jest-junit": {
"output": "__tests__/__results__/junit.xml"
},
"jest-html-reporter": {
"pageTitle": "Zowe cics-deploy Plugin Test Results",
"outputPath": "__tests__/__results__/results.html",
"includeFailureMsg": true
},
"author": "IBM Corp",
"contributors": [
"Contributors to the Zowe Project"
],
"license": "EPL-2.0"
}

26 changes: 15 additions & 11 deletions __tests__/api/BundleContent/__snapshots__/AutoBundler.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AutoBundler01 should cope with an empty directory 1`] = `"{\\"manifest\\":{\\"xmlns\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle\\",\\"bundleVersion\\":1,\\"bundleRelease\\":0}}"`;
exports[`AutoBundler01 should cope with an empty directory 1`] = `"{"manifest":{"xmlns":"http://www.ibm.com/xmlns/prod/cics/bundle","bundleVersion":1,"bundleRelease":0}}"`;

exports[`AutoBundler01 should cope with an empty directory and generate a NODEJSAPP 1`] = `"{\\"manifest\\":{\\"xmlns\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle\\",\\"bundleVersion\\":1,\\"bundleRelease\\":0,\\"define\\":[{\\"name\\":\\"wibble\\",\\"type\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP\\",\\"path\\":\\"nodejsapps/wibble.nodejsapp\\"}]}}"`;
exports[`AutoBundler01 should cope with an empty directory and generate a NODEJSAPP 1`] = `"{"manifest":{"xmlns":"http://www.ibm.com/xmlns/prod/cics/bundle","bundleVersion":1,"bundleRelease":0,"define":[{"name":"wibble","type":"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP","path":"nodejsapps/wibble.nodejsapp"}]}}"`;

exports[`AutoBundler01 should detect --merge without --overwrite 1`] = `"--merge requires the use of --overwrite"`;

exports[`AutoBundler01 should detect a bad package.json 1`] = `"Parsing error occurred reading package.json: Unexpected token g in JSON at position 0"`;
exports[`AutoBundler01 should detect a bad package.json 1`] = `
"Parsing error occurred reading package.json: Unexpected token 'g', "garbage
exports[`AutoBundler01 should not merge an existing bundle 1`] = `"{\\"manifest\\":{\\"xmlns\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle\\",\\"bundleVersion\\":1,\\"bundleRelease\\":0}}"`;
" is not valid JSON"
`;

exports[`AutoBundler01 should read an existing bundle 1`] = `"{\\"manifest\\":{\\"xmlns\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle\\",\\"bundleVersion\\":\\"1\\",\\"bundleRelease\\":\\"2\\",\\"id\\":\\"ThisIsAnId\\",\\"bundleMajorVer\\":\\"10\\",\\"bundleMinorVer\\":\\"11\\",\\"bundleMicroVer\\":\\"12\\",\\"define\\":[{\\"name\\":\\"name1\\",\\"type\\":\\"type1\\",\\"path\\":\\"path1\\"},{\\"name\\":\\"name2\\",\\"type\\":\\"type2\\",\\"path\\":\\"path2\\"},{\\"name\\":\\"name3\\",\\"type\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP\\",\\"path\\":\\"nodejsapps/Test.nodejsapp\\"}]}}"`;
exports[`AutoBundler01 should not merge an existing bundle 1`] = `"{"manifest":{"xmlns":"http://www.ibm.com/xmlns/prod/cics/bundle","bundleVersion":1,"bundleRelease":0}}"`;

exports[`AutoBundler01 should receive default values from package.json 1`] = `"{\\"manifest\\":{\\"xmlns\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle\\",\\"id\\":\\"testBundleName\\",\\"bundleMajorVer\\":1,\\"bundleMinorVer\\":0,\\"bundleMicroVer\\":0,\\"define\\":[{\\"name\\":\\"testBundleName\\",\\"type\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP\\",\\"path\\":\\"nodejsapps/testBundleName.nodejsapp\\"}]}}"`;
exports[`AutoBundler01 should read an existing bundle 1`] = `"{"manifest":{"xmlns":"http://www.ibm.com/xmlns/prod/cics/bundle","bundleVersion":"1","bundleRelease":"2","id":"ThisIsAnId","bundleMajorVer":"10","bundleMinorVer":"11","bundleMicroVer":"12","define":[{"name":"name1","type":"type1","path":"path1"},{"name":"name2","type":"type2","path":"path2"},{"name":"name3","type":"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP","path":"nodejsapps/Test.nodejsapp"}]}}"`;

exports[`AutoBundler01 should set a nodejsapp name 1`] = `"{\\"manifest\\":{\\"xmlns\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle\\",\\"id\\":\\"testBundleName\\",\\"bundleMajorVer\\":1,\\"bundleMinorVer\\":0,\\"bundleMicroVer\\":0,\\"define\\":[{\\"name\\":\\"MyExampleOverride\\",\\"type\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP\\",\\"path\\":\\"nodejsapps/MyExampleOverride.nodejsapp\\"}]}}"`;
exports[`AutoBundler01 should receive default values from package.json 1`] = `"{"manifest":{"xmlns":"http://www.ibm.com/xmlns/prod/cics/bundle","id":"testBundleName","bundleMajorVer":1,"bundleMinorVer":0,"bundleMicroVer":0,"define":[{"name":"testBundleName","type":"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP","path":"nodejsapps/testBundleName.nodejsapp"}]}}"`;

exports[`AutoBundler01 should set a nodejsapp name 1`] = `"{"manifest":{"xmlns":"http://www.ibm.com/xmlns/prod/cics/bundle","id":"testBundleName","bundleMajorVer":1,"bundleMinorVer":0,"bundleMicroVer":0,"define":[{"name":"MyExampleOverride","type":"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP","path":"nodejsapps/MyExampleOverride.nodejsapp"}]}}"`;

exports[`AutoBundler01 should set a port number 1`] = `"Supplied Port is outside the range of 1-65535: -27"`;

exports[`AutoBundler01 should set the bundle version 1`] = `"{\\"manifest\\":{\\"xmlns\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle\\",\\"bundleMajorVer\\":3,\\"bundleMinorVer\\":4,\\"bundleMicroVer\\":5}}"`;
exports[`AutoBundler01 should set the bundle version 1`] = `"{"manifest":{"xmlns":"http://www.ibm.com/xmlns/prod/cics/bundle","bundleMajorVer":3,"bundleMinorVer":4,"bundleMicroVer":5}}"`;

exports[`AutoBundler01 should set the bundleid 1`] = `"{\\"manifest\\":{\\"xmlns\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle\\",\\"id\\":\\"test\\"}}"`;
exports[`AutoBundler01 should set the bundleid 1`] = `"{"manifest":{"xmlns":"http://www.ibm.com/xmlns/prod/cics/bundle","id":"test"}}"`;

exports[`AutoBundler01 should support main script from package.json 1`] = `"{\\"manifest\\":{\\"xmlns\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle\\",\\"id\\":\\"testBundleName\\",\\"bundleMajorVer\\":1,\\"bundleMinorVer\\":0,\\"bundleMicroVer\\":0,\\"define\\":[{\\"name\\":\\"testBundleName\\",\\"type\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP\\",\\"path\\":\\"nodejsapps/testBundleName.nodejsapp\\"}]}}"`;
exports[`AutoBundler01 should support main script from package.json 1`] = `"{"manifest":{"xmlns":"http://www.ibm.com/xmlns/prod/cics/bundle","id":"testBundleName","bundleMajorVer":1,"bundleMinorVer":0,"bundleMicroVer":0,"define":[{"name":"testBundleName","type":"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP","path":"nodejsapps/testBundleName.nodejsapp"}]}}"`;

exports[`AutoBundler01 should tolerate an almost empty package.json 1`] = `"No startscript value set for NODEJSAPP \\"almostEmpty\\""`;
exports[`AutoBundler01 should tolerate an almost empty package.json 1`] = `"No startscript value set for NODEJSAPP "almostEmpty""`;

exports[`AutoBundler01 should tolerate an empty package.json 1`] = `"No bundleid value set"`;
20 changes: 10 additions & 10 deletions __tests__/api/BundleContent/__snapshots__/BundleSimple.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Bundle01 add a NODEJSAPP 1`] = `"{\\"manifest\\":{\\"xmlns\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle\\",\\"define\\":[{\\"name\\":\\"NodeName\\",\\"type\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP\\",\\"path\\":\\"nodejsapps/NodeName.nodejsapp\\"}]}}"`;
exports[`Bundle01 add a NODEJSAPP 1`] = `"{"manifest":{"xmlns":"http://www.ibm.com/xmlns/prod/cics/bundle","define":[{"name":"NodeName","type":"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP","path":"nodejsapps/NodeName.nodejsapp"}]}}"`;

exports[`Bundle01 add a NODEJSAPP 2`] = `
"<manifest xmlns=\\"http://www.ibm.com/xmlns/prod/cics/bundle\\"><define name=\\"NodeName\\" type=\\"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP\\" path=\\"nodejsapps/NodeName.nodejsapp\\"></define></manifest>
"<manifest xmlns="http://www.ibm.com/xmlns/prod/cics/bundle"><define name="NodeName" type="http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP" path="nodejsapps/NodeName.nodejsapp"></define></manifest>
"
`;

exports[`Bundle01 add a part with missing name 1`] = `"BundlePart name is not set."`;

exports[`Bundle01 add a part with missing path 1`] = `"BundlePart path is not set for part \\"name1\\""`;
exports[`Bundle01 add a part with missing path 1`] = `"BundlePart path is not set for part "name1""`;

exports[`Bundle01 add a part with missing type 1`] = `"BundlePart type is not set for part \\"name1\\""`;
exports[`Bundle01 add a part with missing type 1`] = `"BundlePart type is not set for part "name1""`;

exports[`Bundle01 add definitions 1`] = `"{\\"manifest\\":{\\"xmlns\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle\\",\\"bundleVersion\\":\\"1\\",\\"bundleRelease\\":\\"2\\",\\"id\\":\\"ThisIsAnId\\",\\"bundleMajorVer\\":\\"10\\",\\"bundleMinorVer\\":\\"11\\",\\"bundleMicroVer\\":\\"12\\",\\"define\\":[{\\"name\\":\\"name1\\",\\"type\\":\\"type1\\",\\"path\\":\\"Artefact1\\"},{\\"name\\":\\"name2\\",\\"type\\":\\"type2\\",\\"path\\":\\"Artefact2.txt\\"},{\\"name\\":\\"name3\\",\\"type\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP\\",\\"path\\":\\"nodejsapps/Test.nodejsapp\\"},{\\"name\\":\\"name3\\",\\"type\\":\\"type3\\",\\"path\\":\\"folder/Artefact3.jpg\\"}]}}"`;
exports[`Bundle01 add definitions 1`] = `"{"manifest":{"xmlns":"http://www.ibm.com/xmlns/prod/cics/bundle","bundleVersion":"1","bundleRelease":"2","id":"ThisIsAnId","bundleMajorVer":"10","bundleMinorVer":"11","bundleMicroVer":"12","define":[{"name":"name1","type":"type1","path":"Artefact1"},{"name":"name2","type":"type2","path":"Artefact2.txt"},{"name":"name3","type":"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP","path":"nodejsapps/Test.nodejsapp"},{"name":"name3","type":"type3","path":"folder/Artefact3.jpg"}]}}"`;

exports[`Bundle01 set the id and version 1`] = `"{\\"manifest\\":{\\"xmlns\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle\\",\\"bundleVersion\\":\\"1\\",\\"bundleRelease\\":\\"2\\",\\"id\\":\\"TestExample\\",\\"bundleMajorVer\\":33,\\"bundleMinorVer\\":44,\\"bundleMicroVer\\":55,\\"define\\":[{\\"name\\":\\"name1\\",\\"type\\":\\"type1\\",\\"path\\":\\"path1\\"},{\\"name\\":\\"name2\\",\\"type\\":\\"type2\\",\\"path\\":\\"path2\\"},{\\"name\\":\\"name3\\",\\"type\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP\\",\\"path\\":\\"nodejsapps/Test.nodejsapp\\"}]}}"`;
exports[`Bundle01 set the id and version 1`] = `"{"manifest":{"xmlns":"http://www.ibm.com/xmlns/prod/cics/bundle","bundleVersion":"1","bundleRelease":"2","id":"TestExample","bundleMajorVer":33,"bundleMinorVer":44,"bundleMicroVer":55,"define":[{"name":"name1","type":"type1","path":"path1"},{"name":"name2","type":"type2","path":"path2"},{"name":"name3","type":"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP","path":"nodejsapps/Test.nodejsapp"}]}}"`;

exports[`Bundle01 should be able to add a resource to a single item manifest 1`] = `"{\\"manifest\\":{\\"xmlns\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle\\",\\"define\\":[{\\"name\\":\\"single\\",\\"type\\":\\"type1\\",\\"path\\":\\"path1\\"},{\\"name\\":\\"item2\\",\\"type\\":\\"type2\\",\\"path\\":\\"Artefact1\\"}]}}"`;
exports[`Bundle01 should be able to add a resource to a single item manifest 1`] = `"{"manifest":{"xmlns":"http://www.ibm.com/xmlns/prod/cics/bundle","define":[{"name":"single","type":"type1","path":"path1"},{"name":"item2","type":"type2","path":"Artefact1"}]}}"`;

exports[`Bundle01 should be able to save new definitions 1`] = `"{\\"manifest\\":{\\"xmlns\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle\\",\\"bundleVersion\\":\\"1\\",\\"bundleRelease\\":\\"2\\",\\"id\\":\\"ThisIsAnId\\",\\"bundleMajorVer\\":\\"10\\",\\"bundleMinorVer\\":\\"11\\",\\"bundleMicroVer\\":\\"12\\",\\"define\\":[{\\"name\\":\\"name1\\",\\"type\\":\\"type1\\",\\"path\\":\\"Artefact1\\"},{\\"name\\":\\"name2\\",\\"type\\":\\"type2\\",\\"path\\":\\"path2\\"},{\\"name\\":\\"name3\\",\\"type\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP\\",\\"path\\":\\"nodejsapps/Test.nodejsapp\\"}]}}"`;
exports[`Bundle01 should be able to save new definitions 1`] = `"{"manifest":{"xmlns":"http://www.ibm.com/xmlns/prod/cics/bundle","bundleVersion":"1","bundleRelease":"2","id":"ThisIsAnId","bundleMajorVer":"10","bundleMinorVer":"11","bundleMicroVer":"12","define":[{"name":"name1","type":"type1","path":"Artefact1"},{"name":"name2","type":"type2","path":"path2"},{"name":"name3","type":"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP","path":"nodejsapps/Test.nodejsapp"}]}}"`;

exports[`Bundle01 should read an existing bundle 1`] = `"{\\"manifest\\":{\\"xmlns\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle\\",\\"bundleVersion\\":\\"1\\",\\"bundleRelease\\":\\"2\\",\\"id\\":\\"ThisIsAnId\\",\\"bundleMajorVer\\":\\"10\\",\\"bundleMinorVer\\":\\"11\\",\\"bundleMicroVer\\":\\"12\\",\\"define\\":[{\\"name\\":\\"name1\\",\\"type\\":\\"type1\\",\\"path\\":\\"path1\\"},{\\"name\\":\\"name2\\",\\"type\\":\\"type2\\",\\"path\\":\\"path2\\"},{\\"name\\":\\"name3\\",\\"type\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP\\",\\"path\\":\\"nodejsapps/Test.nodejsapp\\"}]}}"`;
exports[`Bundle01 should read an existing bundle 1`] = `"{"manifest":{"xmlns":"http://www.ibm.com/xmlns/prod/cics/bundle","bundleVersion":"1","bundleRelease":"2","id":"ThisIsAnId","bundleMajorVer":"10","bundleMinorVer":"11","bundleMicroVer":"12","define":[{"name":"name1","type":"type1","path":"path1"},{"name":"name2","type":"type2","path":"path2"},{"name":"name3","type":"http://www.ibm.com/xmlns/prod/cics/bundle/NODEJSAPP","path":"nodejsapps/Test.nodejsapp"}]}}"`;

exports[`Bundle01 should warn that an existing bundle cant be overwritten 1`] = `"A bundle manifest file already exists. Specify --overwrite to replace it, or --merge to merge changes into it."`;

exports[`Bundle01 tolerate an existing almost empty manifest 1`] = `"{\\"manifest\\":{\\"xmlns\\":\\"http://www.ibm.com/xmlns/prod/cics/bundle\\",\\"define\\":[{\\"name\\":\\"name1\\",\\"type\\":\\"type1\\",\\"path\\":\\"Artefact1\\"}]}}"`;
exports[`Bundle01 tolerate an existing almost empty manifest 1`] = `"{"manifest":{"xmlns":"http://www.ibm.com/xmlns/prod/cics/bundle","define":[{"name":"name1","type":"type1","path":"Artefact1"}]}}"`;
Loading

0 comments on commit 2b74aab

Please sign in to comment.