diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b226e01..1bf5634 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,10 +28,17 @@ jobs: run: npm run typecheck --if-present - name: Build run: npm run build - - name: Test (optional) + - name: Test with coverage run: | - if npm run | grep -qE '^[[:space:]]+test'; then - npm test -- --watch=false + if npm run | grep -qE '^[[:space:]]+test:coverage'; then + mkdir -p coverage + npm run test:coverage else - echo "No test script defined; skipping tests." + echo "No test:coverage script defined; skipping tests." fi + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage/lcov.info + fail_ci_if_error: false diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..df39a3e --- /dev/null +++ b/codecov.yml @@ -0,0 +1,22 @@ +coverage: + status: + project: + default: + target: 70% + threshold: 5% + patch: + default: + target: 60% + threshold: 10% + +comment: + layout: "reach,diff,flags,tree" + behavior: default + require_changes: true + +ignore: + - "src/vite-env.d.ts" + - "**/*.d.ts" + - "dist/**" + - "scripts/**/*.test.ts" + - "scripts/**/*.test.mjs" diff --git a/package.json b/package.json index 719969b..0f69cef 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "format:check": "prettier --check src", "prepare": "husky", "test": "node --test --experimental-strip-types scripts/permissions/*.test.ts scripts/foundation/*.test.ts scripts/fleet-command/*.test.ts scripts/staffing-templates/*.test.mjs scripts/wiki-sync/*.test.mjs", + "test:coverage": "node --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test-reporter=spec --test-reporter-destination=stdout --test --experimental-strip-types scripts/permissions/*.test.ts scripts/foundation/*.test.ts scripts/fleet-command/*.test.ts scripts/staffing-templates/*.test.mjs scripts/wiki-sync/*.test.mjs", "test:data": "node --test scripts/staffing-templates/*.test.mjs scripts/wiki-sync/*.test.mjs", "staffing:generate-reviewed": "node scripts/staffing-templates/generate-reviewed-staffing-template-sql.mjs", "db:load-generated": "bash scripts/supabase/load-generated-local-data.sh",