Skip to content

Commit

Permalink
ci: simplify job's matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Apr 30, 2024
1 parent 1368087 commit c22ea02
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
34 changes: 15 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,12 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["pypy-2.7", "pypy-3.8", "2.7", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: ["ubuntu-22.04", "macos-13", "windows-2022"]
pypy: [0, 1]
include:
# Add new helper variables to existing jobs
- {python-version: "pypy-2.7", toxenv: "pypy"}
- {python-version: "pypy-3.8", toxenv: "pypy3"}
- {python-version: "2.7", toxenv: "py27"}
- {python-version: "3.7", toxenv: "py37"}
- {python-version: "3.8", toxenv: "py38"}
- {python-version: "3.9", toxenv: "py39"}
- {python-version: "3.10", toxenv: "py310"}
- {python-version: "3.11", toxenv: "py311"}
- {python-version: "3.12", toxenv: "py312"}
- {os: "ubuntu-20.04", python-version: "2.7"}
- {os: "ubuntu-20.04", python-version: "3.7"}

steps:
- uses: actions/checkout@v3
Expand All @@ -36,22 +29,25 @@ jobs:

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
run: echo "::set-output name=dir::$(pip cache dir)"

- name: Cache
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key:
${{ matrix.os }}-${{ matrix.python-version }}-v1-${{ hashFiles('**/tox.ini') }}
"${{ matrix.os }}-${{ matrix.python-version }}-v1-${{ hashFiles('**/tox.ini') }}"
restore-keys: |
${{ matrix.os }}-${{ matrix.python-version }}-v1-
"${{ matrix.os }}-${{ matrix.python-version }}-v1-"
- name: Install dependencies
- name: Install dependencies & py Env
run: |
python -m pip install tox
# determine the tox environment to run from python version
python -c 'print("TOX_ENV=py" + "${{ matrix.python-version }}".replace(".", ""))' >> $GITHUB_OUTPUT
- name: Set Pypy env
if: matrix.pypy == 1
run: python -c 'print("TOX_ENV=pypy" + "${{ matrix.python-version }}"[0])' >> $GITHUB_OUTPUT

- name: Tox tests
run: |
tox -e ${{ matrix.toxenv }}
run: tox -e ${{ env.TOX_ENV }}
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
isolated_build = true
envlist = py{27, 37, 38, 39, 310, 311, 312, py, py3}
envlist = py{27, 37, 38, 39, 310, 311, 312, py2, py3}

[testenv]
deps =
Expand Down

0 comments on commit c22ea02

Please sign in to comment.