| 1 |
--- |
| 2 |
name: Test code |
| 3 |
|
| 4 |
env: |
| 5 |
CI_FORCE_COLORS_PYTEST: --color yes |
| 6 |
|
| 7 |
on: |
| 8 |
workflow_dispatch: |
| 9 |
|
| 10 |
push: |
| 11 |
tags: |
| 12 |
- "!*" |
| 13 |
branches: |
| 14 |
- main |
| 15 |
- "test-me-*" |
| 16 |
|
| 17 |
pull_request: |
| 18 |
branches: |
| 19 |
- "**" |
| 20 |
|
| 21 |
jobs: |
| 22 |
build: |
| 23 |
name: Tests on ${{ matrix.os }} with python ${{ matrix.python-version }} |
| 24 |
runs-on: ${{ matrix.os }} |
| 25 |
strategy: |
| 26 |
fail-fast: false |
| 27 |
matrix: |
| 28 |
os: ["ubuntu-latest", "windows-latest", "macos-latest"] |
| 29 |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] |
| 30 |
steps: |
| 31 |
- uses: actions/checkout@v3 |
| 32 |
|
| 33 |
- name: Fetch origin/main |
| 34 |
|
| 35 |
run: git fetch --no-tags origin main:refs/remotes/origin/main |
| 36 |
|
| 37 |
- name: Set up Python ${{ matrix.python-version }} |
| 38 |
uses: actions/setup-python@v4 |
| 39 |
with: |
| 40 |
python-version: ${{ matrix.python-version }} |
| 41 |
|
| 42 |
- name: Display Python version |
| 43 |
run: python --version |
| 44 |
|
| 45 |
- name: Upgrade pip |
| 46 |
run: python -m pip install --upgrade pip |
| 47 |
|
| 48 |
- name: Install pipx |
| 49 |
run: python -m pip install --upgrade pipx |
| 50 |
|
| 51 |
- name: Install tox via pipx |
| 52 |
run: pipx install tox |
| 53 |
|
| 54 |
- name: Run tests via tox (linux/macos) |
| 55 |
if: runner.os != 'Windows' |
| 56 |
run: | |
| 57 |
major=$(python -c "import sys;print(sys.version_info[0])") |
| 58 |
minor=$(python -c "import sys;print(sys.version_info[1])") |
| 59 |
tox -m py${major}.${minor} |
| 60 |
|
| 61 |
- name: Run tests via tox (windows) |
| 62 |
if: runner.os == 'Windows' |
| 63 |
run: | |
| 64 |
$major = python -c "import sys;print(sys.version_info[0])" |
| 65 |
$minor = python -c "import sys;print(sys.version_info[1])" |
| 66 |
tox -m py${major}.${minor} |