Skip to content

Commit

Permalink
feat(coverage): Combine coverge from matrix runs
Browse files Browse the repository at this point in the history
  • Loading branch information
mdomke committed Oct 11, 2024
1 parent 99b64a9 commit 70742fb
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,51 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install hatch
uses: pypa/hatch@install

- name: Test
run: hatch test --cover --python ${{ matrix.python-version }}

- name: Disambiguate coverage filename
run: mv .coverage ".coverage.${{ matrix.os }}.${{ matrix.python-version }}"

- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
include-hidden-files: true
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
path: .coverage*


coverage:
runs-on: ubuntu-latest
name: Report coverage
needs:
- run
steps:
- uses: actions/checkout@v4
- name: Install Hatch
uses: pypa/hatch@install

- name: Download coverage data
uses: actions/download-artifact@v4
with:
pattern: coverage-*
merge-multiple: true

- name: Combine coverage data
run: hatch run coverage:combine

- name: Export coverage reports
run: hatch run coverage:xml

- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}


package:
name: Build & verify package
runs-on: ubuntu-latest
Expand Down
11 changes: 11 additions & 0 deletions hatch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ features = [
"pydantic"
]

[envs.coverage]
detached = true
dependencies = [
"coverage[toml]>=6.2",
"lxml",
]

[envs.coverage.scripts]
combine = "coverage combine {args}"
xml = "coverage xml"

[envs.types]
extra-dependencies = [
"mypy==1.11.*",
Expand Down

0 comments on commit 70742fb

Please sign in to comment.