Skip to content

Commit f3040e4

Browse files
authored
ci: run full test suite on main, critical-only on PRs (#25)
- PRs: Run tests/critical/ only (fast CI feedback, ~1-2 min) - Main push: Run tests/ full suite (accurate coverage, ~10 min) - Add codecov.yml with carryforward flags configuration - Use dynamic flags: full-python-X.Y vs critical-python-X.Y Coverage improves from ~52% (critical) to ~77% (full) on main.
1 parent d3e068b commit f3040e4

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

.github/workflows/ci.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ jobs:
166166
run: |
167167
uv sync --group dev
168168
169-
- name: Run critical tests with coverage
169+
- name: Run critical tests (PRs)
170+
if: github.event_name == 'pull_request'
170171
env:
171172
REDIS_URL: redis://localhost:6379
172173
run: |
@@ -177,14 +178,26 @@ jobs:
177178
--junitxml=junit.xml \
178179
-o junit_family=legacy
179180
181+
- name: Run full test suite (main)
182+
if: github.event_name == 'push'
183+
env:
184+
REDIS_URL: redis://localhost:6379
185+
run: |
186+
uv run pytest tests/ -m "not slow" \
187+
--cov=src/cachekit \
188+
--cov-report=xml \
189+
--cov-report=term \
190+
--junitxml=junit.xml \
191+
-o junit_family=legacy
192+
180193
- name: Upload coverage to Codecov
181194
if: ${{ !cancelled() }}
182195
uses: codecov/codecov-action@v5
183196
with:
184197
files: ./coverage.xml
185198
use_oidc: true
186199
fail_ci_if_error: false
187-
flags: python-${{ matrix.python-version }}
200+
flags: ${{ github.event_name == 'push' && 'full' || 'critical' }}-python-${{ matrix.python-version }}
188201

189202
- name: Upload test results to Codecov
190203
if: ${{ !cancelled() }}
@@ -193,7 +206,7 @@ jobs:
193206
files: ./junit.xml
194207
report_type: test_results
195208
use_oidc: true
196-
flags: python-${{ matrix.python-version }}
209+
flags: ${{ github.event_name == 'push' && 'full' || 'critical' }}-python-${{ matrix.python-version }}
197210
fail_ci_if_error: false
198211

199212
# Markdown documentation tests

codecov.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Codecov Configuration
2+
# https://docs.codecov.com/docs/codecovyml-reference
3+
4+
coverage:
5+
status:
6+
project:
7+
default:
8+
target: auto
9+
threshold: 2% # Allow 2% coverage drop without failing
10+
patch:
11+
default:
12+
target: 80% # New code should have 80% coverage
13+
14+
# Flag configuration for PR vs main coverage strategy
15+
flag_management:
16+
default_rules:
17+
carryforward: true # Carry forward coverage from previous uploads
18+
statuses:
19+
- type: project
20+
- type: patch
21+
22+
individual_flags:
23+
# Full test suite (main branch only)
24+
- name: full-python-3.12
25+
carryforward: true
26+
paths:
27+
- src/cachekit/
28+
29+
# Critical tests (PRs) - carryforward from full coverage
30+
- name: critical-python-3.12
31+
carryforward: true
32+
carryforward_mode: labels
33+
paths:
34+
- src/cachekit/
35+
36+
comment:
37+
layout: "header, diff, flags, components"
38+
behavior: default
39+
require_changes: true # Only comment if coverage changed

0 commit comments

Comments
 (0)