mirror of
https://github.com/saltbo/zpan.git
synced 2026-08-28 15:51:29 +08:00
ci: enforce merged coverage thresholds
This commit is contained in:
+46
-12
@@ -84,15 +84,17 @@ jobs:
|
||||
node-version: 24
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: pnpm exec vitest run --project unit --shard=${{ matrix.shard }}/2 --coverage --coverage.reportsDirectory=coverage/unit-${{ matrix.shard }}
|
||||
- uses: codecov/codecov-action@v5
|
||||
- name: Run unit shard
|
||||
env:
|
||||
VITEST_BLOB_LABEL: unit-${{ matrix.shard }}
|
||||
run: pnpm exec vitest run --project unit --shard=${{ matrix.shard }}/2 --coverage --coverage.reportsDirectory=coverage/unit-${{ matrix.shard }} --reporter=default --reporter=blob --outputFile.blob=.vitest-reports/unit-${{ matrix.shard }}.blob
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
files: coverage/unit-${{ matrix.shard }}/coverage-final.json
|
||||
flags: unit
|
||||
disable_search: true
|
||||
fail_ci_if_error: false
|
||||
handle_no_reports_found: true
|
||||
name: vitest-coverage-unit-${{ matrix.shard }}
|
||||
path: .vitest-reports/unit-${{ matrix.shard }}.blob
|
||||
include-hidden-files: true
|
||||
retention-days: 1
|
||||
|
||||
integration:
|
||||
name: Integration tests (${{ matrix.shard }}/2)
|
||||
@@ -110,12 +112,45 @@ jobs:
|
||||
node-version: 24
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- run: pnpm exec vitest run --project integration --shard=${{ matrix.shard }}/2 --coverage --coverage.reportsDirectory=coverage/integration-${{ matrix.shard }}
|
||||
- name: Run integration shard
|
||||
env:
|
||||
VITEST_BLOB_LABEL: integration-${{ matrix.shard }}
|
||||
run: pnpm exec vitest run --project integration --shard=${{ matrix.shard }}/2 --coverage --coverage.reportsDirectory=coverage/integration-${{ matrix.shard }} --reporter=default --reporter=blob --outputFile.blob=.vitest-reports/integration-${{ matrix.shard }}.blob
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
name: vitest-coverage-integration-${{ matrix.shard }}
|
||||
path: .vitest-reports/integration-${{ matrix.shard }}.blob
|
||||
include-hidden-files: true
|
||||
retention-days: 1
|
||||
|
||||
coverage:
|
||||
name: Coverage gate
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'saltbo/zpan'
|
||||
needs: [unit, integration]
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 24
|
||||
cache: pnpm
|
||||
- run: pnpm install --frozen-lockfile
|
||||
- uses: actions/download-artifact@v5
|
||||
with:
|
||||
pattern: vitest-coverage-*
|
||||
path: .vitest-reports
|
||||
merge-multiple: true
|
||||
- name: Merge coverage and enforce thresholds
|
||||
env:
|
||||
COVERAGE_ENFORCE: '1'
|
||||
run: pnpm exec vitest --merge-reports=.vitest-reports --coverage --reporter=agent --coverage.reportsDirectory=coverage/merged
|
||||
- uses: codecov/codecov-action@v5
|
||||
if: always()
|
||||
with:
|
||||
files: coverage/integration-${{ matrix.shard }}/coverage-final.json
|
||||
flags: integration
|
||||
files: coverage/merged/coverage-final.json
|
||||
flags: unit,integration
|
||||
disable_search: true
|
||||
fail_ci_if_error: false
|
||||
handle_no_reports_found: true
|
||||
@@ -144,8 +179,7 @@ jobs:
|
||||
needs:
|
||||
- downloader
|
||||
- static
|
||||
- unit
|
||||
- integration
|
||||
- coverage
|
||||
- cloudflare
|
||||
- docker-smoke
|
||||
- docker-cli-smoke
|
||||
|
||||
+14
-19
@@ -33,12 +33,25 @@ const coverageConfig = {
|
||||
'src/**/*.integration.test.ts',
|
||||
'src/i18n/index.ts',
|
||||
],
|
||||
reporter: ['text', 'json'] as const,
|
||||
reporter: ['text-summary', 'json'] as const,
|
||||
}
|
||||
|
||||
const coverageGate =
|
||||
process.env.COVERAGE_ENFORCE === '1'
|
||||
? {
|
||||
thresholds: {
|
||||
statements: 85,
|
||||
branches: 80,
|
||||
functions: 75,
|
||||
lines: 90,
|
||||
},
|
||||
}
|
||||
: {}
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
globals: true,
|
||||
coverage: { ...coverageConfig, ...coverageGate },
|
||||
projects: [
|
||||
{
|
||||
plugins: [react()],
|
||||
@@ -55,15 +68,6 @@ export default defineConfig({
|
||||
],
|
||||
exclude: ['**/*.integration.test.ts', '**/*.cf-test.ts', '**/e2e-*.test.ts'],
|
||||
setupFiles: ['./server/test/app-version.ts'],
|
||||
coverage: {
|
||||
...coverageConfig,
|
||||
thresholds: {
|
||||
statements: 60,
|
||||
branches: 50,
|
||||
functions: 40,
|
||||
lines: 60,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -72,15 +76,6 @@ export default defineConfig({
|
||||
name: 'integration',
|
||||
include: ['server/**/*.integration.test.ts', 'src/**/*.integration.test.ts'],
|
||||
setupFiles: ['./server/test/app-version.ts'],
|
||||
coverage: {
|
||||
...coverageConfig,
|
||||
thresholds: {
|
||||
statements: 90,
|
||||
branches: 80,
|
||||
functions: 90,
|
||||
lines: 90,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user