From ec802b1986e4ec27b392138ecda66178441bb1db Mon Sep 17 00:00:00 2001 From: James Pogran Date: Thu, 5 Dec 2024 10:23:54 -0500 Subject: [PATCH 1/4] (TFECO-8268) Enable code coverage reporting This commit enables code coverage reporting for the integration test suites. It uses the `vscode-test` extension's built-in code coverage reporting feature to generate coverage reports for the test suites. --- .gitignore | 1 + .vscode-test.mjs | 16 +++++++++++++++- package.json | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 828e1609e1..536a3e5497 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ .test-extensions *.vsix bin +coverage node_modules npm-debug.log dist diff --git a/.vscode-test.mjs b/.vscode-test.mjs index e477712057..40379ed956 100644 --- a/.vscode-test.mjs +++ b/.vscode-test.mjs @@ -18,6 +18,7 @@ const testSuiteFolderNames = fs .map((entry) => entry.name); const configs = testSuiteFolderNames.map((folderName) => ({ + label: `Integration Tests - ${folderName}`, version: process.env['VSCODE_VERSION'] ?? 'stable', workspaceFolder: process.env['VSCODE_WORKSPACE_FOLDER'] ?? path.join(BASE_SRC_PATH, folderName, 'workspace'), launchArgs: ['--disable-extensions', '--disable-workspace-trust'], @@ -30,6 +31,19 @@ const configs = testSuiteFolderNames.map((folderName) => ({ }, })); -const config = defineConfig(configs); +const config = defineConfig({ + tests: configs, + coverage: { + exclude: ['src/test/**', '**/node_modules/**', '**/dist/**'], + thresholds: { + global: { + statements: 80, + branches: 80, + functions: 80, + lines: 80, + }, + }, + }, +}); export default config; diff --git a/package.json b/package.json index 46870c4b84..c22197f67e 100644 --- a/package.json +++ b/package.json @@ -946,7 +946,7 @@ "vscode:prepublish": "npm run compile:prod", "package": "vsce package", "pretest": "npm run compile:tests && npm run compile && npm run lint", - "test": "vscode-test", + "test": "vscode-test --coverage", "test:ui": "npm run compile:tests && node .vscode-uitest.mjs", "lint": "eslint", "format": "prettier --write .", From e1afe3b317c92f739c40ec5b1714df4f21a80b98 Mon Sep 17 00:00:00 2001 From: James Pogran Date: Thu, 5 Dec 2024 09:34:48 -0500 Subject: [PATCH 2/4] Reduce the number of duplicate steps in CI Previously if you were to run `npm run compile` or `npm test`, you would be executing `npm run check-types`, then `npm run lint`, and finally `node esbuild.mjs` or `vscode-test`, respectively, every time you wanted to compile or test the code. This duplication added several seconds to the build or test time. This was unecessary when running interactively, and even more so in CI where these steps were repeated multiple times. This change reduces the number of duplicate steps in CI by running type checking, linting, and formatting only once before compiling or running tests. It also results in a faster run time interactively because we aren't running the more intensive type checking every time. This becomes more important as we added UI testing to the CI pipeline, which is a more intensive process than the other steps. --- .github/workflows/test.yml | 6 ++++-- package.json | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7949701f4b..cf37a13d2d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,10 +31,12 @@ jobs: cache: npm - name: npm install run: npm ci - - name: lint - run: npm run lint + - name: check types + run: npm run check-types - name: format run: npm run check-format + - name: lint + run: npm run lint test: strategy: diff --git a/package.json b/package.json index c22197f67e..77b8e8bcdb 100644 --- a/package.json +++ b/package.json @@ -929,7 +929,7 @@ }, "scripts": { "prepare": "npm run download:artifacts", - "compile": "npm run check-types && npm run lint && node esbuild.mjs", + "compile": "node esbuild.mjs", "compile:prod": "npm run check-types && npm run lint && node esbuild.mjs --production", "compile:tests": "tsc -p .", "watch": "npm-run-all -p watch:esbuild watch:tsc", @@ -945,7 +945,7 @@ "download:artifacts": "node ./build/downloader.mjs", "vscode:prepublish": "npm run compile:prod", "package": "vsce package", - "pretest": "npm run compile:tests && npm run compile && npm run lint", + "pretest": "npm run compile:tests && npm run compile", "test": "vscode-test --coverage", "test:ui": "npm run compile:tests && node .vscode-uitest.mjs", "lint": "eslint", From 4de790f5004a812b83af1553c5851cbae5e50878 Mon Sep 17 00:00:00 2001 From: James Pogran Date: Thu, 5 Dec 2024 16:31:37 -0500 Subject: [PATCH 3/4] changelog --- .changes/unreleased/INTERNAL-20241205-163130.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/unreleased/INTERNAL-20241205-163130.yaml diff --git a/.changes/unreleased/INTERNAL-20241205-163130.yaml b/.changes/unreleased/INTERNAL-20241205-163130.yaml new file mode 100644 index 0000000000..9c235c9d82 --- /dev/null +++ b/.changes/unreleased/INTERNAL-20241205-163130.yaml @@ -0,0 +1,6 @@ +kind: INTERNAL +body: Enable code coverage reporting +time: 2024-12-05T16:31:30.723429-05:00 +custom: + Issue: "1901" + Repository: vscode-terraform From a5d00460637a8ac4d64e9c2931111e90117b08d7 Mon Sep 17 00:00:00 2001 From: James Pogran Date: Wed, 11 Dec 2024 11:22:44 -0500 Subject: [PATCH 4/4] Update .vscode-test.mjs Co-authored-by: Daniel Banck --- .vscode-test.mjs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.vscode-test.mjs b/.vscode-test.mjs index 40379ed956..c57d95c5a2 100644 --- a/.vscode-test.mjs +++ b/.vscode-test.mjs @@ -35,14 +35,6 @@ const config = defineConfig({ tests: configs, coverage: { exclude: ['src/test/**', '**/node_modules/**', '**/dist/**'], - thresholds: { - global: { - statements: 80, - branches: 80, - functions: 80, - lines: 80, - }, - }, }, });