Skip to content

Commit

Permalink
Generate github test matrix from tox
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 18, 2024
1 parent 433091a commit d61866d
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 96 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,39 @@ jobs:
run: poetry install --no-interaction --all-extras
- name: build package
run: poetry build
# 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:
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
194 changes: 105 additions & 89 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ classifiers = [
"custom" = "template_handler.custom:Custom"

[tool.poetry.dependencies]
python = ">=3.8,<3.12"
python = "^3.8"

[tool.poetry.group.dev.dependencies]
pre-commit = "^3.2.1"
tox = "^4.0.0"
pytest = "^7.2.2"
tox = "^3.23.0"
pytest = "^7.4.3"
pytest-cov = "^4.0.0"
sceptre = ">3.2"
sceptre = "^4.0"
tox-gh-matrix = "^0.2"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down

0 comments on commit d61866d

Please sign in to comment.