From 12052584f38bc0a8a9851c1618c1a29f63450947 Mon Sep 17 00:00:00 2001 From: Ala Hawash Date: Tue, 12 Mar 2024 23:24:29 +0200 Subject: [PATCH 1/4] add html report --- .github/workflows/axon-tools-tests.yml | 6 +- package-lock.json | 175 ++++++++++++++++++++++- packages/mdctl-axon-tools/.gitignore | 1 + packages/mdctl-axon-tools/jest.config.js | 9 ++ packages/mdctl-axon-tools/package.json | 10 +- 5 files changed, 190 insertions(+), 11 deletions(-) diff --git a/.github/workflows/axon-tools-tests.yml b/.github/workflows/axon-tools-tests.yml index 5f3fa4b2..9ddb2f1b 100644 --- a/.github/workflows/axon-tools-tests.yml +++ b/.github/workflows/axon-tools-tests.yml @@ -5,7 +5,7 @@ name: Axon Tools Tests on: push: - branches: [ "main" ] + branches: [ "main", "reporting" ] pull_request: branches: [ "main" ] @@ -28,3 +28,7 @@ jobs: cache: 'npm' - run: npm ci - run: npm run test --workspace=@medable/mdctl-axon-tools + - uses: actions/upload-artifact@v4 + with: + name: mdctl-axon-tools-report + path: ./packages/mdctl-axon-tools/reports \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 44447bfc..f39031c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6831,6 +6831,15 @@ "node": ">= 0.4" } }, + "node_modules/define-lazy-prop": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", + "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/define-properties": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", @@ -10591,6 +10600,21 @@ "node": ">=0.10.0" } }, + "node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", @@ -10945,6 +10969,18 @@ "node": ">=0.10.0" } }, + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -13943,6 +13979,51 @@ "node": ">=8.0" } }, + "node_modules/jest-html-reporters": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/jest-html-reporters/-/jest-html-reporters-3.1.7.tgz", + "integrity": "sha512-GTmjqK6muQ0S0Mnksf9QkL9X9z2FGIpNSxC52E0PHDzjPQ1XDu2+XTI3B3FS43ZiUzD1f354/5FfwbNIBzT7ew==", + "dev": true, + "dependencies": { + "fs-extra": "^10.0.0", + "open": "^8.0.3" + } + }, + "node_modules/jest-html-reporters/node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/jest-html-reporters/node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/jest-html-reporters/node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "dev": true, + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/jest-jasmine2": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/jest-jasmine2/-/jest-jasmine2-27.5.1.tgz", @@ -18868,6 +18949,23 @@ "node": ">=4" } }, + "node_modules/open": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-8.4.2.tgz", + "integrity": "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==", + "dev": true, + "dependencies": { + "define-lazy-prop": "^2.0.0", + "is-docker": "^2.1.1", + "is-wsl": "^2.2.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/optionator": { "version": "0.8.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", @@ -23694,9 +23792,8 @@ "eslint-plugin-node": "^8.0.0", "eslint-plugin-promise": "^4.0.1", "eslint-plugin-standard": "^4.0.0", - "istanbul": "^1.0.0-alpha", "jest": "^27.4.5", - "mocha": "^5.0.0", + "jest-html-reporters": "^3.1.7", "nock": "^10.0.6" }, "engines": { @@ -30234,10 +30331,9 @@ "eslint-plugin-standard": "^4.0.0", "globby": "^9.1.0", "inflection": "^1.12.0", - "istanbul": "^1.0.0-alpha", "jest": "^27.4.5", + "jest-html-reporters": "^3.1.7", "lodash": "^4.17.14", - "mocha": "^5.0.0", "moment": "^2.29.1", "ndjson": "^1.5.0", "nock": "^10.0.6", @@ -36076,6 +36172,12 @@ "has-property-descriptors": "^1.0.0" } }, + "define-lazy-prop": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", + "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", + "dev": true + }, "define-properties": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", @@ -39021,6 +39123,12 @@ "integrity": "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=", "dev": true }, + "is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true + }, "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", @@ -39266,6 +39374,15 @@ "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==" }, + "is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "requires": { + "is-docker": "^2.0.0" + } + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -41671,6 +41788,45 @@ } } }, + "jest-html-reporters": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/jest-html-reporters/-/jest-html-reporters-3.1.7.tgz", + "integrity": "sha512-GTmjqK6muQ0S0Mnksf9QkL9X9z2FGIpNSxC52E0PHDzjPQ1XDu2+XTI3B3FS43ZiUzD1f354/5FfwbNIBzT7ew==", + "dev": true, + "requires": { + "fs-extra": "^10.0.0", + "open": "^8.0.3" + }, + "dependencies": { + "fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^2.0.0" + } + }, + "universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "dev": true + } + } + }, "jest-jasmine2": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/jest-jasmine2/-/jest-jasmine2-27.5.1.tgz", @@ -45328,6 +45484,17 @@ "mimic-fn": "^1.0.0" } }, + "open": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-8.4.2.tgz", + "integrity": "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==", + "dev": true, + "requires": { + "define-lazy-prop": "^2.0.0", + "is-docker": "^2.1.1", + "is-wsl": "^2.2.0" + } + }, "optionator": { "version": "0.8.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", diff --git a/packages/mdctl-axon-tools/.gitignore b/packages/mdctl-axon-tools/.gitignore index 9ba8d302..e854a000 100644 --- a/packages/mdctl-axon-tools/.gitignore +++ b/packages/mdctl-axon-tools/.gitignore @@ -69,3 +69,4 @@ output*/ manifest.json .editorconfig +reports/ \ No newline at end of file diff --git a/packages/mdctl-axon-tools/jest.config.js b/packages/mdctl-axon-tools/jest.config.js index 647c474b..31eda679 100644 --- a/packages/mdctl-axon-tools/jest.config.js +++ b/packages/mdctl-axon-tools/jest.config.js @@ -15,4 +15,13 @@ module.exports = { // Automatically restore mock state and implementation before every test restoreMocks: true, + + // Custom reporters + reporters: ['default', + ['jest-html-reporters', { + publicPath: './reports', + filename: 'report.html', + stripSkippedTest: true, + }]] + } diff --git a/packages/mdctl-axon-tools/package.json b/packages/mdctl-axon-tools/package.json index 3174c45b..b7ff45bf 100644 --- a/packages/mdctl-axon-tools/package.json +++ b/packages/mdctl-axon-tools/package.json @@ -16,12 +16,11 @@ "author": "Medable, Inc. ", "license": "MIT", "scripts": { - "test": "jest", + "test": "npm run lint && npm run cover", "test:prod": "npm run test", - "test:only": "mocha --recursive", + "test:only": "jest", "test:watch": "npm run test:only -- --watch", - "test:examples": "node examples/", - "cover": "istanbul cover ../../node_modules/mocha/bin/_mocha -- --recursive --timeout 10000", + "cover": "jest --coverage", "lint": "eslint *.js" }, "dependencies": { @@ -46,9 +45,8 @@ "eslint-plugin-node": "^8.0.0", "eslint-plugin-promise": "^4.0.1", "eslint-plugin-standard": "^4.0.0", - "istanbul": "^1.0.0-alpha", "jest": "^27.4.5", - "mocha": "^5.0.0", + "jest-html-reporters": "^3.1.7", "nock": "^10.0.6" }, "gitHead": "4d50c0a1a7e84d29ac2490436643434205ce3f6d" From 541e54d3cec815aeccd5fcb3753908884c074e84 Mon Sep 17 00:00:00 2001 From: Ala Hawash Date: Tue, 12 Mar 2024 23:37:00 +0200 Subject: [PATCH 2/4] add custom info --- .github/workflows/axon-tools-tests.yml | 4 ++-- packages/mdctl-axon-tools/jest.config.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/axon-tools-tests.yml b/.github/workflows/axon-tools-tests.yml index 9ddb2f1b..c36f2096 100644 --- a/.github/workflows/axon-tools-tests.yml +++ b/.github/workflows/axon-tools-tests.yml @@ -5,7 +5,7 @@ name: Axon Tools Tests on: push: - branches: [ "main", "reporting" ] + branches: [ "main" ] pull_request: branches: [ "main" ] @@ -30,5 +30,5 @@ jobs: - run: npm run test --workspace=@medable/mdctl-axon-tools - uses: actions/upload-artifact@v4 with: - name: mdctl-axon-tools-report + name: mdctl-axon-tools-report-{{ matrix.node-version }} path: ./packages/mdctl-axon-tools/reports \ No newline at end of file diff --git a/packages/mdctl-axon-tools/jest.config.js b/packages/mdctl-axon-tools/jest.config.js index 31eda679..6e9dfb05 100644 --- a/packages/mdctl-axon-tools/jest.config.js +++ b/packages/mdctl-axon-tools/jest.config.js @@ -22,6 +22,13 @@ module.exports = { publicPath: './reports', filename: 'report.html', stripSkippedTest: true, + customInfos: [{ + title: 'Ref', + value: process.env.GITHUB_REF_NAME + }, { + title: 'Commit #', + value: process.env.GITHUB_SHA + }] }]] } From 82caaeef7ca4deeb3ebb2204b5ea4d49f5ee0548 Mon Sep 17 00:00:00 2001 From: Ala Hawash Date: Tue, 12 Mar 2024 23:41:24 +0200 Subject: [PATCH 3/4] fix artifact upload --- .github/workflows/axon-tools-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/axon-tools-tests.yml b/.github/workflows/axon-tools-tests.yml index c36f2096..5bbd1847 100644 --- a/.github/workflows/axon-tools-tests.yml +++ b/.github/workflows/axon-tools-tests.yml @@ -30,5 +30,5 @@ jobs: - run: npm run test --workspace=@medable/mdctl-axon-tools - uses: actions/upload-artifact@v4 with: - name: mdctl-axon-tools-report-{{ matrix.node-version }} + name: mdctl-axon-tools-report-${{ matrix.node-version }} path: ./packages/mdctl-axon-tools/reports \ No newline at end of file From 7a4bcd6f3928703b1ef28d041bec5ef3680203aa Mon Sep 17 00:00:00 2001 From: Ala Hawash Date: Wed, 13 Mar 2024 00:03:12 +0200 Subject: [PATCH 4/4] add ENV variables --- .github/workflows/axon-tools-tests.yml | 4 ++++ packages/mdctl-axon-tools/jest.config.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/axon-tools-tests.yml b/.github/workflows/axon-tools-tests.yml index 5bbd1847..753c5c59 100644 --- a/.github/workflows/axon-tools-tests.yml +++ b/.github/workflows/axon-tools-tests.yml @@ -26,6 +26,10 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'npm' + - name: Set ENV variables + id: vars + run: | + echo "CI_COMMIT_SHORT_SHA=$(git rev-parse --short ${{ github.sha }})" >> "$GITHUB_ENV" - run: npm ci - run: npm run test --workspace=@medable/mdctl-axon-tools - uses: actions/upload-artifact@v4 diff --git a/packages/mdctl-axon-tools/jest.config.js b/packages/mdctl-axon-tools/jest.config.js index 6e9dfb05..2a607dc6 100644 --- a/packages/mdctl-axon-tools/jest.config.js +++ b/packages/mdctl-axon-tools/jest.config.js @@ -24,10 +24,10 @@ module.exports = { stripSkippedTest: true, customInfos: [{ title: 'Ref', - value: process.env.GITHUB_REF_NAME + value: process.env.GITHUB_HEAD_REF }, { title: 'Commit #', - value: process.env.GITHUB_SHA + value: process.env.CI_COMMIT_SHORT_SHA }] }]]