Repository navigation
141 lines (130 loc) · 5.21 KB
/
Copy pathreusable-build.yml
File metadata and controls
141 lines (130 loc) · 5.21 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: Reusable build
# Build CPython and run `relocatable.py test` against it. Some checks fail
# until CPython is fixed, so failed checks don't fail the job; the results
# are in the job summary and the uploaded JSON. The job only fails if the
# build or the harness itself breaks.
on:
workflow_call:
inputs:
repository:
description: CPython repository to build
type: string
default: python/cpython
ref:
description: Branch, tag or commit to build (default branch if empty)
type: string
default: ""
artifacts:
description: Also gather the build and upload it as an artifact
type: boolean
default: false
permissions:
contents: read
jobs:
build:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v7
with:
path: prebuilt-cpython
persist-credentials: false
- uses: actions/checkout@v7
with:
repository: ${{ inputs.repository }}
ref: ${{ inputs.ref }}
path: cpython
persist-credentials: false
- uses: actions/setup-python@v7
with:
python-version: "3.x"
- name: Install build dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y build-essential pkg-config patchelf \
libbz2-dev libffi-dev libgdbm-dev liblzma-dev libncurses-dev \
libreadline-dev libsqlite3-dev libssl-dev libzstd-dev uuid-dev \
zlib1g-dev
- name: Install build tools (macOS)
if: runner.os == 'macOS'
run: brew install pkg-config
- name: Build dependencies (macOS)
if: runner.os == 'macOS'
working-directory: cpython
run: python ../prebuilt-cpython/relocatable.py deps
- name: Record the CPython commit
id: commit
working-directory: cpython
env:
REPOSITORY: ${{ inputs.repository }}
run: |
git log -1 --format="$REPOSITORY at %h (%cs)" | tee -a "$GITHUB_STEP_SUMMARY"
os=$(uname -s | tr '[:upper:]' '[:lower:]')
echo "name=cpython-$(git rev-parse --short=12 HEAD)-$os-$(uname -m)" >> "$GITHUB_OUTPUT"
- name: Configure
working-directory: cpython
run: python ../prebuilt-cpython/relocatable.py configure ${{ runner.os == 'macOS' && '--deps-dir deps' || '' }}
- name: Build
working-directory: cpython
run: python ../prebuilt-cpython/relocatable.py make
- name: Test
working-directory: cpython
continue-on-error: true
run: python ../prebuilt-cpython/relocatable.py test --format json > ../results.json
# `--relative-rpath` only changes ELF files.
- name: Test (relative rpath)
if: runner.os == 'Linux'
working-directory: cpython
continue-on-error: true
run: python ../prebuilt-cpython/relocatable.py test --relative-rpath --format json > ../results-relative-rpath.json
- name: Test (no fixup)
working-directory: cpython
continue-on-error: true
run: python ../prebuilt-cpython/relocatable.py test --no-fixup --format json > ../results-no-fixup.json
- name: Summarize
shell: python
run: |
import json, os
colours = {"PASS": "🟢", "FAIL": "🔴", "SKIP": "🟡"}
lines = []
tables = {"test": "results.json", "test --no-fixup": "results-no-fixup.json"}
if os.environ["RUNNER_OS"] == "Linux":
tables["test --relative-rpath"] = "results-relative-rpath.json"
for command, filename in tables.items():
# Fails the job if the harness crashed instead of reporting.
with open(filename) as file:
results = json.load(file)
lines += [f"### `{command}`", "", "| Check | Status | Summary |", "|---|---|---|"]
lines += [f"| `{r['name']}` | {colours[r['status']]} {r['status']} | {r['summary']} |" for r in results]
lines.append("")
with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as summary:
summary.write("\n".join(lines) + "\n")
- uses: actions/upload-artifact@v7
if: ${{ !cancelled() }}
with:
name: relocatability-${{ matrix.os }}
path: results*.json
if-no-files-found: ignore
# fixup.py goes with the tree. The tarball keeps the symlinks and file
# modes that the artifact zip drops.
- name: Gather
if: inputs.artifacts
working-directory: cpython
env:
NAME: ${{ steps.commit.outputs.name }}
run: |
python ../prebuilt-cpython/relocatable.py gather --output "$GITHUB_WORKSPACE/$NAME/python"
cp ../prebuilt-cpython/fixup.py "$GITHUB_WORKSPACE/$NAME/"
tar -C "$GITHUB_WORKSPACE" -czf "$GITHUB_WORKSPACE/$NAME.tar.gz" "$NAME"
- uses: actions/upload-artifact@v7
if: inputs.artifacts
with:
name: ${{ steps.commit.outputs.name }}
path: ${{ steps.commit.outputs.name }}.tar.gz
if-no-files-found: error