Skip to content

Commit 14b66be

Browse files
committed
Update tox and github actions
- Convert .coverage file into a folder for parallel mode. You may will need to delete the file if it exists before running tox tests. - Enable parallel coverage mode. - Test python versions 3.7 - 3.11 - Work around the removal of 3.7 from Ubuntu in github actions - Attach coverage data to the github action report
1 parent 8514a07 commit 14b66be

File tree

3 files changed

+127
-10
lines changed

3 files changed

+127
-10
lines changed

.coveragerc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ skip_empty = true
99
source = preditor
1010
omit =
1111
*/site-packages/*
12+
tests/*
13+
# This file is automatically generated by setuptools_scm
14+
preditor/version.py
15+
parallel=True
1216
relative_files=True
17+
data_file=.coverage/.coverage

.github/workflows/static-analysis-and-test.yml

Lines changed: 102 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ jobs:
3535
strategy:
3636
matrix:
3737
os: ['ubuntu-latest']
38-
python: [3.7, 3.8, 3.9]
39-
# Works around the depreciation of python 3.6 for ubuntu
38+
python: ['3.8', '3.9', '3.10', '3.11']
39+
# Works around the depreciation of python 3.6, 3.7 for ubuntu
4040
# https://github.com/actions/setup-python/issues/544
4141
include:
42-
- os: 'ubuntu-20.04'
43-
python: 3.6
42+
- os: 'ubuntu-22.04'
43+
python: '3.7'
4444

4545
runs-on: ${{ matrix.os }}
4646

@@ -60,4 +60,101 @@ jobs:
6060
6161
- name: Run Tox
6262
run: |
63-
tox -e py
63+
tox -e begin,py -- --tb short
64+
65+
- name: Upload coverage
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: coverage-${{ matrix.os }}-${{ matrix.python }}
69+
path: .coverage/*
70+
include-hidden-files: true
71+
retention-days: 1
72+
73+
74+
coverage:
75+
needs: test
76+
77+
runs-on: ubuntu-latest
78+
steps:
79+
- name: Checkout code
80+
uses: actions/checkout@v4
81+
82+
- name: Setup Python
83+
uses: actions/setup-python@v5
84+
with:
85+
python-version: "3.x"
86+
87+
- name: Install dependencies
88+
run: |
89+
python -m pip install --upgrade pip
90+
python -m pip install tox coverage[toml]
91+
92+
# Ensure version.py is created so coverage can read it's source
93+
- name: Run begin
94+
run: |
95+
tox -e begin
96+
97+
- name: Download coverage artifacts
98+
uses: actions/download-artifact@v4
99+
with:
100+
path: .coverage/
101+
pattern: coverage-*
102+
merge-multiple: true
103+
104+
# Tox runs `coverage combine` and `coverage xml`
105+
- name: Combine coverage and report
106+
run: |
107+
tox -e end
108+
109+
# Report and write to summary.
110+
python -m coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
111+
112+
# Write html coverage report to upload as an artifact
113+
python -m coverage html
114+
115+
# # Report again and fail if under 100%.
116+
# python -m coverage report --fail-under=100
117+
118+
- name: Upload HTML report if check failed.
119+
uses: actions/upload-artifact@v4
120+
with:
121+
name: html-report
122+
path: htmlcov
123+
# # TODO: If we get 100% coverage we can re-enable this and the
124+
# # `--fail-under` check so pull requests fail if the dev doesn't
125+
# # add tests for new code.
126+
# if: ${{ failure() }}
127+
128+
129+
pip-package:
130+
# Build and upload pip packages as artifacts so we can inspect them and
131+
# ensure they are correct for actual release
132+
runs-on: ubuntu-latest
133+
134+
steps:
135+
- name: Checkout code
136+
uses: actions/checkout@v4
137+
with:
138+
fetch-depth: 0
139+
140+
- name: Setup Python
141+
uses: actions/setup-python@v5
142+
with:
143+
python-version: "3.x"
144+
145+
- name: Install dependencies
146+
run: |
147+
python -m pip install --upgrade pip
148+
python -m pip install --upgrade build setuptools wheel twine
149+
150+
- name: Build wheel
151+
run: |
152+
python -m build --wheel --sdist
153+
154+
- name: Upload packages.
155+
uses: actions/upload-artifact@v4
156+
with:
157+
name: pip-packages
158+
path: |
159+
dist/preditor-*.whl
160+
dist/preditor-*.tar.gz

tox.ini

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = begin,py{27,36,37,38,39},modernize,black,flake8
2+
envlist = modernize,begin,py{27,36,37,38,39,310,311},end,black,flake8
33
skip_missing_interpreters = True
44
skipsdist = True
55

@@ -23,8 +23,7 @@ commands =
2323
# Ensure the version.py file is created
2424
python setup.py egg_info
2525

26-
python -m coverage run -m pytest {posargs:tests/}
27-
python -m coverage report
26+
coverage run -m pytest {tty:--color=yes} {posargs:tests/}
2827

2928
[testenv:modernize]
3029
# Test compatibility with python 2 and 3
@@ -37,12 +36,28 @@ commands =
3736
# in this test.
3837
python -m modernize -f print -f import -f basestring -f unicode_type --enforce ./preditor
3938

40-
4139
[testenv:begin]
4240
basepython = python3
41+
deps =
42+
coverage[toml]
43+
build
44+
commands =
45+
coverage erase
46+
47+
[testenv:py{27,36,37,38,39,310,311}]
48+
depends = begin
49+
50+
[testenv:end]
51+
basepython = python3
52+
depends =
53+
begin
54+
py{27,36,37,38,39,310,311}
55+
parallel_show_output = True
4356
deps =
4457
coverage
45-
commands = coverage erase
58+
commands =
59+
coverage combine
60+
coverage report
4661

4762
[testenv:black]
4863
basepython = python3

0 commit comments

Comments
 (0)