From 64ff3fbce50fb6e332537d15a9db5ff597af009b Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Mon, 27 Jan 2025 17:07:13 -0600 Subject: [PATCH 01/10] Debug GH action --- .github/workflows/unit.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index c302e545..33a7ecd8 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -24,6 +24,7 @@ jobs: run: | npm run report:junit2ctrf npm run report:ctrfsummary + echo "Summary: $GITHUB_STEP_SUMMARY" sed -i 's/

Test Summary<\/h3>/

Unit Test Summary<\/h3>/' $GITHUB_STEP_SUMMARY npm run report:prcomment - name: Save PR Number From 5095747f628e3488e95e840b8473af1bdb67999c Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Mon, 27 Jan 2025 17:14:56 -0600 Subject: [PATCH 02/10] Fixed unit test report path --- .github/workflows/unit.yml | 1 - package.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 33a7ecd8..c302e545 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -24,7 +24,6 @@ jobs: run: | npm run report:junit2ctrf npm run report:ctrfsummary - echo "Summary: $GITHUB_STEP_SUMMARY" sed -i 's/

Test Summary<\/h3>/

Unit Test Summary<\/h3>/' $GITHUB_STEP_SUMMARY npm run report:prcomment - name: Save PR Number diff --git a/package.json b/package.json index 677f3dce..3c5b8806 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "test:ci": "npm run compile && npm run test:lint && npm run test:unit", "test:e2e": "npm run compile && cd e2e && wdio run ./wdio.conf.ts", "test:lint": "eslint . --ext ts", - "test:unit": "vitest --reporter=default --reporter=junit --outputFile=./test-reports/vitest.junit.xml", + "test:unit": "vitest --reporter=default --reporter=junit --outputFile=../test-reports/vitest.junit.xml", "test": "npm run test:unit", "vscode:prepublish": "npm run compile:prod", "watch:esbuild": "node scripts/esbuild.js --watch", From d05140dba9e13dbc7ba4baf43fd75652c53ed5e4 Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Mon, 27 Jan 2025 17:26:57 -0600 Subject: [PATCH 03/10] Testing CI failure --- .github/workflows/e2e.yml | 1 + .github/workflows/unit.yml | 1 + package.json | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index e50724ca..f8e3968c 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -22,6 +22,7 @@ jobs: - name: Publish Test Summary Results if: ${{ always() }} run: | + set -e npm run report:ctrfmerge npm run report:ctrfsummary sed -i 's/

Test Summary<\/h3>/

End-to-end Test Summary<\/h3>/' $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index c302e545..6bf9abaf 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -22,6 +22,7 @@ jobs: - name: Publish Test Summary Results if: ${{ always() }} run: | + set -e npm run report:junit2ctrf npm run report:ctrfsummary sed -i 's/

Test Summary<\/h3>/

Unit Test Summary<\/h3>/' $GITHUB_STEP_SUMMARY diff --git a/package.json b/package.json index 3c5b8806..677f3dce 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "test:ci": "npm run compile && npm run test:lint && npm run test:unit", "test:e2e": "npm run compile && cd e2e && wdio run ./wdio.conf.ts", "test:lint": "eslint . --ext ts", - "test:unit": "vitest --reporter=default --reporter=junit --outputFile=../test-reports/vitest.junit.xml", + "test:unit": "vitest --reporter=default --reporter=junit --outputFile=./test-reports/vitest.junit.xml", "test": "npm run test:unit", "vscode:prepublish": "npm run compile:prod", "watch:esbuild": "node scripts/esbuild.js --watch", From 08665cb13584ef7672ba0158afe86f29581778c4 Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Mon, 27 Jan 2025 17:51:42 -0600 Subject: [PATCH 04/10] Fail CI build if missing junit report --- .github/workflows/e2e.yml | 1 - .github/workflows/unit.yml | 1 - package.json | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index f8e3968c..e50724ca 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -22,7 +22,6 @@ jobs: - name: Publish Test Summary Results if: ${{ always() }} run: | - set -e npm run report:ctrfmerge npm run report:ctrfsummary sed -i 's/

Test Summary<\/h3>/

End-to-end Test Summary<\/h3>/' $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index 6bf9abaf..c302e545 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -22,7 +22,6 @@ jobs: - name: Publish Test Summary Results if: ${{ always() }} run: | - set -e npm run report:junit2ctrf npm run report:ctrfsummary sed -i 's/

Test Summary<\/h3>/

