From b1d1aef702f7fd2a19a558cc32c01b5d1ab1c96e Mon Sep 17 00:00:00 2001 From: chihlasm Date: Wed, 18 Mar 2026 02:41:00 +0000 Subject: [PATCH] ci: enforce 80% backend coverage gate and add frontend coverage reporting Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/ci.yml | 6 +++--- .gitignore | 1 + frontend/package.json | 3 +++ frontend/vite.config.ts | 12 ++++++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63630367..bf17e58a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: run: pip install -r backend/requirements.txt -r backend/requirements-dev.txt - name: Run tests with coverage - run: cd backend && python -m pytest --override-ini="addopts=" --cov=app --cov-report=term-missing --cov-report=json:coverage.json + run: cd backend && python -m pytest --override-ini="addopts=" --cov=app --cov-report=term-missing --cov-report=json:coverage.json --cov-fail-under=80 - name: Display coverage summary if: always() @@ -89,8 +89,8 @@ jobs: - name: Lint run: cd frontend && npm run lint - - name: Test - run: cd frontend && npm test + - name: Test with coverage + run: cd frontend && npm run test:coverage - name: Build run: cd frontend && npm run build diff --git a/.gitignore b/.gitignore index cfb5aab2..fbe1c9e2 100644 --- a/.gitignore +++ b/.gitignore @@ -219,6 +219,7 @@ frontend/stats.html frontend/playwright-report/ frontend/test-results/ frontend/e2e/.auth/ +frontend/coverage/ # Superpowers brainstorming mockups .superpowers/ diff --git a/frontend/package.json b/frontend/package.json index ae7e4618..721a2590 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -12,6 +12,7 @@ "lint": "eslint .", "preview": "vite preview", "test": "vitest run", + "test:coverage": "vitest run --coverage", "test:watch": "vitest", "test:e2e": "playwright test", "test:e2e:headed": "playwright test --headed", @@ -48,6 +49,7 @@ "recharts": "^3.7.0", "sonner": "^2.0.7", "tailwind-merge": "^3.4.0", + "web-vitals": "^4.2.4", "zundo": "^2.3.0", "zustand": "^5.0.10" }, @@ -60,6 +62,7 @@ "@types/node": "^24.10.9", "@types/react": "^19.2.5", "@types/react-dom": "^19.2.3", + "@vitest/coverage-v8": "^4.0.18", "@vitejs/plugin-react": "^5.1.1", "eslint": "^9.39.1", "eslint-plugin-react-hooks": "^7.0.1", diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 38c64084..de98c4f0 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -33,6 +33,18 @@ export default defineConfig({ environment: 'jsdom', setupFiles: './src/test/setup.ts', include: ['src/**/*.{test,spec}.{ts,tsx}'], + coverage: { + provider: 'v8', + reporter: ['text', 'json-summary', 'html'], + include: ['src/**/*.{ts,tsx}'], + exclude: [ + 'src/test/**', + 'src/types/**', + 'src/**/*.d.ts', + 'src/instrument.ts', + 'src/main.tsx', + ], + }, }, build: { sourcemap: 'hidden', // Generate source maps but don't expose them publicly