Skip to content

Commit 1f30bf1

Browse files
committed
WIP
1 parent 7eb6084 commit 1f30bf1

File tree

3 files changed

+67
-16
lines changed

3 files changed

+67
-16
lines changed

.github/workflows/pythonapp.yml

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
name: Test
2-
31
on:
42
push:
53
branches:
@@ -9,8 +7,9 @@ on:
97
- cron: '0 8 * * *'
108

119
jobs:
10+
1211
test:
13-
name: 'Python ${{ matrix.python-version }} Django ${{ matrix.django-version }}'
12+
name: 'Test: Python ${{ matrix.python-version }} Django ${{ matrix.django-version }}'
1413
runs-on: ubuntu-latest
1514
strategy:
1615
fail-fast: false
@@ -20,6 +19,7 @@ jobs:
2019
env:
2120
PYTHONUNBUFFERED: 1
2221
PYTHONWARNINGS: always
22+
COVERAGE_FILE: coverage # note: not .coverage: https://github.com/actions/upload-artifact/issues/447
2323
steps:
2424
- name: Checkout
2525
run: |
@@ -54,8 +54,59 @@ jobs:
5454
- name: 'Install Browsers for Playwright tests'
5555
run: make playwright-install
5656

57-
- name: 'Run tests with Python ${{ matrix.python-version }} Django ${{ matrix.django-version }}'
57+
- name: 'Run tests with Python ${{ matrix.python-version }} + Django ${{ matrix.django-version }}'
5858
run: poetry run tox -e $(echo py${{ matrix.python-version }}-django${{ matrix.django-version }} | tr -d .)
5959

60-
- name: 'Upload coverage report'
61-
run: bash <(curl -s https://codecov.io/bash)
60+
- name: Store partial coverage data
61+
uses: actions/upload-artifact@v3
62+
with:
63+
name: coverage-data
64+
path: "coverage.*" # note: not .coverage: https://github.com/actions/upload-artifact/issues/447
65+
if-no-files-found: error
66+
# crash if no files for upload could be found.
67+
# the most likely reasons for that are an error with the coverage tool itself
68+
# or a disparity between configured tox envs and the action's matrix.
69+
70+
coverage:
71+
name: Coverage report
72+
runs-on: ubuntu-latest
73+
needs: test
74+
env:
75+
COVERAGE_FILE: coverage # note: not .coverage: https://github.com/actions/upload-artifact/issues/447
76+
steps:
77+
- name: Checkout
78+
uses: actions/checkout@v4
79+
80+
- name: Setup Python
81+
uses: actions/setup-python@v4
82+
with:
83+
python-version: "3.11"
84+
85+
- name: Install coverage
86+
run: python -m pip install --upgrade coverage[toml]
87+
88+
- name: Download partial coverage data
89+
uses: actions/download-artifact@v3
90+
91+
- name: Combine individual data files
92+
run: python -m coverage combine coverage-data/
93+
94+
- name: Print report
95+
run: python -m coverage report
96+
97+
- name: Generate HTML report
98+
run: python -m coverage html
99+
100+
- name: Upload HTML report artifact
101+
uses: actions/upload-artifact@v3
102+
with:
103+
name: coverage-html-report
104+
path: "htmlcov/*"
105+
if-no-files-found: error
106+
107+
- name: Upload report to Codecov
108+
uses: codecov/codecov-action@v3
109+
env:
110+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
111+
with:
112+
fail_ci_if_error: true

Makefile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ update: check-poetry ## Update the dependencies as according to the pyproject.to
3333
poetry update -v
3434
poetry install
3535

36+
clear-partial-coverage:
37+
rm -f .coverage.*
38+
3639
lint: ## Run code formatters and linter
3740
poetry run darker --diff --check
3841
poetry run isort --check-only .
@@ -45,18 +48,18 @@ fix-code-style: ## Fix code formatting
4548
tox-listenvs: check-poetry ## List all tox test environments
4649
poetry run tox --listenvs
4750

48-
tox: check-poetry ## Run unittests via tox with all environments
49-
poetry run tox
50-
poetry run coverage combine --append
51+
tox: check-poetry clear-partial-coverage ## Run unittests via tox with all environments
52+
poetry run tox p
53+
poetry run coverage combine
5154
poetry run coverage html
5255
poetry run coverage report
5356

5457
test: check-poetry ## Run unittests
5558
RAISE_LOG_OUTPUT=1 ./manage.sh test --parallel --shuffle --buffer
5659

57-
coverage_test: ## Run tests and generate coverage html report
58-
poetry run coverage run --rcfile=pyproject.toml manage.py test --parallel --shuffle
59-
poetry run coverage combine --append
60+
coverage_test: clear-partial-coverage ## Run tests and generate coverage html report
61+
poetry run coverage run --parallel-mode manage.py test --parallel --shuffle
62+
poetry run coverage combine
6063
poetry run coverage html
6164
poetry run coverage report
6265

pyproject.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,7 @@ deps =
140140
commands_pre =
141141
{envpython} -m playwright install chromium firefox
142142
commands =
143-
{envpython} -m coverage run --context='{envname}'
144-
{envpython} -m coverage combine --append
145-
{envpython} -m coverage xml
146-
{envpython} -m coverage report
143+
{envpython} -m coverage run --parallel-mode --context='{envname}'
147144
"""
148145

149146

0 commit comments

Comments
 (0)