Repository navigation
146 lines (146 loc) · 4.91 KB
/
Copy pathcheck.yaml
File metadata and controls
146 lines (146 loc) · 4.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: Check
on:
workflow_call:
inputs:
include:
description: JSON array of matrix rows; each has env, and optionally python and os
type: string
required: true
os:
description: Runner for rows without an os
type: string
default: ubuntu-26.04
apt-packages:
description: Space-separated Ubuntu packages installed on Linux jobs before tox runs
type: string
default: ""
tox-install:
description: Arguments to uv tool install that put tox and its plugins on PATH
type: string
default: tox --with tox-uv
exclude-newer:
description: Upload cutoff for the tox install, a timestamp or a duration
type: string
default: 7 days
exclude-newer-package:
description: Newline-separated name=date cutoffs that override exclude-newer for single packages
type: string
default: ""
pytest-addopts:
description: PYTEST_ADDOPTS for the test run
type: string
default: "-vv --durations=20"
diff-against:
description: DIFF_AGAINST for the test run, a Git revision the tests compare with
type: string
default: HEAD
coverage:
description: Upload each job's .tox/.coverage.* data as an artifact for a caller job to merge
type: boolean
default: false
permissions: {}
jobs:
test:
name: 🧪 ${{ matrix.env }} on ${{ matrix.os || inputs.os }}
runs-on: ${{ matrix.os || inputs.os }}
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include: ${{ fromJSON(inputs.include) }}
steps:
- name: 📥 Check out repository
uses: actions/checkout@v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: 📦 Install apt packages
id: apt
background: true
shell: bash
env:
APT_PACKAGES: ${{ inputs.apt-packages }}
run: |
set -euo pipefail
if [[ -z "$APT_PACKAGES" || "$RUNNER_OS" != Linux ]]; then
echo 'Apt packages skipped: the apt-packages input is empty or the runner is not Linux'
exit 0
fi
read -ra packages <<<"$APT_PACKAGES"
sudo apt-get update
sudo apt-get install -y ${packages[@]+"${packages[@]}"}
- name: 🐍 Install uv and Python
uses: astral-sh/setup-uv@v10.3.3
with:
version: latest-known
python-version: "3.15"
enable-cache: false
- name: 📦 Install tox
id: tox
background: true
shell: bash
env:
TOX_INSTALL: ${{ inputs.tox-install }}
EXCLUDE_NEWER: ${{ inputs.exclude-newer }}
EXCLUDE_NEWER_PACKAGE: ${{ inputs.exclude-newer-package }}
run: |
set -euo pipefail
read -ra spec <<<"$TOX_INSTALL"
options=(--exclude-newer "$EXCLUDE_NEWER")
while IFS= read -r line; do
if [[ -n "$line" ]]; then options+=(--exclude-newer-package "$line"); fi
done <<<"$EXCLUDE_NEWER_PACKAGE"
echo "Installing ${spec[*]+"${spec[*]}"} with uploads older than $EXCLUDE_NEWER"
uv tool install --python-preference only-managed --python 3.15 "${options[@]}" ${spec[@]+"${spec[@]}"}
- name: 🐍 Install Python
id: python
background: true
shell: bash
env:
PYTHON: ${{ matrix.python }}
run: |
set -euo pipefail
if [[ -z "$PYTHON" ]]; then
echo 'Python install skipped: the matrix row names no python'
exit 0
fi
uv python install --python-preference only-managed "$PYTHON"
- name: ⏳ Wait for apt packages
wait: apt
- name: ⏳ Wait for tox
wait: tox
- name: ⏳ Wait for Python
wait: python
- name: 📦 Set up test suite
shell: bash
env:
MATRIX_ENV: ${{ matrix.env }}
run: tox run -vv --notest --skip-missing-interpreters false -e "$MATRIX_ENV"
- name: 🧪 Run test suite
shell: bash
env:
MATRIX_ENV: ${{ matrix.env }}
PYTEST_ADDOPTS: ${{ inputs.pytest-addopts }}
DIFF_AGAINST: ${{ inputs.diff-against }}
run: tox run --skip-pkg-install -e "$MATRIX_ENV"
- name: 📤 Upload coverage data
if: ${{ inputs.coverage }}
uses: actions/upload-artifact@v7.0.2
with:
include-hidden-files: true
name: .coverage.${{ matrix.os || inputs.os }}.${{ matrix.env }}
path: .tox/.coverage.*
if-no-files-found: error
retention-days: 3
gate:
name: 🚦 Required checks pass
if: ${{ !cancelled() }}
needs: [test]
runs-on: ubuntu-26.04
permissions: {}
steps:
- name: 🚦 Require all needed jobs to pass
uses: $/required-checks
with:
needs: ${{ toJSON(needs) }}