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