From b7ba4842e4f67c4235bcaca3ff1b9c4c6e573e83 Mon Sep 17 00:00:00 2001 From: Nicholas Date: Mon, 6 May 2024 16:47:02 +0100 Subject: [PATCH 01/14] chore: swap out artefacts for annotions --- .github/workflows/coverage.yml | 7 +++++++ .github/workflows/test.yml | 7 ++++--- package.json | 2 +- test/config/cucumber.mjs | 6 +++--- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index f8b26cc..b67b627 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -37,3 +37,10 @@ jobs: CC_TEST_REPORTER_ID: 760097cb88b4c685dce427cf94a8e12a5f082774d06b4f4f5daef839ffc07821 with: coverageCommand: npm run lcov + + - name: Coverage annotations + uses: jgillick/test-coverage-annotations@v1 + with: + access-token: ${{ secrets.GITHUB_TOKEN }} + coverage: ./coverage/coverage-summary.json + only-changed-files: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d2a776e..0402892 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,7 +34,8 @@ jobs: - name: Run Tests and Linting run: npm run test - - uses: actions/upload-artifact@v3 + - name: Cucumber annotations + uses: deblockt/cucumber-report-annotations-action@v1.7 with: - name: test-reports-${{ matrix.node-version }} - path: test/reports/ + access-token: ${{ secrets.GITHUB_TOKEN }} + path: "test/reports/cucumber-report.ndjson" diff --git a/package.json b/package.json index c59ed34..4731c11 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "test:integration": "npm run test:integration:init && cucumber-js --config ./test/config/cucumber.mjs", "test": "npm run test:unit && npm run test:integration", "coverage": "c8 mocha && c8 report --reporter=html && c8 report --reporter=json-summary", - "lcov": "c8 mocha && c8 report --reporter=lcov", + "lcov": "c8 mocha && c8 report --reporter=lcov && c8 report --reporter=json-summary", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --fix", "format": "prettier --log-level warn --write \"**/*.{js,json,jsx,md,ts,tsx,html}\"", diff --git a/test/config/cucumber.mjs b/test/config/cucumber.mjs index b160c04..9c814a6 100644 --- a/test/config/cucumber.mjs +++ b/test/config/cucumber.mjs @@ -1,6 +1,6 @@ export default { parallel: 0, - format: ['html:test/reports/cucumber-report.html'], - paths: ['test/features'], - forceExit: true + format: ["message:test/reports/cucumber-report.ndjson"], + paths: ["test/features"], + forceExit: true, }; From 74d38433994eda7e442ef6ffe600670e87f50b7e Mon Sep 17 00:00:00 2001 From: Nicholas Date: Mon, 6 May 2024 16:56:40 +0100 Subject: [PATCH 02/14] chore: try something else for pr coverage --- .github/workflows/coverage.yml | 7 ------ .github/workflows/pr-coverage.yml | 37 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/pr-coverage.yml diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index b67b627..f8b26cc 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -37,10 +37,3 @@ jobs: CC_TEST_REPORTER_ID: 760097cb88b4c685dce427cf94a8e12a5f082774d06b4f4f5daef839ffc07821 with: coverageCommand: npm run lcov - - - name: Coverage annotations - uses: jgillick/test-coverage-annotations@v1 - with: - access-token: ${{ secrets.GITHUB_TOKEN }} - coverage: ./coverage/coverage-summary.json - only-changed-files: true diff --git a/.github/workflows/pr-coverage.yml b/.github/workflows/pr-coverage.yml new file mode 100644 index 0000000..36d2e3e --- /dev/null +++ b/.github/workflows/pr-coverage.yml @@ -0,0 +1,37 @@ +name: Continuous Integration +on: + pull_request: + branches: + - 'main' +permissions: + contents: read + pull-requests: write + +jobs: + coverage_report: + name: Generate coverage report + needs: testing + runs-on: ubuntu-latest + strategy: + matrix: + node-version: 22.x + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Setup LCOV + run: npm run lcov + + - name: Report code coverage + uses: zgosalvez/github-actions-report-lcov@v3 + with: + coverage-files: coverage/lcov.*.info + minimum-coverage: 90 + artifact-name: code-coverage-report + github-token: ${{ secrets.GITHUB_TOKEN }} + update-comment: true \ No newline at end of file From 178beb66d06b3d9d0bcb3e2b1a57432ad45e5b97 Mon Sep 17 00:00:00 2001 From: Nicholas Date: Mon, 6 May 2024 16:57:59 +0100 Subject: [PATCH 03/14] chore: changing name --- .github/workflows/pr-coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-coverage.yml b/.github/workflows/pr-coverage.yml index 36d2e3e..b05e148 100644 --- a/.github/workflows/pr-coverage.yml +++ b/.github/workflows/pr-coverage.yml @@ -1,4 +1,4 @@ -name: Continuous Integration +name: Comment PR Coverage on: pull_request: branches: From a126f149216d16cbe7f6d8b1b58cf0449651fe85 Mon Sep 17 00:00:00 2001 From: Nicholas Date: Mon, 6 May 2024 17:03:46 +0100 Subject: [PATCH 04/14] chore: removing unrequired output --- .github/workflows/test.yml | 2 +- package.json | 2 +- test/config/cucumber.mjs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0402892..9419cc9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,4 +38,4 @@ jobs: uses: deblockt/cucumber-report-annotations-action@v1.7 with: access-token: ${{ secrets.GITHUB_TOKEN }} - path: "test/reports/cucumber-report.ndjson" + path: "test/reports/cucumber-report.json" diff --git a/package.json b/package.json index 4731c11..c59ed34 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "test:integration": "npm run test:integration:init && cucumber-js --config ./test/config/cucumber.mjs", "test": "npm run test:unit && npm run test:integration", "coverage": "c8 mocha && c8 report --reporter=html && c8 report --reporter=json-summary", - "lcov": "c8 mocha && c8 report --reporter=lcov && c8 report --reporter=json-summary", + "lcov": "c8 mocha && c8 report --reporter=lcov", "lint": "eslint . --ext .ts", "lint:fix": "eslint . --fix", "format": "prettier --log-level warn --write \"**/*.{js,json,jsx,md,ts,tsx,html}\"", diff --git a/test/config/cucumber.mjs b/test/config/cucumber.mjs index 9c814a6..6f3704e 100644 --- a/test/config/cucumber.mjs +++ b/test/config/cucumber.mjs @@ -1,6 +1,6 @@ export default { parallel: 0, - format: ["message:test/reports/cucumber-report.ndjson"], + format: ["json:test/reports/cucumber-report.json"], paths: ["test/features"], forceExit: true, }; From 24671e2a3dd45fc34dada13fc54f674af9573ab6 Mon Sep 17 00:00:00 2001 From: Nicholas Date: Mon, 6 May 2024 17:05:57 +0100 Subject: [PATCH 05/14] chore: updating permissions --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9419cc9..6b545ed 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,6 +8,8 @@ on: - main permissions: contents: read + checks: write + pull-requests: write jobs: build: From 66d54465a9d474c86b0688890c268ef5b6adc152 Mon Sep 17 00:00:00 2001 From: Nicholas Date: Mon, 6 May 2024 17:22:36 +0100 Subject: [PATCH 06/14] chore: adding test reports --- .github/workflows/test.yml | 10 ++++++++++ package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6b545ed..c7ffd3d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,6 +10,8 @@ permissions: contents: read checks: write pull-requests: write + actions: read + checks: write jobs: build: @@ -35,6 +37,14 @@ jobs: - name: Run Tests and Linting run: npm run test + + - name: Test Report + uses: dorny/test-reporter@v1 + if: success() || failure() + with: + name: Mocha Tests + path: test/reports/test-results.json + reporter: mocha-json - name: Cucumber annotations uses: deblockt/cucumber-report-annotations-action@v1.7 diff --git a/package.json b/package.json index c59ed34..c7a6718 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "build": "npm run clean && npm run compile && npm run add-package-jsons", "watch": "tsc --watch", "prepublishOnly": "npm run build", - "test:unit": "mocha --recursive --full-trace --exit", + "test:unit": "mocha --recursive --full-trace --exit --reporter json > test/reports/test-results.json", "pretest:integration:init": "npm run build", "test:integration:init": "sh ./test/scripts/initIntTests.sh", "test:integration": "npm run test:integration:init && cucumber-js --config ./test/config/cucumber.mjs", From da79496017b4e2e728d968b0810738ff65498c52 Mon Sep 17 00:00:00 2001 From: Nicholas Date: Mon, 6 May 2024 17:23:44 +0100 Subject: [PATCH 07/14] chore: remove if --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c7ffd3d..37cc370 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,7 +40,6 @@ jobs: - name: Test Report uses: dorny/test-reporter@v1 - if: success() || failure() with: name: Mocha Tests path: test/reports/test-results.json From 6f6aff3c419ea145117fd51da6934634ce9c0116 Mon Sep 17 00:00:00 2001 From: Nicholas Date: Mon, 6 May 2024 17:32:40 +0100 Subject: [PATCH 08/14] chore: change to use artefacts but extend them --- .github/workflows/annotate-test-reports.yml | 30 +++++++++++++++++++++ .github/workflows/pr-coverage.yml | 3 +-- .github/workflows/test.yml | 16 +++-------- 3 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/annotate-test-reports.yml diff --git a/.github/workflows/annotate-test-reports.yml b/.github/workflows/annotate-test-reports.yml new file mode 100644 index 0000000..653f17c --- /dev/null +++ b/.github/workflows/annotate-test-reports.yml @@ -0,0 +1,30 @@ +name: Annotate CI run with test results +on: + workflow_run: + workflows: ["Run Tests"] + types: + - completed +permissions: + contents: read + +jobs: + annotate: + permissions: + checks: write + + name: Annotate CI run with test results + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion != 'cancelled' }} + strategy: + fail-fast: false + matrix: + node-version: [18.x, 20.x, 22.x] + timeout-minutes: 5 + steps: + - name: Annotate CI run with test results + uses: dorny/test-reporter@v1.8.0 + with: + artifact: test-reports-${{ matrix.node-version }} + name: Test Results (${{matrix.node-version}} + path: "test-results.json" + reporter: mocha-json \ No newline at end of file diff --git a/.github/workflows/pr-coverage.yml b/.github/workflows/pr-coverage.yml index b05e148..98b903e 100644 --- a/.github/workflows/pr-coverage.yml +++ b/.github/workflows/pr-coverage.yml @@ -10,11 +10,10 @@ permissions: jobs: coverage_report: name: Generate coverage report - needs: testing runs-on: ubuntu-latest strategy: matrix: - node-version: 22.x + node-version: [20.x] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 37cc370..784b387 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,8 +10,6 @@ permissions: contents: read checks: write pull-requests: write - actions: read - checks: write jobs: build: @@ -37,16 +35,8 @@ jobs: - name: Run Tests and Linting run: npm run test - - - name: Test Report - uses: dorny/test-reporter@v1 - with: - name: Mocha Tests - path: test/reports/test-results.json - reporter: mocha-json - - name: Cucumber annotations - uses: deblockt/cucumber-report-annotations-action@v1.7 + - uses: actions/upload-artifact@v3 with: - access-token: ${{ secrets.GITHUB_TOKEN }} - path: "test/reports/cucumber-report.json" + name: test-reports-${{ matrix.node-version }} + path: test/reports/ From 51726061a0dc0eccbc871c6ab4203009028612e7 Mon Sep 17 00:00:00 2001 From: Nicholas Date: Mon, 6 May 2024 17:34:22 +0100 Subject: [PATCH 09/14] chore: install deps --- .github/workflows/pr-coverage.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pr-coverage.yml b/.github/workflows/pr-coverage.yml index 98b903e..3f5f82a 100644 --- a/.github/workflows/pr-coverage.yml +++ b/.github/workflows/pr-coverage.yml @@ -23,6 +23,9 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'npm' + - name: Install Node Modules + run: npm ci + - name: Setup LCOV run: npm run lcov From 9983920c8f87051b37d4fd17a5128b691155cc53 Mon Sep 17 00:00:00 2001 From: Nicholas Date: Mon, 6 May 2024 17:38:24 +0100 Subject: [PATCH 10/14] chore: add lcov setup --- .github/workflows/pr-coverage.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-coverage.yml b/.github/workflows/pr-coverage.yml index 3f5f82a..a5cdb4c 100644 --- a/.github/workflows/pr-coverage.yml +++ b/.github/workflows/pr-coverage.yml @@ -26,9 +26,12 @@ jobs: - name: Install Node Modules run: npm ci - - name: Setup LCOV + - name: Run Coverage Check run: npm run lcov + - name: Setup LCOV + uses: hrishikesh-kadam/setup-lcov@v1 + - name: Report code coverage uses: zgosalvez/github-actions-report-lcov@v3 with: From 86b06d065751c76dca013730e8ae8714341155e8 Mon Sep 17 00:00:00 2001 From: Nicholas Date: Mon, 6 May 2024 17:44:00 +0100 Subject: [PATCH 11/14] chore: wrong filename --- .github/workflows/pr-coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-coverage.yml b/.github/workflows/pr-coverage.yml index a5cdb4c..2e0b858 100644 --- a/.github/workflows/pr-coverage.yml +++ b/.github/workflows/pr-coverage.yml @@ -35,7 +35,7 @@ jobs: - name: Report code coverage uses: zgosalvez/github-actions-report-lcov@v3 with: - coverage-files: coverage/lcov.*.info + coverage-files: coverage/lcov.info minimum-coverage: 90 artifact-name: code-coverage-report github-token: ${{ secrets.GITHUB_TOKEN }} From efdcbf555f8d13b50ceb0e4672b52b4eaf4c796c Mon Sep 17 00:00:00 2001 From: Nicholas Date: Mon, 6 May 2024 17:46:26 +0100 Subject: [PATCH 12/14] chore: update actions/upload-artifact --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 784b387..f9565d0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,7 +36,7 @@ jobs: - name: Run Tests and Linting run: npm run test - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: test-reports-${{ matrix.node-version }} path: test/reports/ From 63d507f9881d71cbe1e740efe61610f1e25bf0a4 Mon Sep 17 00:00:00 2001 From: Nicholas Date: Mon, 6 May 2024 17:48:21 +0100 Subject: [PATCH 13/14] chore: see if this triggers now --- .github/workflows/annotate-test-reports.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/annotate-test-reports.yml b/.github/workflows/annotate-test-reports.yml index 653f17c..0440311 100644 --- a/.github/workflows/annotate-test-reports.yml +++ b/.github/workflows/annotate-test-reports.yml @@ -1,7 +1,8 @@ name: Annotate CI run with test results on: workflow_run: - workflows: ["Run Tests"] + workflows: + - "Run Tests" types: - completed permissions: From b0d4bbe4fb49a02c1d74cf03a20b2c0b9275898d Mon Sep 17 00:00:00 2001 From: Nicholas Date: Mon, 6 May 2024 17:50:25 +0100 Subject: [PATCH 14/14] chore: try updating permissions --- .github/workflows/annotate-test-reports.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/annotate-test-reports.yml b/.github/workflows/annotate-test-reports.yml index 0440311..dae5736 100644 --- a/.github/workflows/annotate-test-reports.yml +++ b/.github/workflows/annotate-test-reports.yml @@ -6,13 +6,13 @@ on: types: - completed permissions: + actions: read contents: read + checks: write + pull-requests: write jobs: annotate: - permissions: - checks: write - name: Annotate CI run with test results runs-on: ubuntu-latest if: ${{ github.event.workflow_run.conclusion != 'cancelled' }}