Skip to content

Commit 7cce74c

Browse files
committed
ci: authenticate installer requests and select available uv builds
1 parent 745e729 commit 7cce74c

2 files changed

Lines changed: 54 additions & 13 deletions

File tree

‎.github/select-uv-version.py‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""Choose a current security-only Python 3.10 build for the installation smoke test."""
2+
import json
3+
import os
4+
import platform
5+
import urllib.request
6+
7+
os_name = "windows" if platform.system() == "Windows" else "linux"
8+
request = urllib.request.Request(
9+
"https://vault.vfox.dev/python/uv-build?os=" + os_name + "&arch=x86_64",
10+
headers={"User-Agent": "vfox"},
11+
)
12+
with urllib.request.urlopen(request, timeout=30) as response:
13+
items = json.load(response)["items"]
14+
versions = set()
15+
for item in items:
16+
version = item.get("version", "")
17+
parts = version.split(".")
18+
if (item.get("implementation") == "cpython"
19+
and item.get("variant", "default") == "default"
20+
and len(parts) == 3 and parts[:2] == ["3", "10"]
21+
and all(part.isdigit() for part in parts)
22+
and item.get("filename", "").endswith((".tar.gz", ".zip"))):
23+
versions.add(version)
24+
if not versions:
25+
raise RuntimeError("No Python 3.10 uv-build installer is available for " + os_name)
26+
version = max(versions, key=lambda value: tuple(map(int, value.split("."))))
27+
with open(os.environ["GITHUB_ENV"], "a", encoding="utf-8") as output:
28+
output.write("VFOX_TEST_UV_VERSION=" + version + "\n")
29+
print("Testing uv-build Python " + version + " on " + os_name)

‎.github/workflows/vfox-test.yaml‎

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ on:
99
tags: ["v*"]
1010

1111
permissions:
12-
contents: write
12+
contents: read
1313

1414
jobs:
1515
test-on-linux:
1616
runs-on: ${{ matrix.os }}
1717
strategy:
18+
fail-fast: false
1819
matrix:
1920
os: [ubuntu-latest]
2021
python-version: [3.12.2]
@@ -33,6 +34,8 @@ jobs:
3334
exclusions: "*.git* manifest.json"
3435

3536
- name: Install vfox
37+
env:
38+
GITHUB_TOKEN: ${{ github.token }}
3639
shell: bash
3740
run: |
3841
for _ in {1..10}; do
@@ -64,24 +67,28 @@ jobs:
6467
exit 1
6568
fi
6669
67-
- name: Install Python 3.10.20 with uv-build
70+
- name: Select an available uv-build Python 3.10 version
71+
if: matrix.mirror == ''
72+
run: python .github/select-uv-version.py
73+
74+
- name: Install Python 3.10 with uv-build
6875
if: matrix.mirror == ''
6976
env:
7077
VFOX_PYTHON_USE_UV_BUILD: "1"
7178
run: |
7279
eval "$(vfox activate bash)"
73-
vfox install python@3.10.20
74-
vfox use -g python@3.10.20
80+
vfox install python@"$VFOX_TEST_UV_VERSION"
81+
vfox use -g python@"$VFOX_TEST_UV_VERSION"
7582
vfox current
7683
77-
- name: Check uv-build python 3.10.20
84+
- name: Check uv-build python 3.10
7885
if: matrix.mirror == ''
7986
run: |
8087
eval "$(vfox activate bash)"
8188
python_version=$(python -c 'import sys;print(sys.version)')
8289
echo "$python_version"
8390
84-
if [[ ! $python_version == 3.10.20* ]]; then
91+
if [[ ! $python_version == "$VFOX_TEST_UV_VERSION"* ]]; then
8592
exit 1
8693
fi
8794
@@ -94,6 +101,7 @@ jobs:
94101
shell: pwsh
95102
runs-on: ${{ matrix.os }}
96103
strategy:
104+
fail-fast: false
97105
matrix:
98106
os: [windows-latest]
99107
python-version: [3.12.2]
@@ -147,17 +155,21 @@ jobs:
147155
exit 1
148156
}
149157
150-
- name: Install Python 3.10.20 with uv-build
158+
- name: Select an available uv-build Python 3.10 version
159+
if: matrix.mirror == ''
160+
run: python .github/select-uv-version.py
161+
162+
- name: Install Python 3.10 with uv-build
151163
if: runner.os == 'Windows' && matrix.mirror == ''
152164
env:
153165
VFOX_PYTHON_USE_UV_BUILD: "1"
154166
run: |
155167
Invoke-Expression "$(vfox activate pwsh)"
156-
vfox install python@3.10.20
168+
vfox install "python@$env:VFOX_TEST_UV_VERSION"
157169
if ($LASTEXITCODE -ne 0) {
158170
exit $LASTEXITCODE
159171
}
160-
vfox use -g python@3.10.20
172+
vfox use -g "python@$env:VFOX_TEST_UV_VERSION"
161173
if ($LASTEXITCODE -ne 0) {
162174
exit $LASTEXITCODE
163175
}
@@ -169,19 +181,19 @@ jobs:
169181
}
170182
Write-Output $python_version
171183
172-
if ($python_version -notlike "3.10.20*") {
173-
Write-Error "expected uv-build python 3.10.20, got $python_version"
184+
if ($python_version -notlike "$env:VFOX_TEST_UV_VERSION*") {
185+
Write-Error "expected uv-build python $env:VFOX_TEST_UV_VERSION, got $python_version"
174186
exit 1
175187
}
176188
177-
- name: Check uv-build python 3.10.20
189+
- name: Check uv-build python 3.10
178190
if: runner.os == 'Windows' && matrix.mirror == ''
179191
run: |
180192
Invoke-Expression "$(vfox activate pwsh)"
181193
$python_version = $(python -c 'import sys;print(sys.version)')
182194
Write-Output $python_version
183195
184-
if ($python_version -notlike "3.10.20*") {
196+
if ($python_version -notlike "$env:VFOX_TEST_UV_VERSION*") {
185197
exit 1
186198
}
187199

0 commit comments

Comments
 (0)