Skip to content

Commit 97d4c8e

Browse files
committed
Wire up pytest invocations via tox
1 parent 1ecbd74 commit 97d4c8e

File tree

3 files changed

+105
-20
lines changed

3 files changed

+105
-20
lines changed

.github/workflows/test-library.yml

Lines changed: 99 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ name: Proxy.py Library
33
on: [push, pull_request]
44

55
jobs:
6-
build:
6+
integration:
77
runs-on: ${{ matrix.os }}-latest
88
name: Library - Python ${{ matrix.python }} on ${{ matrix.os }}
99
strategy:
1010
matrix:
11-
os: [macOS, ubuntu, windows]
11+
os: [macOS, Ubuntu]
1212
python: ['3.6', '3.7', '3.8', '3.9', '3.10']
1313
max-parallel: 4
1414
fail-fast: false
@@ -18,26 +18,14 @@ jobs:
1818
uses: actions/setup-python@v2
1919
with:
2020
python-version: ${{ matrix.python }}
21-
- name: Install dependencies
22-
run: |
23-
python -m pip install --upgrade pip
24-
pip install -r requirements.txt
25-
pip install -r requirements-testing.txt
26-
pip install -r requirements-tunnel.txt
27-
- name: Run Tests
28-
run: pytest --cov=proxy tests/
29-
- name: Upload coverage to Codecov
30-
env:
31-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
32-
run: codecov
3321
- name: Integration testing
34-
if: matrix.os != 'windows'
3522
run: |
23+
pip install -U pip
3624
pip install .
3725
proxy --hostname 127.0.0.1 --enable-web-server --pid-file proxy.pid --log-file proxy.log &
3826
./tests/integration/main.sh
3927
40-
tox:
28+
lint:
4129
name: ${{ matrix.toxenv }}
4230

4331
runs-on: Ubuntu-latest
@@ -114,10 +102,103 @@ jobs:
114102
--parallel-live
115103
--skip-missing-interpreters false
116104
105+
test:
106+
name: 🐍${{ matrix.python }} @ ${{ matrix.os }}
107+
108+
runs-on: ${{ matrix.os }}-latest
109+
strategy:
110+
fail-fast: false
111+
matrix:
112+
os:
113+
- macOS
114+
- Ubuntu
115+
- Windows
116+
python:
117+
# NOTE: The latest and the lowest supported Pythons are prioritized
118+
# NOTE: to improve the responsiveness. It's nice to see the most
119+
# NOTE: important results first.
120+
- '3.10'
121+
- 3.6
122+
- 3.9
123+
- 3.8
124+
- 3.7
125+
max-parallel: 4
126+
127+
env:
128+
PY_COLORS: 1
129+
TOX_PARALLEL_NO_SPINNER: 1
130+
TOXENV: python
131+
132+
steps:
133+
- name: Switch to using Python v${{ matrix.python }}
134+
uses: actions/setup-python@v2
135+
with:
136+
python-version: ${{ matrix.python }}
137+
- name: >-
138+
Calculate Python interpreter version hash value
139+
for use in the cache key
140+
id: calc-cache-key-py
141+
run: |
142+
from hashlib import sha512
143+
from sys import version
144+
145+
hash = sha512(version.encode()).hexdigest()
146+
print(f'::set-output name=py-hash-key::{hash}')
147+
shell: python
148+
- name: Get pip cache dir
149+
id: pip-cache
150+
run: >-
151+
echo "::set-output name=dir::$(pip cache dir)"
152+
- name: Set up pip cache
153+
uses: actions/[email protected]
154+
with:
155+
path: ${{ steps.pip-cache.outputs.dir }}
156+
key: >-
157+
${{ runner.os }}-pip-${{
158+
steps.calc-cache-key-py.outputs.py-hash-key }}-${{
159+
hashFiles('tox.ini', 'requirements.txt', 'requirements-testing.txt')
160+
}}
161+
restore-keys: |
162+
${{ runner.os }}-pip-${{
163+
steps.calc-cache-key-py.outputs.py-hash-key
164+
}}-
165+
${{ runner.os }}-pip-
166+
- name: Install tox
167+
run: >-
168+
python -m
169+
pip install
170+
--user
171+
tox
172+
173+
- name: Grab the source from Git
174+
uses: actions/checkout@v2
175+
176+
- name: Pre-populate the testing env
177+
run: >-
178+
python -m
179+
tox
180+
--parallel auto
181+
--parallel-live
182+
--skip-missing-interpreters false
183+
--notest
184+
- name: Run the testing
185+
run: >-
186+
python -m
187+
tox
188+
--parallel auto
189+
--parallel-live
190+
--skip-missing-interpreters false
191+
- name: Upload coverage to Codecov
192+
uses: codecov/codecov-action@v2
193+
with:
194+
flags: pytest, GHA, Python ${{ matrix.python }}, ${{ runner.os }}
195+
verbose: true
196+
117197
check: # This job does nothing and is only used for the branch protection
118198
needs:
119-
- build
120-
- tox
199+
- integration
200+
- lint
201+
- test
121202

122203
runs-on: ubuntu-latest
123204

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ lib-lint:
9292
python -m tox -e lint
9393

9494
lib-test: lib-clean lib-version lib-lint
95-
pytest -v tests/
95+
python -m tox -e python -- -v
9696

9797
lib-package: lib-clean lib-version
9898
python -m tox -e cleanup-dists,build-dists,metadata-validation

tox.ini

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ minversion = 3.21.0
77
deps =
88
-rrequirements.txt
99
-rrequirements-testing.txt
10-
commands = pytest
10+
# NOTE: The command is invoked by the script name and not via
11+
# NOTE: `{envpython} -m pytest` because it'd add CWD into $PYTHONPATH
12+
# NOTE: testing the project from the Git checkout
13+
# NOTE: rather than one installed.
14+
commands = pytest --cov=proxy tests/ {posargs:}
1115

1216

1317
[dists]

0 commit comments

Comments
 (0)