Skip to content

ci: simplify job's matrix #120

ci: simplify job's matrix

ci: simplify job's matrix #120

Workflow file for this run

name: Test
on: [push, pull_request, workflow_dispatch]
env:
FORCE_COLOR: 1
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: ["ubuntu-22.04", "macos-13", "windows-2022"]
pypy: [0, 1]
include:
- {os: "ubuntu-20.04", python-version: "2.7"}
- {os: "ubuntu-20.04", python-version: "3.7"}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Get pip cache dir
id: pip-cache
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') }}"
restore-keys: |
"${{ matrix.os }}-${{ matrix.python-version }}-v1-"
- 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 ${{ env.TOX_ENV }}