Skip to content

Commit 53f7f02

Browse files
authored
🤖 Add Codecov integration to CI (#351)
## Overview Integrates Codecov into the CI pipeline to automatically track code coverage on every PR and commit. ## Changes - **Unit Tests job**: Added coverage generation with `bun test --coverage` and upload to Codecov with `unit-tests` flag - **Integration Tests job**: Added coverage generation with `jest --coverage` and upload to Codecov with `integration-tests` flag - Renamed "Test" job to "Unit Tests" for clarity - Set `fail_ci_if_error: false` on uploads to avoid blocking PRs if Codecov has issues ## How It Works Codecov automatically merges the two coverage reports into a unified view: - See overall coverage across both test types - See per-flag coverage (unit vs integration) to understand which tests cover which code - Coverage reports appear as PR comments - Historical trends tracked over time ## Setup Required The `CODECOV_TOKEN` secret has already been configured in GitHub Actions settings. _Generated with `cmux`_
1 parent dfe0b25 commit 53f7f02

File tree

2 files changed

+66
-5
lines changed

2 files changed

+66
-5
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
run: make -j3 static-check
5757

5858
test:
59-
name: Test
59+
name: Unit Tests
6060
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}
6161
steps:
6262
- name: Checkout code
@@ -66,8 +66,16 @@ jobs:
6666

6767
- uses: ./.github/actions/setup-cmux
6868

69-
- name: Run tests
70-
run: make test-unit
69+
- name: Run tests with coverage
70+
run: bun test --coverage --coverage-reporter=lcov src
71+
72+
- name: Upload coverage to Codecov
73+
uses: codecov/codecov-action@v5
74+
with:
75+
token: ${{ secrets.CODECOV_TOKEN }}
76+
files: ./coverage/lcov.info
77+
flags: unit-tests
78+
fail_ci_if_error: false
7179

7280
integration-test:
7381
name: Integration Tests
@@ -80,12 +88,20 @@ jobs:
8088

8189
- uses: ./.github/actions/setup-cmux
8290

83-
- name: Run integration tests
84-
run: make test-integration
91+
- name: Run integration tests with coverage
92+
run: TEST_INTEGRATION=1 bun x jest --coverage tests
8593
env:
8694
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
8795
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
8896

97+
- name: Upload coverage to Codecov
98+
uses: codecov/codecov-action@v5
99+
with:
100+
token: ${{ secrets.CODECOV_TOKEN }}
101+
files: ./coverage/lcov.info
102+
flags: integration-tests
103+
fail_ci_if_error: false
104+
89105
storybook-test:
90106
name: Storybook Interaction Tests
91107
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }}

codecov.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Codecov Configuration
2+
# https://docs.codecov.com/docs/codecovyml-reference
3+
4+
# Disable PR comments - just show status checks
5+
comment: false
6+
7+
coverage:
8+
# Coverage precision (decimal places)
9+
precision: 2
10+
round: down
11+
range: 70..100
12+
13+
status:
14+
# Project coverage status - informational only
15+
project:
16+
default:
17+
target: auto # Compare to base commit
18+
threshold: 5% # Allow 5% drop without changing status
19+
informational: true # Won't block PRs
20+
21+
# Patch coverage status - informational only
22+
patch:
23+
default:
24+
target: auto # Compare to base commit
25+
threshold: 5% # Allow 5% drop without changing status
26+
informational: true # Won't block PRs
27+
28+
# Flag configuration to track unit vs integration test coverage
29+
flags:
30+
unit-tests:
31+
paths:
32+
- src/**
33+
carryforward: false
34+
integration-tests:
35+
paths:
36+
- tests/**
37+
carryforward: false
38+
39+
# Ignore common non-source paths
40+
ignore:
41+
- "**/*.test.ts"
42+
- "**/*.test.tsx"
43+
- "**/dist/**"
44+
- "**/node_modules/**"
45+
- "**/coverage/**"

0 commit comments

Comments
 (0)