Skip to content

Commit 79ccb43

Browse files
committed
WIP
1 parent 7eb6084 commit 79ccb43

File tree

3 files changed

+67
-14
lines changed

3 files changed

+67
-14
lines changed

.github/workflows/pythonapp.yml

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ on:
99
- cron: '0 8 * * *'
1010

1111
jobs:
12+
1213
test:
13-
name: 'Python ${{ matrix.python-version }} Django ${{ matrix.django-version }}'
14+
name: 'Test: Python ${{ matrix.python-version }} Django ${{ matrix.django-version }}'
1415
runs-on: ubuntu-latest
1516
strategy:
1617
fail-fast: false
@@ -20,6 +21,7 @@ jobs:
2021
env:
2122
PYTHONUNBUFFERED: 1
2223
PYTHONWARNINGS: always
24+
COVERAGE_FILE: coverage # note: not .coverage: https://github.com/actions/upload-artifact/issues/447
2325
steps:
2426
- name: Checkout
2527
run: |
@@ -54,8 +56,59 @@ jobs:
5456
- name: 'Install Browsers for Playwright tests'
5557
run: make playwright-install
5658

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

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