ci: Report coverage with CodeCov (#2862)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* Output coverage per each test * Collect coverage * Exclude test-only files * update comment * exclude types * Add config * Update bun comment * Generate coverage in Deno
authored by TATSUNO “Taz” Yasuhiro · committed by GitHub · parent 0dfb794 · Browse files · 11 files·+117 added−4 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
11 files+117 added−4 removed
- other:+117 added−4 removed
Provenance
- Commit
8cc8a05- Tree
d4eb7f6- Author
TATSUNO “Taz” Yasuhiro <ytatsuno.jp@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
0dfb794
11 files changed+117 added−4 removed
modified:.github/workflows/ci.yml+57 added-3 removed
10 unmodified lines1112131415161718192021222324252627282930313233343536373839404142438 unmodified lines52535455565758596061626311 unmodified lines75767778505152798081828384858687888912 unmodified lines1021031041051061071081091101111121138 unmodified lines1221231241251261271281291301311321331342 unmodified lines1371381391401411421431441451461471482 unmodified lines1511521531541551561571581591601611622 unmodified lines16516616716816917017117210 unmodified lines - '.gitignore' - 'LICENSE'
jobs: coverage: name: 'Coverage' runs-on: ubuntu-latest needs: # bun excluded because it uses built-in test tool which does not support coverage in v8/istanbul format. # refer https://github.com/oven-sh/bun/issues/4015 - main - fastly - node - wrangler - lambda - lambda-edge steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: pattern: coverage-* merge-multiple: true path: ./coverage - uses: codecov/codecov-action@v4 with: fail_ci_if_error: true directory: ./coverage token: ${{ secrets.CODECOV_TOKEN }}
main: name: 'Main' runs-on: ubuntu-latest steps:8 unmodified lines - run: bun run format - run: bun run lint - run: bun run build - run: bun run test - uses: actions/upload-artifact@v4 with: name: coverage-main path: coverage/
jsr-dry-run: name: "Checking if it's valid for JSR" runs-on: ubuntu-latest11 unmodified lines - uses: actions/checkout@v4 - uses: denoland/setup-deno@v1 with: deno-version: v1.x - run: env NAME=Deno deno test --allow-read --allow-env --allow-write -c runtime_tests/deno/deno.json runtime_tests/deno - run: deno test -c runtime_tests/deno-jsx/deno.precompile.json runtime_tests/deno-jsx - run: deno test -c runtime_tests/deno-jsx/deno.react-jsx.json runtime_tests/deno-jsx - run: env NAME=Deno deno test --coverage=coverage/raw/deno-runtime --allow-read --allow-env --allow-write -c runtime_tests/deno/deno.json runtime_tests/deno - run: deno test -c runtime_tests/deno-jsx/deno.precompile.json --coverage=coverage/raw/deno-precompile-jsx runtime_tests/deno-jsx - run: deno test -c runtime_tests/deno-jsx/deno.react-jsx.json --coverage=coverage/raw/deno-react-jsx runtime_tests/deno-jsx - uses: actions/upload-artifact@v4 with: name: coverage-deno path: coverage/
bun: name: 'Bun' runs-on: ubuntu-latest12 unmodified lines - uses: oven-sh/setup-bun@v1 - run: bun install - run: bun run build - run: bun run test:fastly - uses: actions/upload-artifact@v4 with: name: coverage-fastly path: coverage/
node: name: 'Node.js v${{ matrix.node }}' runs-on: ubuntu-latest8 unmodified lines - uses: oven-sh/setup-bun@v1 - run: bun install - run: bun run build - run: bun run test:node - uses: actions/upload-artifact@v4 if: matrix.node == '22.x' with: name: coverage-node path: coverage/
wrangler: name: 'Cloudflare Workers' runs-on: ubuntu-latest2 unmodified lines - uses: oven-sh/setup-bun@v1 - run: bun install - run: bun run build - run: bun run test:wrangler - uses: actions/upload-artifact@v4 with: name: coverage-wrangler path: coverage/
lambda: name: 'AWS Lambda' runs-on: ubuntu-latest2 unmodified lines - uses: oven-sh/setup-bun@v1 - run: bun install - run: bun run build - run: bun run test:lambda - uses: actions/upload-artifact@v4 with: name: coverage-lambda path: coverage/
lambda-edge: name: 'Lambda@Edge' runs-on: ubuntu-latest2 unmodified lines - uses: oven-sh/setup-bun@v1 - run: bun install --frozen-lockfile - run: bun run build - run: bun run test:lambda-edge - uses: actions/upload-artifact@v4 with: name: coverage-lambda-edge path: coverage/modified:.vitest.config/jsx-runtime-default.ts+3 added
6 unmodified lines7891011121314156 unmodified lines config.test.include = [ '**/src/jsx/dom/**/(*.)+(spec|test).+(ts|tsx|js)', 'src/jsx/hooks/dom.test.tsx', ] if (config.test.coverage) { config.test.coverage.reportsDirectory = './coverage/raw/jsx-runtime' }}export default configmodified:.vitest.config/jsx-runtime-dom.ts+3 added
6 unmodified lines7891011121314156 unmodified lines config.test.include = [ '**/src/jsx/dom/**/(*.)+(spec|test).+(ts|tsx|js)', 'src/jsx/hooks/dom.test.tsx', ] if (config.test.coverage) { config.test.coverage.reportsDirectory = './coverage/raw/jsx-dom' }}export default configmodified:runtime_tests/bun/vitest.config.ts+5 added
1234567891011121314/// <reference types="vitest" />import { defineConfig } from 'vitest/config'import config from '../../vitest.config'
export default defineConfig({ test: { globals: true, include: ['**/runtime_tests/bun/**/*.+(ts|tsx|js)'], coverage: { ...config.test?.coverage, reportsDirectory: './coverage/raw/runtime-bun', }, },})modified:runtime_tests/fastly/vitest.config.ts+5 added
1 /// <reference types="vitest" />2 import fastlyCompute from 'vite-plugin-fastly-js-compute'3 import { defineConfig } from 'vitest/config'4+import config from '../../vitest.config'5 6 export default defineConfig({7 plugins: [fastlyCompute()],8 test: {9 globals: true,10 include: ['**/runtime_tests/fastly/**/(*.)+(test).+(ts|tsx)'],11 exclude: ['**/runtime_tests/fastly/vitest.config.ts'],12+ coverage: {13+ ...config.test?.coverage,14+ reportsDirectory: './coverage/raw/runtime-fastly',15+ },16 },17 })modified:runtime_tests/lambda/vitest.config.ts+5 added
1 /// <reference types="vitest" />2 import { defineConfig } from 'vitest/config'3+import config from '../../vitest.config'4 5 export default defineConfig({6 test: {7 env: {1 unmodified line9 },10 globals: true,11 include: ['**/runtime_tests/lambda/**/*.+(ts|tsx|js)'],12 exclude: ['**/runtime_tests/lambda/vitest.config.ts', '**/runtime_tests/lambda/mock.ts'],13+ coverage: {14+ ...config.test?.coverage,15+ reportsDirectory: './coverage/raw/runtime-lambda',16+ },17 },18 })modified:runtime_tests/lambda-edge/vitest.config.ts+5 added
1 /// <reference types="vitest" />2 import { defineConfig } from 'vitest/config'3+import config from '../../vitest.config'4 5 export default defineConfig({6 test: {7 env: {1 unmodified line9 },10 globals: true,11 include: ['**/runtime_tests/lambda-edge/**/*.+(ts|tsx|js)'],12 exclude: ['**/runtime_tests/lambda-edge/vitest.config.ts'],13+ coverage: {14+ ...config.test?.coverage,15+ reportsDirectory: './coverage/raw/runtime-lambda-edge',16+ },17 },18 })modified:runtime_tests/node/vitest.config.ts+5 added
1 /// <reference types="vitest" />2 import { defineConfig } from 'vitest/config'3+import config from '../../vitest.config'4 5 export default defineConfig({6 test: {7 env: {1 unmodified line9 },10 globals: true,11 include: ['**/runtime_tests/node/**/*.+(ts|tsx|js)'],12 exclude: ['**/runtime_tests/node/vitest.config.ts'],13+ coverage: {14+ ...config.test?.coverage,15+ reportsDirectory: './coverage/raw/runtime-node',16+ },17 },18 })modified:runtime_tests/wrangler/vitest.config.ts+5 added
1 /// <reference types="vitest" />2 import { defineConfig } from 'vitest/config'3+import config from '../../vitest.config'4 5 export default defineConfig({6 test: {7 globals: true,8 include: ['**/runtime_tests/wrangler/**/(*.)+(test).+(ts|tsx)'],9 exclude: ['**/runtime_tests/wrangler/vitest.config.ts'],10+ coverage: {11+ ...config.test?.coverage,12+ reportsDirectory: './coverage/raw/runtime-wrangler',13+ },14 },15 })added:codecov.yml+13 added
1+# Edit "test.coverage.exclude" option in vitest.config.ts to exclude specific files from coverage reports.2+# We can also use "ignore" option in codecov.yml, but it is not recognized by vitest, so results may differ on local.3+4+coverage:5+ status:6+ patch:7+ default:8+ target: 80%9+ informational: true # Don't fail the build even if coverage is below target10+ project:11+ default:12+ target: 75%13+ threshold: 1%modified:vitest.config.ts+11 added-1 removed
10 unmodified lines11 include: ['**/src/**/(*.)+(spec|test).+(ts|tsx|js)'],12 exclude: [...configDefaults.exclude, '**/sandbox/**', '**/*.case.test.+(ts|tsx|js)'],13 setupFiles: ['./src/test-utils/setup-vitest.ts'],14 coverage: {15+ enabled: true,16 provider: 'v8',17+ reportsDirectory: './coverage/raw/default',16- reporter: ['text'],18+ reporter: ['json'],19+ exclude: [20+ ...(configDefaults.coverage.exclude ?? []),21+ 'benchmarks',22+ 'runtime_tests',23+ 'build.ts',24+ 'src/test-utils',25+ 'src/**/types.ts', // types are compile-time only, so their coverage cannot be measured26+ ]27 },28 pool: 'forks',29 },30 })