| 1 |
name: Tests |
| 2 |
on: [push, pull_request, workflow_dispatch] |
| 3 |
jobs: |
| 4 |
{%- raw %} |
| 5 |
examples: |
| 6 |
runs-on: ubuntu-latest |
| 7 |
strategy: |
| 8 |
fail-fast: false |
| 9 |
matrix: |
| 10 |
python-version: ["pypy-3.9", "3.11"] |
| 11 |
target: [ |
| 12 |
"src-layout", |
| 13 |
"adhoc-layout", |
| 14 |
] |
| 15 |
include: |
| 16 |
# Add new helper variables to existing jobs |
| 17 |
- {python-version: "pypy-3.9", tox-python-version: "pypy3"} |
| 18 |
- {python-version: "3.11", tox-python-version: "py311"} |
| 19 |
steps: |
| 20 |
- uses: actions/checkout@v3 |
| 21 |
|
| 22 |
- name: Set up Python ${{ matrix.python-version }} |
| 23 |
uses: actions/setup-python@v4 |
| 24 |
with: |
| 25 |
python-version: ${{ matrix.python-version }} |
| 26 |
|
| 27 |
- name: Cache |
| 28 |
uses: actions/cache@v3 |
| 29 |
with: |
| 30 |
path: ~/.cache/pip |
| 31 |
key: |
| 32 |
examples-v1-${{ hashFiles('**/tox.ini') }} |
| 33 |
restore-keys: | |
| 34 |
examples-v1- |
| 35 |
|
| 36 |
- name: Install dependencies |
| 37 |
run: | |
| 38 |
python -m pip install --upgrade pip |
| 39 |
python -m pip install --upgrade wheel |
| 40 |
python -m pip install --progress-bar=off tox -rci/requirements.txt |
| 41 |
|
| 42 |
- name: Examples |
| 43 |
run: | |
| 44 |
cd examples/${{ matrix.target }} |
| 45 |
tox -v -e ${{ matrix.tox-python-version }} |
| 46 |
{%- endraw %} |
| 47 |
|
| 48 |
test: |
| 49 |
name: {{ '${{ matrix.name }}' }} |
| 50 |
runs-on: {{ '${{ matrix.os }}' }} |
| 51 |
timeout-minutes: 30 |
| 52 |
strategy: |
| 53 |
fail-fast: false |
| 54 |
matrix: |
| 55 |
include: |
| 56 |
- name: 'check' |
| 57 |
python: '3.11' |
| 58 |
toxpython: 'python3.11' |
| 59 |
tox_env: 'check' |
| 60 |
os: 'ubuntu-latest' |
| 61 |
- name: 'docs' |
| 62 |
python: '3.11' |
| 63 |
toxpython: 'python3.11' |
| 64 |
tox_env: 'docs' |
| 65 |
os: 'ubuntu-latest' |
| 66 |
{% for env in tox_environments %} |
| 67 |
{% set prefix = env.split('-')[0] -%} |
| 68 |
{% if prefix.startswith('pypy') %} |
| 69 |
{% set python %}pypy-{{ prefix[4] }}.{{ prefix[5:] }}{% endset %} |
| 70 |
{% set cpython %}pp{{ prefix[4:5] }}{% endset %} |
| 71 |
{% set toxpython %}pypy{{ prefix[4] }}.{{ prefix[5:] }}{% endset %} |
| 72 |
{% else %} |
| 73 |
{% set python %}{{ prefix[2] }}.{{ prefix[3:] }}{% endset %} |
| 74 |
{% set cpython %}cp{{ prefix[2:] }}{% endset %} |
| 75 |
{% set toxpython %}python{{ prefix[2] }}.{{ prefix[3:] }}{% endset %} |
| 76 |
{% endif %} |
| 77 |
{% for os, python_arch in [ |
| 78 |
['ubuntu', 'x64'], |
| 79 |
['windows', 'x64'], |
| 80 |
['macos', 'x64'], |
| 81 |
] %} |
| 82 |
- name: '{{ env }} ({{ os }})' |
| 83 |
python: '{{ python }}' |
| 84 |
toxpython: '{{ toxpython }}' |
| 85 |
python_arch: '{{ python_arch }}' |
| 86 |
tox_env: '{{ env }}' |
| 87 |
os: '{{ os }}-latest' |
| 88 |
{% endfor %} |
| 89 |
{% endfor %} |
| 90 |
steps: |
| 91 |
- uses: actions/checkout@v4 |
| 92 |
with: |
| 93 |
fetch-depth: 0 |
| 94 |
- uses: actions/setup-python@v5 |
| 95 |
with: |
| 96 |
python-version: {{ '${{ matrix.python }}' }} |
| 97 |
architecture: {{ '${{ matrix.python_arch }}' }} |
| 98 |
- name: install dependencies |
| 99 |
run: | |
| 100 |
python -mpip install --progress-bar=off -r ci/requirements.txt |
| 101 |
virtualenv --version |
| 102 |
pip --version |
| 103 |
tox --version |
| 104 |
pip list --format=freeze |
| 105 |
- name: test |
| 106 |
env: |
| 107 |
TOXPYTHON: '{{ '${{ matrix.toxpython }}' }}' |
| 108 |
run: > |
| 109 |
tox -e {{ '${{ matrix.tox_env }}' }} -v |
| 110 |
{% raw %} |
| 111 |
successful: |
| 112 |
# this provides a single status check for branch merge rules |
| 113 |
# (use this in `Require status checks to pass before merging` in branch settings) |
| 114 |
if: always() |
| 115 |
needs: |
| 116 |
- test |
| 117 |
- examples |
| 118 |
runs-on: ubuntu-latest |
| 119 |
steps: |
| 120 |
- name: Decide whether the needed jobs succeeded or failed |
| 121 |
uses: re-actors/alls-green@release/v1 |
| 122 |
with: |
| 123 |
jobs: ${{ toJSON(needs) }} |
| 124 |
{% endraw %} |