Skip to content

Commit 70742fb

Browse files
committed
feat(coverage): Combine coverge from matrix runs
1 parent 99b64a9 commit 70742fb

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

.github/workflows/lint-and-test.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,51 @@ jobs:
6060
uses: actions/setup-python@v5
6161
with:
6262
python-version: ${{ matrix.python-version }}
63+
6364
- name: Install hatch
6465
uses: pypa/hatch@install
66+
6567
- name: Test
6668
run: hatch test --cover --python ${{ matrix.python-version }}
69+
70+
- name: Disambiguate coverage filename
71+
run: mv .coverage ".coverage.${{ matrix.os }}.${{ matrix.python-version }}"
72+
73+
- name: Upload coverage data
74+
uses: actions/upload-artifact@v4
75+
with:
76+
include-hidden-files: true
77+
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
78+
path: .coverage*
79+
80+
81+
coverage:
82+
runs-on: ubuntu-latest
83+
name: Report coverage
84+
needs:
85+
- run
86+
steps:
87+
- uses: actions/checkout@v4
88+
- name: Install Hatch
89+
uses: pypa/hatch@install
90+
91+
- name: Download coverage data
92+
uses: actions/download-artifact@v4
93+
with:
94+
pattern: coverage-*
95+
merge-multiple: true
96+
97+
- name: Combine coverage data
98+
run: hatch run coverage:combine
99+
100+
- name: Export coverage reports
101+
run: hatch run coverage:xml
102+
67103
- uses: codecov/codecov-action@v4
68104
with:
69105
token: ${{ secrets.CODECOV_TOKEN }}
70106

107+
71108
package:
72109
name: Build & verify package
73110
runs-on: ubuntu-latest

hatch.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ features = [
1616
"pydantic"
1717
]
1818

19+
[envs.coverage]
20+
detached = true
21+
dependencies = [
22+
"coverage[toml]>=6.2",
23+
"lxml",
24+
]
25+
26+
[envs.coverage.scripts]
27+
combine = "coverage combine {args}"
28+
xml = "coverage xml"
29+
1930
[envs.types]
2031
extra-dependencies = [
2132
"mypy==1.11.*",

0 commit comments

Comments
 (0)