Skip to content

Commit

Permalink
Generate github test matrix from tox (#1422)
Browse files Browse the repository at this point in the history
We only want one static list of environments to run unit tests
and that list should come from tox.ini

This sets up tox-gh-matrix[1] to dynamically generate the list
of test environments for github actions to run. It will allow
us to consolidate the list to just one for easier maintenance
going forward.

[1] https://github.com/medmunds/tox-gh-matrix
  • Loading branch information
zaro0508 committed Jan 23, 2024
1 parent 0445e32 commit 0b3a400
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 107 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,42 @@ jobs:
- name: build documentation
run: poetry run make html --directory docs

# use https://github.com/medmunds/tox-gh-matrix to export tox envlist to GH actions
get-tox-envlist:
runs-on: ubuntu-latest
outputs:
envlist: ${{ steps.generate-envlist.outputs.envlist }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install --no-interaction --all-extras
- id: generate-envlist
run: poetry run tox --gh-matrix

unit-tests:
needs: get-tox-envlist
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]
tox: ${{ fromJSON(needs.get-tox-envlist.outputs.envlist) }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Setup Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
python-version: ${{ matrix.tox.python.spec }}
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install --no-interaction --all-extras
- name: run python tests
run: poetry run tox -e py
run: poetry run tox -e ${{ matrix.tox.name }}
- name: run python test report
run: poetry run tox -e report

Expand Down

0 comments on commit 0b3a400

Please sign in to comment.