Skip to content

Commit

Permalink
Add dynamic matrix (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Jan 5, 2023
1 parent 2298704 commit 44da846
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 31 deletions.
80 changes: 50 additions & 30 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,77 @@
name: tox

# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

on:
push: # only publishes pushes to the main branch to TestPyPI
branches: # any integration branch but not tag
- "main"
pull_request:

jobs:
pre:
name: pre
runs-on: ubuntu-22.04
outputs:
matrix: ${{ steps.generate_matrix.outputs.matrix }}
steps:
- name: Determine matrix
id: generate_matrix
uses: coactions/dynamic-matrix@v1
with:
min_python: "3.9"
max_python: "3.11"
default_python: "3.9" # used by jobs in other_names
other_names: |
lint
pkg
devel
build:
name: ${{ matrix.tox_env }}
runs-on: ubuntu-latest
name: ${{ matrix.name }}
runs-on: ubuntu-22.04
needs: pre
env:
PYTEST_REQPASS: 3
strategy:
fail-fast: false
matrix:
include:
- tox_env: lint
# - tox_env: docs
- tox_env: py38
PREFIX: PYTEST_REQPASS=3
- tox_env: py39
PREFIX: PYTEST_REQPASS=3
- tox_env: py310
PREFIX: PYTEST_REQPASS=3
- tox_env: py311
PREFIX: PYTEST_REQPASS=3
- tox_env: py311-devel
PREFIX: PYTEST_REQPASS=3
- tox_env: pkg
matrix: ${{ fromJson(needs.pre.outputs.matrix) }}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # needed by setuptools-scm

- name: Install system dependencies
run: |
sudo apt-get update \
&& sudo apt-get install -y ansible \
&& ansible-doc -l | grep gce
- name: Find python version
id: py_ver
shell: python
if: ${{ contains(matrix.tox_env, 'py') }}
run: |
v = '${{ matrix.tox_env }}'.split('-')[0].lstrip('py')
print('::set-output name=version::{0}.{1}'.format(v[0],v[1:]))
# Even our lint and other envs need access to tox
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{ steps.py_ver.outputs.version || '>=3.8' }}
python-version: ${{ matrix.python_version }}

- name: Install dependencies
run: |
python -m pip install -U pip
pip install tox
- name: Run tox -e ${{ matrix.tox_env }}
pip install 'tox>=4.2.3'
- name: Run tox run -e ${{ matrix.passed_name }}
run: |
echo "${{ matrix.PREFIX }} tox -e ${{ matrix.tox_env }}"
${{ matrix.PREFIX }} tox -e ${{ matrix.tox_env }}
${{ matrix.PREFIX }} tox run -e ${{ matrix.passed_name }}
check: # This job does nothing and is only used for the branch protection
if: always()

needs:
- build
runs-on: ubuntu-22.04
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# For more information about tox, see https://tox.readthedocs.io/en/latest/
[tox]
minversion = 4.2.2
minversion = 4.2.3
envlist =
lint
pkg
Expand Down

0 comments on commit 44da846

Please sign in to comment.