Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: use tox to build and run test environments #1259

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 33 additions & 40 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,51 @@ on: [push, pull_request]

jobs:
test:
name: test
runs-on: ${{ matrix.os }}
name: ${{ matrix.toxenv }} (Python ${{ matrix.python-version }}, ${{ matrix.runs-on }})
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.7", "3.10", "pypy-3.7", "pypy-3.8"]
timeout-minutes: 30
runs-on: ["ubuntu-latest"]
python-version: ["3.7", "3.8", "pypy3.8", "3.10", "3.11"]
toxenv: ["test-xdist"]
include:
- runs-on: ubuntu-latest
python-version: "3.8"
toxenv: test-mindeps-xdist
- runs-on: ubuntu-latest
python-version: "3.11"
toxenv: test-devdeps-xdist
- runs-on: ubuntu-latest
python-version: "3.x"
toxenv: test-xdist-cov
- runs-on: macos-latest
python-version: "3.x"
toxenv: test-xdist-cov
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

# We need Python 3.7 to always be installed, so tests with
# multiple environments can run.
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: 3.7

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml

- name: Install dependencies
run: python -m pip install -r requirements-dev.txt

- name: Install asv
run: pip install .

- name: Run tests
run: python -m pytest -v --timeout=300 --durations=100 test

docs:
runs-on: ubuntu-latest
- run: pip install tox
- run: tox -e ${{ matrix.toxenv }}
build:
name: ${{ matrix.toxenv }} (Python ${{ matrix.python-version }}, ${{ matrix.runs-on }})
runs-on: ${{ matrix.runs-on }}
strategy:
fail-fast: false
matrix:
runs-on: ["ubuntu-latest"]
python-version: ["3.x"]
toxenv: ["build-docs", "build-dist"]
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: '3.x'
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml

- name: Install dependencies
run: python -m pip install -r requirements-dev.txt

- name: Install asv
run: pip install ".[doc]"

- name: Build docs
run: sphinx-build -W docs/source html
- run: pip install tox
- run: tox -e ${{ matrix.toxenv }}
6 changes: 3 additions & 3 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- uses: pre-commit/action@v2.0.3
python-version: '3.x'
- uses: pre-commit/action@v3.0.0
43 changes: 43 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[tox]
env_list =
test{,-mindeps}{,-warnings,-cov}-xdist
build-{docs,dist}

[testenv]
description =
run tests
mindeps: with the minimum supported versions of key dependencies
warnings: treating warnings as errors
cov: with coverage
xdist: using parallel processing
extras =
test
deps =
devdeps: -rrequirements-dev.txt
mindeps: minimum_dependencies
cov: pytest-cov
xdist: pytest-xdist
commands_pre =
mindeps: minimum_dependencies asv --filename requirements-min.txt
mindeps: pip install -r requirements-min.txt
pip freeze
commands =
pytest -v --timeout 300 --durations 100 \
cov: --cov . --cov-report xml \
warnings: -W error \
xdist: -n auto \
{posargs}

[testenv:build-docs]
description = invoke sphinx-build to build the HTML docs
extras = doc
commands =
sphinx-build -W docs/source html

[testenv:build-dist]
description = package source and build wheel
skip_install = true
deps =
build
commands =
python -m build .