-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython-runtime-qualification.yml
More file actions
241 lines (216 loc) · 9.81 KB
/
Copy pathpython-runtime-qualification.yml
File metadata and controls
241 lines (216 loc) · 9.81 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
name: Python Runtime Qualification
on:
workflow_dispatch:
inputs:
baseline_runtime_wheel_url:
description: Optional HTTPS URL for a previously qualified 0.1.x runtime wheel
required: false
default: ""
type: string
baseline_runtime_wheel_sha256:
description: Required SHA-256 when a baseline runtime wheel URL is supplied
required: false
default: ""
type: string
permissions:
contents: read
jobs:
portable-matrix:
name: Python ${{ matrix.python }} / ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
python:
- "3.10"
- "3.11"
- "3.12"
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: runtimes/python/pyproject.toml
- name: Verify the install-free source quickstart
run: python -I scripts/verify-source-quickstart.py
- name: Install qualification tooling
run: >-
python -m pip install
--disable-pip-version-check
--editable "runtimes/python[dev]"
- name: Verify contracts, implementation, and typing
run: |
python scripts/sync-python-runtime-contracts.py
python scripts/verify-runtime-conformance.py
python -m coverage run --branch --source=runtimes/python/src/vyral_runtime -m unittest discover -s runtimes/python/tests -p "test_*.py"
python -m coverage report --fail-under=77.5 --precision=1
python -m mypy --config-file runtimes/python/pyproject.toml runtimes/python/src/vyral_runtime runtimes/python/tests/typecheck_consumer.py runtimes/python/tests/test_record_store.py
- name: Build and consume clean artifacts
run: |
python -m build --sdist --wheel --outdir artifacts/python-runtime runtimes/python
python scripts/verify-python-runtime-install.py --server artifacts/python-runtime --output artifacts/qualification/clean-install.json
python scripts/write-python-runtime-platform-receipt.py artifacts/python-runtime --clean-install-evidence artifacts/qualification/clean-install.json --output artifacts/qualification/platform.json
- name: Upload platform qualification evidence
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: python-runtime-${{ matrix.python }}-${{ matrix.os }}-${{ github.sha }}
path: artifacts
if-no-files-found: error
host-protocol:
name: Packaged host, SDKs, workers, and MCP
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
cache: pip
cache-dependency-path: |
clients/python/pyproject.toml
runtimes/python/pyproject.toml
- name: Set up Node
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 22.x
cache: npm
cache-dependency-path: clients/javascript/package-lock.json
- name: Build Python and JavaScript packages
run: |
python -m pip install --disable-pip-version-check build==1.3.0
mkdir -p artifacts/runtime artifacts/python-client artifacts/javascript artifacts/qualification
python -m build --sdist --wheel --outdir artifacts/runtime runtimes/python
python -m build --sdist --wheel --outdir artifacts/python-client clients/python
npm ci --ignore-scripts --prefix clients/javascript
(cd clients/javascript && npm pack --json --pack-destination ../../artifacts/javascript)
- name: Validate optional upgrade baseline inputs
id: baseline
env:
BASELINE_RUNTIME_WHEEL_URL: ${{ inputs.baseline_runtime_wheel_url }}
BASELINE_RUNTIME_WHEEL_SHA256: ${{ inputs.baseline_runtime_wheel_sha256 }}
run: |
python - <<'PY'
import os
url_supplied = bool(os.environ["BASELINE_RUNTIME_WHEEL_URL"].strip())
hash_supplied = bool(
os.environ["BASELINE_RUNTIME_WHEEL_SHA256"].strip()
)
if url_supplied != hash_supplied:
raise SystemExit(
"Supply both baseline wheel inputs or leave both empty."
)
with open(
os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8"
) as output:
output.write(
"enabled=" + ("true" if url_supplied else "false") + "\n"
)
print(
"python-runtime-upgrade-baseline="
+ ("supplied" if url_supplied else "not-supplied")
)
PY
- name: Fetch verified upgrade baseline
if: ${{ steps.baseline.outputs.enabled == 'true' }}
env:
BASELINE_RUNTIME_WHEEL_URL: ${{ inputs.baseline_runtime_wheel_url }}
BASELINE_RUNTIME_WHEEL_SHA256: ${{ inputs.baseline_runtime_wheel_sha256 }}
run: |
python - <<'PY'
import hashlib
import os
from pathlib import Path
import re
from urllib.parse import urlsplit
from urllib.request import urlopen
url = os.environ["BASELINE_RUNTIME_WHEEL_URL"].strip()
expected = os.environ["BASELINE_RUNTIME_WHEEL_SHA256"].strip().lower()
if expected.startswith("sha256:"):
expected = expected.removeprefix("sha256:")
if urlsplit(url).scheme != "https":
raise SystemExit("The baseline runtime wheel URL must use HTTPS.")
if not re.fullmatch(r"[0-9a-f]{64}", expected):
raise SystemExit("The baseline runtime wheel SHA-256 is invalid.")
name = Path(urlsplit(url).path).name
if not re.fullmatch(
r"vyral_runtime-0\.1\.\d+-py3-none-any\.whl",
name,
):
raise SystemExit(
"The baseline URL must name a portable 0.1.x runtime wheel."
)
with urlopen(url, timeout=60) as response:
content = response.read(64 * 1024 * 1024 + 1)
if len(content) > 64 * 1024 * 1024:
raise SystemExit("The baseline runtime wheel exceeds 64 MiB.")
actual = hashlib.sha256(content).hexdigest()
if actual != expected:
raise SystemExit(
f"Baseline SHA-256 mismatch: expected {expected}, found {actual}."
)
destination = Path("artifacts/baseline") / name
destination.parent.mkdir(parents=True, exist_ok=True)
destination.write_bytes(content)
print(f"baseline-runtime-wheel=ok sha256:{actual}")
PY
- name: Run packaged host qualifications
run: |
scripts/test-built-sdk-python-runtime.sh artifacts/runtime/*.whl artifacts/python-client/*.whl artifacts/javascript/*.tgz
scripts/verify-python-runtime-external-worker.sh artifacts/runtime/*.whl
VYRAL_PYTHON_MCP_CONFORMANCE_ARTIFACT_DIR=artifacts/qualification/python-mcp-conformance \
scripts/verify-python-runtime-mcp-conformance.sh artifacts/runtime/*.whl
python scripts/verify-python-runtime-security.py artifacts/runtime/*.whl --output artifacts/qualification/python-runtime-security.json
python scripts/benchmark-python-runtime.py --output artifacts/qualification/python-runtime-performance.json
- name: Run installed upgrade qualification
if: ${{ steps.baseline.outputs.enabled == 'true' }}
run: >-
python scripts/verify-python-runtime-upgrade.py
artifacts/baseline/*.whl
artifacts/runtime/*.whl
--output artifacts/qualification/python-runtime-upgrade.json
- name: Upload qualification evidence
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: python-runtime-qualification-${{ github.sha }}
path: artifacts
if-no-files-found: error
aggregate-platform-matrix:
name: Verify complete platform matrix
needs: portable-matrix
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
- name: Download platform receipts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: python-runtime-*-${{ github.sha }}
path: artifacts/platform-receipts
- name: Verify one consistent nine-cell matrix
run: |
python scripts/test-python-runtime-platform-matrix.py
python scripts/verify-python-runtime-platform-matrix.py \
artifacts/platform-receipts \
--output artifacts/qualification/python-runtime-platform-matrix.json
- name: Upload aggregate platform evidence
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: python-runtime-platform-matrix-${{ github.sha }}
path: artifacts/qualification/python-runtime-platform-matrix.json
if-no-files-found: error