|
| 1 | +--- |
1 | 2 | name: tox |
2 | 3 |
|
3 | 4 | on: |
4 | | - push: # only publishes pushes to the main branch to TestPyPI |
5 | | - branches: # any integration branch but not tag |
6 | | - - main |
7 | | - tags-ignore: |
8 | | - - "**" |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - "main" |
9 | 8 | pull_request: |
| 9 | + branches: |
| 10 | + - "main" |
| 11 | + schedule: |
| 12 | + - cron: "0 0 * * *" |
| 13 | + workflow_call: |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +env: |
| 20 | + FORCE_COLOR: 1 # tox, pytest, ansible-lint |
| 21 | + PY_COLORS: 1 |
10 | 22 |
|
11 | 23 | jobs: |
12 | | - pre: |
13 | | - name: pre |
14 | | - runs-on: ubuntu-22.04 |
| 24 | + prepare: |
| 25 | + name: prepare |
| 26 | + runs-on: ubuntu-24.04 |
15 | 27 | outputs: |
16 | 28 | matrix: ${{ steps.generate_matrix.outputs.matrix }} |
17 | 29 | steps: |
18 | 30 | - name: Determine matrix |
19 | 31 | id: generate_matrix |
20 | | - uses: coactions/dynamic-matrix@v1 |
| 32 | + uses: coactions/dynamic-matrix@v4 |
21 | 33 | with: |
22 | 34 | min_python: "3.9" |
23 | 35 | other_names: | |
24 | 36 | lint |
25 | 37 | docs |
26 | 38 | pkg |
| 39 | + alpine |
27 | 40 |
|
28 | | - alpine: |
29 | | - name: alpine |
30 | | - runs-on: ubuntu-22.04 |
| 41 | + build: |
| 42 | + name: ${{ matrix.name }} |
| 43 | + runs-on: ${{ matrix.os || 'ubuntu-24.04' }} |
| 44 | + needs: |
| 45 | + - prepare |
| 46 | + strategy: |
| 47 | + matrix: ${{ fromJson(needs.prepare.outputs.matrix) }} |
31 | 48 | steps: |
32 | | - - name: Check out code |
33 | | - uses: actions/checkout@v4 |
| 49 | + - uses: actions/checkout@v4 |
34 | 50 | with: |
35 | | - fetch-depth: 0 |
| 51 | + fetch-depth: 0 # needed by setuptools-scm |
| 52 | + submodules: true |
36 | 53 |
|
37 | | - - name: Run docker build |
38 | | - run: docker build . |
| 54 | + - name: Set pre-commit cache |
| 55 | + uses: actions/cache@v4 |
| 56 | + if: ${{ matrix.name == 'lint' }} |
| 57 | + with: |
| 58 | + path: | |
| 59 | + ~/.cache/pre-commit |
| 60 | + key: pre-commit-${{ matrix.name }}-${{ hashFiles('.pre-commit-config.yaml') }} |
39 | 61 |
|
40 | | - unit: |
41 | | - name: ${{ matrix.name }} |
42 | | - runs-on: ${{ matrix.os || 'ubuntu-22.04' }} |
43 | | - needs: pre |
44 | | - strategy: |
45 | | - matrix: ${{ fromJson(needs.pre.outputs.matrix) }} |
46 | | - steps: |
| 62 | + - name: Set up Python ${{ matrix.python_version || '3.10' }} |
| 63 | + if: "!contains(matrix.shell, 'wsl')" |
| 64 | + uses: actions/setup-python@v5 |
| 65 | + with: |
| 66 | + cache: pip |
| 67 | + python-version: ${{ matrix.python_version || '3.10' }} |
| 68 | + |
| 69 | + - name: Install tox |
| 70 | + run: | |
| 71 | + python3 -m pip install --upgrade pip |
| 72 | + python3 -m pip install --upgrade "tox>=4.0.0" "tox-uv>=1.16.0" uv |
| 73 | +
|
| 74 | + - name: Log installed dists |
| 75 | + run: python3 -m pip freeze --all |
| 76 | + |
| 77 | + - run: ${{ matrix.command }} |
| 78 | + |
| 79 | + - run: ${{ matrix.command2 }} |
| 80 | + if: ${{ matrix.command2 }} |
47 | 81 |
|
48 | | - - uses: actions/checkout@main |
49 | | - with: |
50 | | - fetch-depth: 0 |
51 | | - |
52 | | - - name: Set up stock Python ${{ matrix.python_version }} from GitHub |
53 | | - uses: actions/setup-python@v5 |
54 | | - with: |
55 | | - python-version: ${{ matrix.python_version }} |
56 | | - |
57 | | - - name: Log the currently selected Python version info (${{ matrix.python_version }}) |
58 | | - run: | |
59 | | - python --version --version |
60 | | - which python |
61 | | -
|
62 | | - - name: Pip cache |
63 | | - uses: actions/cache@v4 |
64 | | - with: |
65 | | - path: ~/.cache/pip |
66 | | - key: ${{ runner.os }}-pip-${{ env.PY_SHA256 }}-${{ hashFiles('setup.cfg') }}-${{ hashFiles('tox.ini') }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('.pre-commit-config.yaml') }}-${{ hashFiles('pytest.ini') }} |
67 | | - restore-keys: | |
68 | | - ${{ runner.os }}-pip- |
69 | | - ${{ runner.os }}- |
70 | | -
|
71 | | - - name: Install tox |
72 | | - run: | |
73 | | - python -m pip install -U pip |
74 | | - pip install tox |
75 | | - - name: Run tox run -e ${{ matrix.passed_name }} |
76 | | - run: tox run -e ${{ matrix.passed_name }} |
| 82 | + - run: ${{ matrix.command3 }} |
| 83 | + if: ${{ matrix.command3 }} |
| 84 | + |
| 85 | + - run: ${{ matrix.command4 }} |
| 86 | + if: ${{ matrix.command4 }} |
| 87 | + |
| 88 | + - run: ${{ matrix.command5 }} |
| 89 | + if: ${{ matrix.command5 }} |
| 90 | + |
| 91 | + - name: Archive logs |
| 92 | + uses: actions/upload-artifact@v4 |
| 93 | + with: |
| 94 | + name: logs-${{ matrix.name }}.zip |
| 95 | + include-hidden-files: true |
| 96 | + path: | |
| 97 | + .tox/**/log/ |
| 98 | + .tox/**/.coverage* |
| 99 | + .tox/**/coverage.xml |
77 | 100 |
|
| 101 | + - name: Report failure if git reports dirty status |
| 102 | + run: | |
| 103 | + if [[ -n $(git status -s) ]]; then |
| 104 | + # shellcheck disable=SC2016 |
| 105 | + echo -n '::error file=git-status::' |
| 106 | + printf '### Failed as git reported modified and/or untracked files\n```\n%s\n```\n' "$(git status -s)" | tee -a "$GITHUB_STEP_SUMMARY" |
| 107 | + exit 99 |
| 108 | + fi |
| 109 | + # https://github.com/actions/toolkit/issues/193 |
78 | 110 | check: # This job does nothing and is only used for the branch protection |
79 | 111 | if: always() |
80 | 112 | needs: |
81 | | - - unit |
82 | | - - alpine |
83 | | - runs-on: ubuntu-22.04 |
| 113 | + - build |
| 114 | + runs-on: ubuntu-24.04 |
84 | 115 | steps: |
85 | 116 | - name: Decide whether the needed jobs succeeded or failed |
86 | 117 | uses: re-actors/alls-green@release/v1 |
|
0 commit comments