Skip to content

Commit

Permalink
ci: combine multiple coverage reports
Browse files Browse the repository at this point in the history
  • Loading branch information
kmontag committed Jul 26, 2024
1 parent 4c589f0 commit ec4e89b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
34 changes: 30 additions & 4 deletions .github/workflows/test_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

jobs:
validate:
name: "tests & coverage"
name: lint and test
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -28,15 +28,41 @@ jobs:
- run: hatch test --cover
- run: hatch run types:check

# Adapted from
# https://github.com/pypa/hatch/blob/master/.github/workflows/test.yml
- run: mv .coverage ".coverage.${{ matrix.os }}.${{ matrix.python-version }}"
- uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
path: .coverage*

coverage:
name: report coverage
runs-on: ubuntu-latest
# Make sure coverage reports have been generated.
needs:
- validate
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.12
- run: python -m pip install hatch

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

- run: hatch run coverage:combine
- run: hatch run coverage:report-xml
- uses: codecov/codecov-action@v4
# We don't need to upload coverage more than once.
if: matrix.python-version == '3.12'
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

release:
name: "publish to GitHub and PyPi"
name: publish to GitHub and PyPi
runs-on: ubuntu-latest
concurrency: release
environment:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ __pycache__/
/.mypy_cache/
/.ruff_cache/

/.coverage
# Code coverage reports.
/.coverage*
/coverage.xml

/dist/
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ path = "src/alpax/__about__.py"
# "pytest-asyncio~=0.23.7",
# ]

[tool.hatch.envs.coverage]
detached = true
dependencies = [
"coverage~=7.6.0",
]

[tool.hatch.envs.coverage.scripts]
combine = "coverage combine {args}"
report-xml = "coverage xml"

[tool.hatch.envs.types]
extra-dependencies = [
"mypy>=1.0.0",
Expand Down

0 comments on commit ec4e89b

Please sign in to comment.