Unit Test Summary<\/h3>/' $GITHUB_STEP_SUMMARY diff --git a/package.json b/package.json index 677f3dce..e2fa1784 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "publish:prerelease": "./scripts/publish-prerelease.sh", "report:ctrfmerge": "ctrf merge e2e/reports --keep-reports --output-dir test-reports --output ctrf-report.json", "report:ctrfsummary": "github-actions-ctrf test-reports/ctrf-report.json", - "report:junit2ctrf": "junit-to-ctrf test-reports/vitest.junit.xml --output test-reports/ctrf-report.json", + "report:junit2ctrf": "test -e test-reports/vitest.junit.xml && junit-to-ctrf test-reports/vitest.junit.xml --output test-reports/ctrf-report.json || echo 'test-reports/vitest.junit.xml not found.'", "report:prcomment": "mkdir -p ./pr-comment && cp $GITHUB_STEP_SUMMARY pr-comment/pr-comment.html", "test:ci": "npm run compile && npm run test:lint && npm run test:unit", "test:e2e": "npm run compile && cd e2e && wdio run ./wdio.conf.ts", From 541d69a66b83d49929a88a5a310e796fa8de794d Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Mon, 27 Jan 2025 18:10:52 -0600 Subject: [PATCH 05/10] Fail build after PR number generation --- .github/workflows/unit.yml | 10 ++++++++++ package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unit.yml b/.github/workflows/unit.yml index c302e545..e1199ace 100644 --- a/.github/workflows/unit.yml +++ b/.github/workflows/unit.yml @@ -26,6 +26,16 @@ jobs: npm run report:ctrfsummary sed -i 's/

Test Summary<\/h3>/

