Repository navigation
93 lines (90 loc) · 4.15 KB
/
Copy pathpython-binding.yml
File metadata and controls
93 lines (90 loc) · 4.15 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
name: Python binding
on:
# Tags are excluded: release tags point at commits already tested on a branch.
push:
branches: [main, "release/**"]
pull_request:
# Superseded pull request runs are cancelled. Pushes to main and release
# branches get their own group, so every pushed commit is tested.
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
installed-wheel:
name: CPython ${{ matrix.python-version }} (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
# The abi3 wheel covers every version; Linux runs the version matrix and
# one macOS job keeps platform coverage without queueing for macOS runners.
os: [ubuntu-latest]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
include:
- os: macos-15
python-version: "3.12"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Docs-only changes skip the remaining steps but still report success, so
# required checks never wait for a run that path filters would not start.
- name: Detect docs-only changes
id: scope
shell: bash
env:
BASE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
run: |
code=true
if [[ -n "$BASE" && "$BASE" != 0000000000000000000000000000000000000000 ]] && git cat-file -e "$BASE^{commit}" 2>/dev/null; then
files="$(git diff --name-only "$BASE" "$GITHUB_SHA")"
if [[ -n "$files" ]]; then
code=false
while IFS= read -r file; do
case "$file" in docs/*|*.md|*.mdx) ;; *) code=true ;; esac
done <<< "$files"
fi
fi
echo "code=$code" >> "$GITHUB_OUTPUT"
- if: steps.scope.outputs.code == 'true'
id: rust-version
run: echo "version=$(./scripts/pin.sh rust)" >> "$GITHUB_OUTPUT"
- if: steps.scope.outputs.code == 'true'
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.rust-version.outputs.version }}
- if: steps.scope.outputs.code == 'true'
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.os }}
# Pull requests reuse caches from main without adding their own.
save-if: ${{ github.ref == 'refs/heads/main' }}
- if: steps.scope.outputs.code == 'true'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- if: steps.scope.outputs.code == 'true' && (matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12')
name: Test publication check without downloading models
run: |
python scripts/test-model-publish-check.py
python scripts/test-model-manifest.py
- if: steps.scope.outputs.code == 'true'
run: python -m pip install maturin
- if: steps.scope.outputs.code == 'true'
run: maturin build --manifest-path bindings/python/Cargo.toml --release
- if: steps.scope.outputs.code == 'true'
run: |
python -m venv .venv
.venv/bin/python -m pip install target/wheels/*.whl
.venv/bin/python -m pip install -r bindings/python/tests/requirements-typing.txt
.venv/bin/python bindings/python/tests/test_installed.py
.venv/bin/python bindings/python/tests/test_typing.py
- if: steps.scope.outputs.code == 'true' && (matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10')
name: Verify typing survives a source distribution rebuild
run: |
maturin sdist --manifest-path bindings/python/Cargo.toml --out target/sdist
.venv/bin/python -m pip wheel --no-deps target/sdist/*.tar.gz --wheel-dir target/rebuilt-wheels
.venv/bin/python -m pip install --force-reinstall target/rebuilt-wheels/*.whl
.venv/bin/python bindings/python/tests/test_installed.py
.venv/bin/python bindings/python/tests/test_typing.py