Repository navigation
141 lines (127 loc) · 4.88 KB
/
Copy pathpython.yml
File metadata and controls
141 lines (127 loc) · 4.88 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
name: Python
run-name: Python wheel build and validation
on:
pull_request:
paths:
- ".github/workflows/python.yml"
- ".github/workflows/release-crates.yml"
- ".github/workflows/release-python.yml"
- "Cargo.lock"
- "Cargo.toml"
- "crates/**"
- "README.md"
- "docs/**"
- "pyproject.toml"
- "python-build-constraints.txt"
- "python/**"
- "scripts/check-python-wheel.sh"
- "scripts/validate-python-release-version.sh"
- "tests/python/**"
merge_group:
push:
branches:
- main
paths:
- ".github/workflows/python.yml"
- ".github/workflows/release-crates.yml"
- ".github/workflows/release-python.yml"
- "Cargo.lock"
- "Cargo.toml"
- "crates/**"
- "README.md"
- "docs/**"
- "pyproject.toml"
- "python-build-constraints.txt"
- "python/**"
- "scripts/check-python-wheel.sh"
- "scripts/validate-python-release-version.sh"
- "tests/python/**"
concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
python:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: |
3.10
3.11
3.12
3.13
cache: pip
cache-dependency-path: |
pyproject.toml
python-build-constraints.txt
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9 # v1
with:
toolchain: 1.98.0
- name: Cache cargo registry and build
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: cargo-python-${{ runner.os }}-${{ hashFiles('Cargo.lock', 'python-build-constraints.txt') }}
restore-keys: |
cargo-python-${{ runner.os }}-
cargo-${{ runner.os }}-
- name: Install uv
run: python -m pip install --constraint python-build-constraints.txt uv
# The binary wheel has no Python ABI dependency; reuse it across interpreters.
- name: Build wheel
id: build
run: |
set -euo pipefail
expected_version="$(cargo metadata --format-version 1 --no-deps \
| jq -r '.packages[] | select(.name == "agentic-server") | .version')"
if [ -z "$expected_version" ] || [ "$expected_version" = "null" ]; then
echo "::error::agentic-server workspace version could not be determined"
exit 1
fi
uv venv --python 3.12 .venv
uv pip install --python .venv/bin/python --constraint python-build-constraints.txt maturin
wheel_dir="$RUNNER_TEMP/agentic-api-wheels"
mkdir -p "$wheel_dir"
.venv/bin/python -m maturin build --release --locked --out "$wheel_dir"
wheel_path="$(
.venv/bin/python -c 'from pathlib import Path; import sys; matches = sorted(Path(sys.argv[1]).glob(f"agentic_api-{sys.argv[2]}-*.whl")); assert len(matches) == 1, f"expected exactly one wheel, found {[path.name for path in matches]}"; print(matches[0])' "$wheel_dir" "$expected_version"
)"
echo "AGENTIC_API_TEST_WHEEL=$wheel_path" >> "$GITHUB_ENV"
echo "AGENTIC_API_EXPECTED_VERSION=$expected_version" >> "$GITHUB_ENV"
- name: Validate wheel on Python 3.10
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
env:
PYTHON_VERSION: "3.10"
run: &validate-wheel |
set -euo pipefail
venv_dir=".venv-${PYTHON_VERSION}"
uv venv --python "$PYTHON_VERSION" "$venv_dir"
uv pip install --python "$venv_dir/bin/python" --constraint python-build-constraints.txt \
pytest "$AGENTIC_API_TEST_WHEEL"
"$venv_dir/bin/python" -m pytest tests/python -q
AGENTIC_API_CHECK_PYTHON="$venv_dir/bin/python" \
AGENTIC_API_CHECK_SCRIPTS_DIR="$venv_dir/bin" \
scripts/check-python-wheel.sh "$AGENTIC_API_TEST_WHEEL"
- name: Validate wheel on Python 3.11
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
env:
PYTHON_VERSION: "3.11"
run: *validate-wheel
- name: Validate wheel on Python 3.12
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
env:
PYTHON_VERSION: "3.12"
run: *validate-wheel
- name: Validate wheel on Python 3.13
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
env:
PYTHON_VERSION: "3.13"
run: *validate-wheel