Skip to content

Commit 1df060e

Browse files
itamaroclaude
andcommitted
Run the relocatability checks in GitHub Actions
Build CPython main on Ubuntu and macOS and run `relocatable.py test` with both strategies, daily and for each push and pull request. On macOS, the libraries that the system doesn't provide are built with `relocatable.py deps`. Failed checks don't fail the job, since some fail until CPython is fixed; the results go in the job summary and an uploaded JSON artifact. The job fails only if the build or the harness itself breaks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 38ef21a commit 1df060e

2 files changed

Lines changed: 106 additions & 0 deletions

File tree

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Relocatability
2+
3+
# Build CPython main and run `relocatable.py test` against it. Some checks
4+
# fail until CPython is fixed, so failed checks don't fail the job; the
5+
# results are in the job summary and the uploaded JSON. The job only fails
6+
# if the build or the harness itself breaks.
7+
8+
on:
9+
push:
10+
branches: [main]
11+
pull_request:
12+
schedule:
13+
# Daily, to track changes in CPython main.
14+
- cron: "17 6 * * *"
15+
workflow_dispatch:
16+
17+
permissions:
18+
contents: read
19+
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.ref }}
22+
cancel-in-progress: true
23+
24+
jobs:
25+
test:
26+
name: ${{ matrix.os }}
27+
# Forks get the schedule too; only run it here.
28+
if: github.event_name != 'schedule' || github.repository == 'python/prebuilt-cpython'
29+
runs-on: ${{ matrix.os }}
30+
timeout-minutes: 60
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
os: [ubuntu-latest, macos-latest]
35+
steps:
36+
- uses: actions/checkout@v5
37+
with:
38+
path: prebuilt-cpython
39+
persist-credentials: false
40+
- uses: actions/checkout@v5
41+
with:
42+
repository: python/cpython
43+
path: cpython
44+
persist-credentials: false
45+
- uses: actions/setup-python@v6
46+
with:
47+
python-version: "3.14"
48+
49+
- name: Install build dependencies (Linux)
50+
if: runner.os == 'Linux'
51+
run: |
52+
sudo apt-get update
53+
sudo apt-get install -y build-essential pkg-config patchelf \
54+
libbz2-dev libffi-dev libgdbm-dev liblzma-dev libncurses-dev \
55+
libreadline-dev libsqlite3-dev libssl-dev libzstd-dev uuid-dev \
56+
zlib1g-dev
57+
- name: Install build tools (macOS)
58+
if: runner.os == 'macOS'
59+
run: brew install pkg-config
60+
- name: Build dependencies (macOS)
61+
if: runner.os == 'macOS'
62+
working-directory: cpython
63+
run: python ../prebuilt-cpython/relocatable.py deps
64+
65+
- name: Record the CPython commit
66+
working-directory: cpython
67+
run: git log -1 --format='CPython main at %h (%cs)' | tee -a "$GITHUB_STEP_SUMMARY"
68+
- name: Configure
69+
working-directory: cpython
70+
run: python ../prebuilt-cpython/relocatable.py configure ${{ runner.os == 'macOS' && '--deps-dir deps' || '' }}
71+
- name: Build
72+
working-directory: cpython
73+
run: python ../prebuilt-cpython/relocatable.py make
74+
75+
- name: Test (patch)
76+
working-directory: cpython
77+
continue-on-error: true
78+
run: python ../prebuilt-cpython/relocatable.py test --strategy patch --format json > ../results-patch.json
79+
- name: Test (origin)
80+
working-directory: cpython
81+
continue-on-error: true
82+
run: python ../prebuilt-cpython/relocatable.py test --strategy origin --format json > ../results-origin.json
83+
84+
- name: Summarize
85+
shell: python
86+
run: |
87+
import json, os
88+
89+
lines = []
90+
for strategy in ("patch", "origin"):
91+
# Fails the job if the harness crashed instead of reporting.
92+
with open(f"results-{strategy}.json") as file:
93+
results = json.load(file)
94+
lines += [f"### `--strategy {strategy}`", "", "| Check | Status | Summary |", "|---|---|---|"]
95+
lines += [f"| `{r['name']}` | {r['status']} | {r['summary']} |" for r in results]
96+
lines.append("")
97+
with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as summary:
98+
summary.write("\n".join(lines) + "\n")
99+
- uses: actions/upload-artifact@v4
100+
if: ${{ !cancelled() }}
101+
with:
102+
name: relocatability-${{ matrix.os }}
103+
path: results-*.json
104+
if-no-files-found: ignore

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ Each check prints `PASS`, `FAIL`, or `SKIP` (in color on a terminal, unless `NO_
7676

7777
Use `--strategy origin` to gather with `--origin` (the default is `--patch`), `--full` to also run `python -m test --fast-ci`, `--work-dir DIR` to keep the temporary files (including `gather.log`, the `make install` output), and `--format json` for JSON output.
7878

79+
The Relocatability GitHub Actions workflow runs `test` with both strategies against CPython `main` on Linux and macOS, daily and for each pull request. Each run's summary lists the results, and the JSON is attached to the run.
80+
7981
If the build wasn't configured by `relocatable.py configure`, its `--prefix` is left alone and treated as the old location. If that directory still exists, the `distribution.isolation` check fails, because the moved build might be using files from it without anyone noticing.
8082

8183
## Project Representatives

0 commit comments

Comments
 (0)