Skip to content

Commit 0ec4425

Browse files
authored
Determine tox versions on our own (#1098)
1 parent cabc062 commit 0ec4425

2 files changed

Lines changed: 50 additions & 28 deletions

File tree

.github/workflows/ci.yml

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ permissions:
2323

2424
jobs:
2525
tests:
26-
name: tox on ${{ matrix.python-version }}
26+
name: tests on ${{ matrix.python-version }}
2727
runs-on: ubuntu-latest
2828

2929
strategy:
@@ -58,13 +58,24 @@ jobs:
5858
with:
5959
python-version: ${{ matrix.python-version }}
6060

61-
- name: Install dependencies
61+
- name: Determine Python version for tox
6262
run: |
63-
python -VV
64-
python -m site
65-
python -m pip install --upgrade wheel tox tox-gh-actions
63+
V=${{ matrix.python-version }}
64+
if [[ "$V" = ~* ]]; then
65+
# Extract version from a '~3.XX.0-0' specifier.
66+
V=${V:1:4}
67+
fi
6668
67-
- run: python -m tox
69+
if [[ "$V" = pypy-* ]]; then
70+
V=pypy3
71+
else
72+
V=py$(echo $V | tr -d .)
73+
fi
74+
75+
echo TOX_PYTHON=$V >>$GITHUB_ENV
76+
77+
- run: python -Im pip install --upgrade wheel tox
78+
- run: python -Im tox run -f ${{ env.TOX_PYTHON }}
6879

6980
- name: Upload coverage data
7081
uses: actions/upload-artifact@v3
@@ -94,7 +105,7 @@ jobs:
94105
# Use latest Python, so it understands all syntax.
95106
python-version: ${{env.PYTHON_LATEST}}
96107

97-
- run: python -m pip install --upgrade coverage[toml]
108+
- run: python -Im pip install --upgrade coverage[toml]
98109

99110
- name: Download coverage data
100111
uses: actions/download-artifact@v3
@@ -103,9 +114,9 @@ jobs:
103114

104115
- name: Combine coverage and fail if it's <100%.
105116
run: |
106-
python -m coverage combine
107-
python -m coverage html --skip-covered --skip-empty
108-
python -m coverage report --fail-under=100
117+
python -Im coverage combine
118+
python -Im coverage html --skip-covered --skip-empty
119+
python -Im coverage report --fail-under=100
109120
110121
- name: Upload HTML report if check failed.
111122
uses: actions/upload-artifact@v3
@@ -134,8 +145,30 @@ jobs:
134145
# Keep in sync with tox/docs and .readthedocs.yaml.
135146
python-version: "3.10"
136147

137-
- run: python -m pip install --upgrade wheel tox
138-
- run: python -m tox -e docs,changelog
148+
- run: python -Im pip install --upgrade wheel tox
149+
- run: python -Im tox -e docs,changelog
150+
151+
mypy:
152+
name: mypy on ${{ matrix.python-version }}
153+
runs-on: ubuntu-latest
154+
strategy:
155+
fail-fast: false
156+
matrix:
157+
python-version:
158+
- "3.7"
159+
- "3.8"
160+
- "3.9"
161+
- "3.10"
162+
- "3.11"
163+
164+
steps:
165+
- uses: actions/checkout@v3
166+
- uses: actions/setup-python@v4
167+
with:
168+
python-version: ${{ matrix.python-version }}
169+
170+
- run: python -Im pip install --upgrade wheel tox
171+
- run: python -Im tox run -e mypy
139172

140173
pyright:
141174
name: Check types using pyright
@@ -158,8 +191,8 @@ jobs:
158191
with:
159192
python-version: ${{env.PYTHON_LATEST}}
160193

161-
- run: python -m pip install --upgrade wheel tox
162-
- run: python -m tox -e pyright
194+
- run: python -Im pip install --upgrade wheel tox
195+
- run: python -Im tox run -e pyright
163196

164197
install-dev:
165198
name: Verify dev env
@@ -183,8 +216,8 @@ jobs:
183216
- uses: actions/setup-python@v4
184217
with:
185218
python-version: ${{env.PYTHON_LATEST}}
186-
- run: python -m pip install -e .[dev]
187-
- run: python -c 'import attr; print(attr.__version__)'
219+
- run: python -Im pip install -e .[dev]
220+
- run: python -Ic 'import attr; print(attr.__version__)'
188221

189222
# Ensure everything required is passing for branch protection.
190223
required-checks-pass:
@@ -194,6 +227,7 @@ jobs:
194227
- coverage
195228
- docs
196229
- install-dev
230+
- mypy
197231
- pyright
198232

199233
runs-on: ubuntu-latest

tox.ini

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
# Keep docs in sync with docs env and .readthedocs.yml.
2-
[gh-actions]
3-
python =
4-
3.7: py37
5-
3.8: py38
6-
3.9: py39
7-
3.10: py310, mypy
8-
3.11: py311
9-
3.12: py312
10-
pypy-3: pypy3
11-
12-
131
[tox]
142
envlist = mypy,pre-commit,py37,py38,py39,py310,py311,py312,pypy3,pyright,docs,changelog,coverage-report
153
isolated_build = True

0 commit comments

Comments
 (0)