-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (45 loc) · 1.36 KB
/
test.yml
File metadata and controls
53 lines (45 loc) · 1.36 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
name: Tests
on:
workflow_call:
jobs:
setup:
runs-on: ubuntu-latest
outputs:
python-versions: ${{ steps.versions.outputs.versions }}
steps:
- uses: actions/checkout@v6
- name: Read Python versions from classifiers
id: versions
run: |
versions=$(python3 -c "
import tomllib, json, re
with open('pyproject.toml', 'rb') as f:
data = tomllib.load(f)
classifiers = data.get('project', {}).get('classifiers', [])
versions = [
m.group(1) for c in classifiers
if (m := re.fullmatch(r'Programming Language :: Python :: (\d+\.\d+)', c))
]
print(json.dumps(versions))
")
if [ "$versions" = "[]" ]; then
echo "No Python versions declared in pyproject.toml classifiers" >&2
exit 1
fi
echo "versions=$versions" >> "$GITHUB_OUTPUT"
test:
needs: setup
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ${{ fromJson(needs.setup.outputs.python-versions) }}
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync
- name: Run tests
run: uv run pytest tests