Kaynağa Gözat

Setup QLTY Initial Coverage Metrics (#6167)

Setup QLTY Initial Coverage Metrics
Jose Castelli 3 ay önce
ebeveyn
işleme
dfc660e73c

+ 5 - 0
.changeset/silver-bats-accept.md

@@ -0,0 +1,5 @@
+---
+"claude-dev": patch
+---
+
+Setup QLTY Initial Coverage Metrics

+ 46 - 2
.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/

+ 2 - 0
.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/
 

+ 48 - 0
.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"
+}

+ 23 - 0
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: {