Skip to content

Commit

Permalink
build: reduce CI usage (#83)
Browse files Browse the repository at this point in the history
* CI: Test multiple Pythons per OS

* Build a wheel once

* CI: Cache virtual environments
  • Loading branch information
kurtmckee authored Jul 25, 2023
1 parent 5dafcc5 commit 6a3a064
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 32 deletions.
44 changes: 29 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env:

jobs:
tests:
name: "${{ matrix.python-version }} on ${{ matrix.os }}"
name: "Test on ${{ matrix.os }}"
runs-on: "${{ matrix.os }}-latest"

strategy:
Expand All @@ -31,29 +31,43 @@ jobs:
- ubuntu
- macos
- windows
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "pypy-3.9"

steps:
- name: "Check out the repo"
uses: "actions/checkout@v3"

- name: "Set up Python"
id: "setup-python"
uses: "actions/setup-python@v4"
with:
python-version: "${{ matrix.python-version }}"
cache: pip
cache-dependency-path: 'requirements/*.txt'
# The last listed Python version is the default.
python-version: |
pypy-3.9
3.7
3.8
3.9
3.10
3.11
- name: "Restore cache"
id: "restore-cache"
uses: "actions/cache@v3"
with:
path: |
.tox/
.venv/
key: "cache-python-${{ steps.setup-python.outputs.python-version }}-os-${{ runner.os }}-hash-${{ hashFiles('tox.ini', 'requirements/*.txt') }}"

- name: "Identify venv path"
shell: "bash"
run: "echo 'venv-path=${{ runner.os == 'Windows' && '.venv/Scripts' || '.venv/bin' }}' >> $GITHUB_ENV"

- name: "Install dependencies"
if: "steps.restore-cache.outputs.cache-hit == false"
run: |
python -m pip install -U setuptools
python -m pip install -r requirements/tox.txt
python -m venv .venv
${{ env.venv-path }}/python -m pip install -U setuptools
${{ env.venv-path }}/python -m pip install -r requirements/tox.txt
- name: "Install pandoc on Linux"
# sudo apt-get pandoc: will install a version from 2018!
Expand All @@ -72,9 +86,9 @@ jobs:
run: |
choco install -y -r --no-progress pandoc
- name: "Run tox for ${{ matrix.python-version }}"
- name: "Run tox"
run: |
python -m tox
${{ env.venv-path }}/python -m tox -m ci-tests
- name: "Upload coverage data"
uses: actions/upload-artifact@v3
Expand Down
3 changes: 0 additions & 3 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,6 @@ tomlkit==0.11.8
tox==4.6.4
# via
# -r requirements/tox.txt
# tox-gh
tox-gh==1.2.0
# via -r requirements/tox.txt
twine==4.0.2
# via -r requirements/quality.txt
typed-ast==1.5.5
Expand Down
1 change: 0 additions & 1 deletion requirements/tox.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
-c constraints.txt

tox # Virtualenv management for tests
tox-gh # Run tox environment based on the GitHub action matrix
3 changes: 0 additions & 3 deletions requirements/tox.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ tomli==2.0.1
tox==4.6.4
# via
# -r requirements/tox.in
# tox-gh
tox-gh==1.2.0
# via -r requirements/tox.in
typing-extensions==4.7.1
# via
# importlib-metadata
Expand Down
14 changes: 4 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ envlist =
py3{7,11}-no_extras,
# And the rest:
pypy3, coverage, docs, quality
labels =
ci-tests = py3{7,8,9,10,11},pypy3

[testenv]
package = wheel
wheel_build_env = .pkg
deps =
-r{toxinidir}/requirements/test.txt
extras =
Expand Down Expand Up @@ -61,13 +65,3 @@ commands =
commands =
python -m pip install -U pip
make upgrade

[gh]
# https://pypi.org/project/tox-gh/
python =
3.7 = py37, py37-no_extras
3.8 = py38
3.9 = py39
3.10 = py310
3.11 = py311, py311-no_extras
pypy3 = pypy3

0 comments on commit 6a3a064

Please sign in to comment.