Skip to content

Commit

Permalink
coverage: add new job to run after build
Browse files Browse the repository at this point in the history
Build job:
- add upload artifact step after each test in the matrix.
- update coveralls step to upload partial data.

Converage job (new):
- complete the coveralls in the coverage job.
- add step to download all uploaded artifacts
- add step to combine coverage data, create report and fail if not
  enough
- add step to upload html report if coverage is not enough
  • Loading branch information
rudaporto committed Oct 17, 2022
1 parent 95272c2 commit f3704f2
Showing 1 changed file with 46 additions and 11 deletions.
57 changes: 46 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ jobs:
- ["3.10", "py310"]
- ["3.11.0-rc.2", "py311"]
- ["3.9", "docs"]
- ["3.9", "coverage"]
- ["3.9", "py39-datetime"]
exclude:
- { os: windows, config: ["3.9", "lint"] }
- { os: windows, config: ["3.9", "docs"] }
- { os: windows, config: ["3.9", "coverage"] }

runs-on: ${{ matrix.os }}-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
Expand All @@ -58,13 +56,50 @@ jobs:
python -m pip install --upgrade pip
pip install tox
- name: Test
if: matrix.config[1] != 'coverage'
run: tox -e ${{ matrix.config[1] }}
- name: Coverage
if: matrix.config[1] == 'coverage'
run: |
tox -e py36,py37,py38,py39,py39-datetime,py310,py311,coverage
pip install coveralls
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload coverage artifact
uses: actions/upload-artifact@v2
if: matrix.os != 'windows'
with:
name: coverage-data
path: .coverage.${{ matrix.config[1] }}
if-no-files-found: ignore

coverage:
name: Combined coverage
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
# Use latest, so it understands all syntax.
python-version: "3.10"
- run: python -m pip install --upgrade coveralls coverage[toml]

- name: Download coverage data.
uses: actions/download-artifact@v2
with:
name: coverage-data

- name: Indicate completion to coveralls.io
run: |
python -m coverage combine
coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Coverage report and fail if it's <100%.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python -m coverage html --skip-covered --skip-empty
python -m coverage report --fail-under=100
- name: Upload HTML report if check failed.
uses: actions/upload-artifact@v2
with:
name: html-report
path: htmlcov
if: ${{ failure() }}

0 comments on commit f3704f2

Please sign in to comment.