Skip to content

Commit f3704f2

Browse files
committed
coverage: add new job to run after build
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
1 parent 95272c2 commit f3704f2

File tree

1 file changed

+46
-11
lines changed

1 file changed

+46
-11
lines changed

.github/workflows/tests.yml

+46-11
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ jobs:
2929
- ["3.10", "py310"]
3030
- ["3.11.0-rc.2", "py311"]
3131
- ["3.9", "docs"]
32-
- ["3.9", "coverage"]
3332
- ["3.9", "py39-datetime"]
3433
exclude:
3534
- { os: windows, config: ["3.9", "lint"] }
3635
- { os: windows, config: ["3.9", "docs"] }
37-
- { os: windows, config: ["3.9", "coverage"] }
3836

3937
runs-on: ${{ matrix.os }}-latest
4038
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
@@ -58,13 +56,50 @@ jobs:
5856
python -m pip install --upgrade pip
5957
pip install tox
6058
- name: Test
61-
if: matrix.config[1] != 'coverage'
6259
run: tox -e ${{ matrix.config[1] }}
63-
- name: Coverage
64-
if: matrix.config[1] == 'coverage'
65-
run: |
66-
tox -e py36,py37,py38,py39,py39-datetime,py310,py311,coverage
67-
pip install coveralls
68-
coveralls --service=github
69-
env:
70-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
61+
- name: Upload coverage artifact
62+
uses: actions/upload-artifact@v2
63+
if: matrix.os != 'windows'
64+
with:
65+
name: coverage-data
66+
path: .coverage.${{ matrix.config[1] }}
67+
if-no-files-found: ignore
68+
69+
coverage:
70+
name: Combined coverage
71+
runs-on: ubuntu-latest
72+
needs: build
73+
steps:
74+
- uses: actions/checkout@v2
75+
- uses: actions/setup-python@v2
76+
with:
77+
# Use latest, so it understands all syntax.
78+
python-version: "3.10"
79+
- run: python -m pip install --upgrade coveralls coverage[toml]
80+
81+
- name: Download coverage data.
82+
uses: actions/download-artifact@v2
83+
with:
84+
name: coverage-data
85+
86+
- name: Indicate completion to coveralls.io
87+
run: |
88+
python -m coverage combine
89+
coveralls --service=github
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
93+
- name: Coverage report and fail if it's <100%.
94+
env:
95+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96+
run: |
97+
python -m coverage html --skip-covered --skip-empty
98+
python -m coverage report --fail-under=100
99+
100+
- name: Upload HTML report if check failed.
101+
uses: actions/upload-artifact@v2
102+
with:
103+
name: html-report
104+
path: htmlcov
105+
if: ${{ failure() }}

0 commit comments

Comments
 (0)