From dfc660e73c1d6940681ca0b07a6a80b50eb3fc39 Mon Sep 17 00:00:00 2001 From: Jose Castelli Date: Wed, 17 Sep 2025 08:39:08 +0200 Subject: [PATCH] Setup QLTY Initial Coverage Metrics (#6167) Setup QLTY Initial Coverage Metrics --- .changeset/silver-bats-accept.md | 5 ++++ .github/workflows/test.yml | 48 ++++++++++++++++++++++++++++++-- .gitignore | 2 ++ .nycrc.unit.json | 48 ++++++++++++++++++++++++++++++++ webview-ui/vite.config.ts | 23 +++++++++++++++ 5 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 .changeset/silver-bats-accept.md create mode 100644 .nycrc.unit.json diff --git a/.changeset/silver-bats-accept.md b/.changeset/silver-bats-accept.md new file mode 100644 index 0000000000..f16a86b2f4 --- /dev/null +++ b/.changeset/silver-bats-accept.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Setup QLTY Initial Coverage Metrics diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fd9c7fac30..dd5bc8af44 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -90,8 +90,14 @@ jobs: - name: Build Tests and Extension run: npm run pretest - - name: Unit Tests - run: npm run test:unit + - name: Unit Tests (with coverage on Linux) + run: | + if [ "${{ runner.os }}" = "Linux" ]; then + npm install --no-save nyc + npx nyc --nycrc-path .nycrc.unit.json --reporter=lcov npm run test:unit + else + npm run test:unit + fi # Run extension tests with coverage - name: Extension Integration Tests with Coverage @@ -125,6 +131,8 @@ jobs: path: | extension_coverage.txt webview-ui/webview_coverage.txt + coverage-unit/lcov.info + webview-ui/coverage/lcov.info # Set the check as failed if any of the tests failed - name: Check for test failures @@ -219,3 +227,39 @@ jobs: --verbose env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + qlty: + needs: test + runs-on: ubuntu-latest + # Run on PRs to main, pushes to main, and manual dispatches + if: always() && needs.test.result == 'success' + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history for accurate comparison + + - name: Download Coverage Reports + uses: actions/download-artifact@v4 + with: + name: pr-coverage-reports + path: . + + - name: Upload core unit tests coverage to Qlty + uses: qltysh/qlty-action/coverage@v2 + with: + token: ${{ secrets.QLTY_COVERAGE_TOKEN }} + # we can merge multiple files if necessary + files: | + coverage-unit/lcov.info + tag: unit:core + + - name: Upload webview-ui unit tests coverage to Qlty + uses: qltysh/qlty-action/coverage@v2 + with: + token: ${{ secrets.QLTY_COVERAGE_TOKEN }} + # we can merge multiple files if necessary + files: | + webview-ui/coverage/lcov.info + tag: unit:webview-ui + add-prefix: webview-ui/ diff --git a/.gitignore b/.gitignore index ba31697749..cd3beef220 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,8 @@ webview-ui/src/**/*.js.map # Ignore coverage directories and files coverage +coverage-unit +.nyc_output # But don't ignore the coverage scripts in .github/scripts/ !.github/scripts/coverage/ diff --git a/.nycrc.unit.json b/.nycrc.unit.json new file mode 100644 index 0000000000..06b184267f --- /dev/null +++ b/.nycrc.unit.json @@ -0,0 +1,48 @@ +{ + "all": true, + "check-coverage": false, + "reporter": [ + "text", + "lcov" + ], + "include": [ + "src/**/*.ts" + ], + "exclude": [ + "**/*.d.ts", + + "**/*.{test,spec}.{js,jsx,ts,tsx,mjs,cjs}", + "**/__tests__/**", + "**/test/**", + "**/tests/**", + "**/.nyc_output/**", + "**/.vscode-test/**", + "**/tests-results/**", + "src/test/**", + + "src/generated/**", + + "**/node_modules/**", + "**/dist/**", + "**/out/**", + "**/build/**", + "**/coverage/**", + "**/coverage-unit/**", + "**/proto/**", + + "**/*.{config,setup}.{js,ts,mjs,cjs}", + "**/vite-env.d.ts", + + "**/*.{css,scss,sass,less,styl}", + "**/*.{svg,png,jpg,jpeg,gif,ico}", + "**/*.{json,yaml,yml}" + ], + "extension": [ + ".ts", + ".js" + ], + "cache": true, + "sourceMap": true, + "instrument": true, + "report-dir": "./coverage-unit" +} diff --git a/webview-ui/vite.config.ts b/webview-ui/vite.config.ts index 6cee31d722..234ee2f787 100644 --- a/webview-ui/vite.config.ts +++ b/webview-ui/vite.config.ts @@ -46,6 +46,29 @@ export default defineConfig({ coverage: { provider: "v8", reportOnFailure: true, + reporter: ["html", "lcov", "text"], + reportsDirectory: "./coverage", + exclude: [ + "**/*.{spec,test}.{js,jsx,ts,tsx,mjs,cjs}", + + "**/*.d.ts", + "**/vite-env.d.ts", + "**/*.{config,setup}.{js,ts,mjs,cjs}", + + "**/*.{css,scss,sass,less,styl}", + "**/*.{svg,png,jpg,jpeg,gif,ico}", + + "**/*.{json,yaml,yml}", + + "**/__mocks__/**", + "node_modules/**", + "build/**", + "coverage/**", + "dist/**", + "public/**", + + "src/services/grpc-client.ts", + ], }, }, build: {