Migrate the pytest invocation to `tox` (#662)
* Fix the `commands` setting in the tox config * Wire up `pytest` invocations via tox
This commit is contained in:
parent
05a78567ac
commit
7c5877b74a
|
@ -13,12 +13,12 @@ concurrency:
|
|||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
integration:
|
||||
runs-on: ${{ matrix.os }}-latest
|
||||
name: Library - Python ${{ matrix.python }} on ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macOS, ubuntu, windows]
|
||||
os: [macOS, Ubuntu]
|
||||
python: ['3.6', '3.7', '3.8', '3.9', '3.10']
|
||||
max-parallel: 4
|
||||
fail-fast: false
|
||||
|
@ -28,21 +28,9 @@ jobs:
|
|||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
pip install -r requirements-testing.txt
|
||||
pip install -r requirements-tunnel.txt
|
||||
- name: Run Tests
|
||||
run: pytest --cov=proxy tests/
|
||||
- name: Upload coverage to Codecov
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
run: codecov
|
||||
- name: Integration testing
|
||||
if: matrix.os != 'windows'
|
||||
run: |
|
||||
pip install -U pip
|
||||
pip install .
|
||||
proxy \
|
||||
--hostname 127.0.0.1 \
|
||||
|
@ -52,7 +40,7 @@ jobs:
|
|||
&
|
||||
./tests/integration/main.sh
|
||||
|
||||
tox:
|
||||
lint:
|
||||
name: ${{ matrix.toxenv }}
|
||||
|
||||
runs-on: Ubuntu-latest
|
||||
|
@ -129,10 +117,103 @@ jobs:
|
|||
--parallel-live
|
||||
--skip-missing-interpreters false
|
||||
|
||||
test:
|
||||
name: 🐍${{ matrix.python }} @ ${{ matrix.os }}
|
||||
|
||||
runs-on: ${{ matrix.os }}-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os:
|
||||
- macOS
|
||||
- Ubuntu
|
||||
- Windows
|
||||
python:
|
||||
# NOTE: The latest and the lowest supported Pythons are prioritized
|
||||
# NOTE: to improve the responsiveness. It's nice to see the most
|
||||
# NOTE: important results first.
|
||||
- '3.10'
|
||||
- 3.6
|
||||
- 3.9
|
||||
- 3.8
|
||||
- 3.7
|
||||
max-parallel: 4
|
||||
|
||||
env:
|
||||
PY_COLORS: 1
|
||||
TOX_PARALLEL_NO_SPINNER: 1
|
||||
TOXENV: python
|
||||
|
||||
steps:
|
||||
- name: Switch to using Python v${{ matrix.python }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
- name: >-
|
||||
Calculate Python interpreter version hash value
|
||||
for use in the cache key
|
||||
id: calc-cache-key-py
|
||||
run: |
|
||||
from hashlib import sha512
|
||||
from sys import version
|
||||
|
||||
hash = sha512(version.encode()).hexdigest()
|
||||
print(f'::set-output name=py-hash-key::{hash}')
|
||||
shell: python
|
||||
- name: Get pip cache dir
|
||||
id: pip-cache
|
||||
run: >-
|
||||
echo "::set-output name=dir::$(pip cache dir)"
|
||||
- name: Set up pip cache
|
||||
uses: actions/cache@v2.1.5
|
||||
with:
|
||||
path: ${{ steps.pip-cache.outputs.dir }}
|
||||
key: >-
|
||||
${{ runner.os }}-pip-${{
|
||||
steps.calc-cache-key-py.outputs.py-hash-key }}-${{
|
||||
hashFiles('tox.ini', 'requirements.txt', 'requirements-testing.txt')
|
||||
}}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-${{
|
||||
steps.calc-cache-key-py.outputs.py-hash-key
|
||||
}}-
|
||||
${{ runner.os }}-pip-
|
||||
- name: Install tox
|
||||
run: >-
|
||||
python -m
|
||||
pip install
|
||||
--user
|
||||
tox
|
||||
|
||||
- name: Grab the source from Git
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Pre-populate the testing env
|
||||
run: >-
|
||||
python -m
|
||||
tox
|
||||
--parallel auto
|
||||
--parallel-live
|
||||
--skip-missing-interpreters false
|
||||
--notest
|
||||
- name: Run the testing
|
||||
run: >-
|
||||
python -m
|
||||
tox
|
||||
--parallel auto
|
||||
--parallel-live
|
||||
--skip-missing-interpreters false
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v2
|
||||
with:
|
||||
flags: pytest, GHA, Python ${{ matrix.python }}, ${{ runner.os }}
|
||||
verbose: true
|
||||
|
||||
check: # This job does nothing and is only used for the branch protection
|
||||
needs:
|
||||
- build
|
||||
- tox
|
||||
- integration
|
||||
- lint
|
||||
- test
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
|
|
2
Makefile
2
Makefile
|
@ -92,7 +92,7 @@ lib-lint:
|
|||
python -m tox -e lint
|
||||
|
||||
lib-test: lib-clean lib-version lib-lint
|
||||
pytest -v tests/
|
||||
python -m tox -e python -- -v
|
||||
|
||||
lib-package: lib-clean lib-version
|
||||
python -m tox -e cleanup-dists,build-dists,metadata-validation
|
||||
|
|
6
tox.ini
6
tox.ini
|
@ -7,7 +7,11 @@ minversion = 3.21.0
|
|||
deps =
|
||||
-rrequirements.txt
|
||||
-rrequirements-testing.txt
|
||||
command = pytest
|
||||
# NOTE: The command is invoked by the script name and not via
|
||||
# NOTE: `{envpython} -m pytest` because it'd add CWD into $PYTHONPATH
|
||||
# NOTE: testing the project from the Git checkout
|
||||
# NOTE: rather than one installed.
|
||||
commands = pytest --cov=proxy tests/ {posargs:}
|
||||
|
||||
|
||||
[dists]
|
||||
|
|
Loading…
Reference in New Issue