Unit Test Summary<\/h3>/' $GITHUB_STEP_SUMMARY npm run report:prcomment + + # The junit-to-ctrf npm package exits with a 0 status code even if + # it fails to parse the JUnit report, so check for the file manually + # and explicilty exit with a non-zero status code if it's not found. + # We do this after npm run report:prcomment so that the PR number can + # still be associated in subsequent steps. + if [ ! -e test-reports/vitest.junit.xml ]; then + echo "No JUnit report found at test-reports/vitest.junit.xml" + exit 1 + fi - name: Save PR Number if: ${{ always() }} run: echo ${{ github.event.number }} > pr-comment/PR-number.txt diff --git a/package.json b/package.json index e2fa1784..677f3dce 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "publish:prerelease": "./scripts/publish-prerelease.sh", "report:ctrfmerge": "ctrf merge e2e/reports --keep-reports --output-dir test-reports --output ctrf-report.json", "report:ctrfsummary": "github-actions-ctrf test-reports/ctrf-report.json", - "report:junit2ctrf": "test -e test-reports/vitest.junit.xml && junit-to-ctrf test-reports/vitest.junit.xml --output test-reports/ctrf-report.json || echo 'test-reports/vitest.junit.xml not found.'", + "report:junit2ctrf": "junit-to-ctrf test-reports/vitest.junit.xml --output test-reports/ctrf-report.json", "report:prcomment": "mkdir -p ./pr-comment && cp $GITHUB_STEP_SUMMARY pr-comment/pr-comment.html", "test:ci": "npm run compile && npm run test:lint && npm run test:unit", "test:e2e": "npm run compile && cd e2e && wdio run ./wdio.conf.ts", From 6dcbafec6a67dd6616d45b4cccf6aedce941451c Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Mon, 27 Jan 2025 18:14:49 -0600 Subject: [PATCH 06/10] Fix CI build --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 677f3dce..3c5b8806 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "test:ci": "npm run compile && npm run test:lint && npm run test:unit", "test:e2e": "npm run compile && cd e2e && wdio run ./wdio.conf.ts", "test:lint": "eslint . --ext ts", - "test:unit": "vitest --reporter=default --reporter=junit --outputFile=./test-reports/vitest.junit.xml", + "test:unit": "vitest --reporter=default --reporter=junit --outputFile=../test-reports/vitest.junit.xml", "test": "npm run test:unit", "vscode:prepublish": "npm run compile:prod", "watch:esbuild": "node scripts/esbuild.js --watch", From 4d0aa20c052cc44532fa3a9cba55a55d8e8e62ae Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Tue, 28 Jan 2025 11:33:10 -0600 Subject: [PATCH 07/10] Addressed code review comments --- .eslintrc.json | 8 ++++---- {src/__mocks__ => __mocks__}/vscode.ts | 4 +++- package.json | 2 +- vitest.config.mts | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) rename {src/__mocks__ => __mocks__}/vscode.ts (84%) diff --git a/.eslintrc.json b/.eslintrc.json index 1f6c16a2..74529563 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -19,11 +19,11 @@ "overrides": [ { "files": ["*.ts"], - // Since parserOptions.project is used, can't include files outside of + // Since parserOptions.project is used, we can't include files outside of // the listed tsconfig files and seems silly to add a tsconfig just for - // the one file. It will still be linted by the base config above. It just - // won't be included in this overrides section. - "excludedFiles": ["vitest.config.ts"], + // a few vitest files. These files will still be linted by the base config + // above. They just won't be included in this overrides section. + "excludedFiles": ["__mocks__/**/*.ts", "vitest.config.ts"], "parserOptions": { "project": [ "./tsconfig.json", diff --git a/src/__mocks__/vscode.ts b/__mocks__/vscode.ts similarity index 84% rename from src/__mocks__/vscode.ts rename to __mocks__/vscode.ts index 40573747..6399f5ad 100644 --- a/src/__mocks__/vscode.ts +++ b/__mocks__/vscode.ts @@ -2,7 +2,9 @@ /** * Mock `vscode` module. Note that `vi.mock('vscode')` has to be explicitly * called in any test module needing to use this mock. It will not be loaded - * automatically. + * automatically. This module also needs to be located under the `__mocks__` + * directory under the project root to be found when `vi.mock('vscode')` is + * called. */ import { vi } from 'vitest'; diff --git a/package.json b/package.json index 3c5b8806..677f3dce 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "test:ci": "npm run compile && npm run test:lint && npm run test:unit", "test:e2e": "npm run compile && cd e2e && wdio run ./wdio.conf.ts", "test:lint": "eslint . --ext ts", - "test:unit": "vitest --reporter=default --reporter=junit --outputFile=../test-reports/vitest.junit.xml", + "test:unit": "vitest --reporter=default --reporter=junit --outputFile=./test-reports/vitest.junit.xml", "test": "npm run test:unit", "vscode:prepublish": "npm run compile:prod", "watch:esbuild": "node scripts/esbuild.js --watch", diff --git a/vitest.config.mts b/vitest.config.mts index bcc2ba9f..ed0975f8 100644 --- a/vitest.config.mts +++ b/vitest.config.mts @@ -3,7 +3,7 @@ import { defineConfig } from 'vite'; export default defineConfig({ test: { - root: 'src', + include: ['src/**/*.spec.ts'], server: { deps: { // Imports of .js files without extensions fail without this From 99e2fa6b7713b8d24a732f7db5ab9f4b84dc4134 Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Tue, 28 Jan 2025 11:45:30 -0600 Subject: [PATCH 08/10] Renamed orchestrator --- .github/workflows/ci.yml | 2 +- .github/workflows/pr-comment.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4fd14e7..39c6974d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,7 @@ # This action orchestrates CI actions that can be run in parallel. This action # can be listed by any actions that use `workflow_run` as a trigger that depend # on all orchestrated actions being completed (e.g. pr-comment.yml). -name: 'Orchestrator' +name: 'Tests' on: push: branches: diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index 7b15d59d..1d2149e0 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -13,7 +13,7 @@ name: End-to-end PR Comment # access to secrets on: workflow_run: - workflows: ['Orchestrator'] + workflows: ['Tests'] types: - completed From 9b3605a50b806b316fea128399c684024076def6 Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Tue, 28 Jan 2025 11:46:20 -0600 Subject: [PATCH 09/10] Renamed orchestrator again --- .github/workflows/ci.yml | 2 +- .github/workflows/pr-comment.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 39c6974d..270110cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,7 @@ # This action orchestrates CI actions that can be run in parallel. This action # can be listed by any actions that use `workflow_run` as a trigger that depend # on all orchestrated actions being completed (e.g. pr-comment.yml). -name: 'Tests' +name: 'CI Tests' on: push: branches: diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index 1d2149e0..4d9b410b 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -13,7 +13,7 @@ name: End-to-end PR Comment # access to secrets on: workflow_run: - workflows: ['Tests'] + workflows: ['CI Tests'] types: - completed From ed7323b1f434d438b3095c5d9bc59035d118d51b Mon Sep 17 00:00:00 2001 From: Brian Ingles Date: Wed, 29 Jan 2025 09:34:06 -0600 Subject: [PATCH 10/10] Update vitest.config.mts Co-authored-by: Mike Bender --- vitest.config.mts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vitest.config.mts b/vitest.config.mts index ed0975f8..2e75bc96 100644 --- a/vitest.config.mts +++ b/vitest.config.mts @@ -3,7 +3,7 @@ import { defineConfig } from 'vite'; export default defineConfig({ test: { - include: ['src/**/*.spec.ts'], + dir: 'src', server: { deps: { // Imports of .js files without extensions fail without this