Skip to content

Commit 1d8e8f8

Browse files
committed
Split version generation
Signed-off-by: Kemal Akkoyun <[email protected]>
1 parent 1cb9e2d commit 1d8e8f8

File tree

2 files changed

+168
-6
lines changed

2 files changed

+168
-6
lines changed
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: Generate Python (end-of-life versions)
2+
on:
3+
workflow_call:
4+
push:
5+
branches:
6+
- main
7+
- release
8+
paths:
9+
- ".github/workflows/generate-python.yml"
10+
- "pkg/python/**"
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
generate:
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 20
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
python-version: [
24+
2.7, 2.7.15, 2.7.16, 2.7.17, 2.7.18,
25+
3.3, 3.3.6, 3.3.7,
26+
3.4, 3.4.2, 3.4.3, 3.4.4, 3.4.5, 3.4.6, 3.4.7, 3.4.8, 3.4.9, 3.4.10,
27+
3.5.0, 3.5.1, 3.5.2, 3.5.3, 3.5.4, 3.5.5, 3.5.6, 3.5.7, 3.5.8, 3.5.9, 3.5.10,
28+
3.6.0, 3.6.1, 3.6.2, 3.6.3, 3.6.4, 3.6.5, 3.6.6, 3.6.7, 3.6.8, 3.6.9, 3.6.10, 3.6.11, 3.6.12, 3.6.13, 3.6.14, 3.6.15,
29+
3.7.0, 3.7.1, 3.7.2, 3.7.3, 3.7.4, 3.7.5, 3.7.6, 3.7.7, 3.7.8, 3.7.9, 3.7.10, 3.7.11, 3.7.12, 3.7.13, 3.7.14, 3.7.15, 3.7.16, 3.7.17,
30+
]
31+
arch: [amd64, arm64]
32+
steps:
33+
- name: Check out the code
34+
uses: actions/checkout@v4
35+
36+
- name: Install devbox
37+
uses: jetpack-io/[email protected]
38+
with:
39+
enable-cache: true
40+
41+
- name: Setup devbox
42+
run: devbox run -- echo "done!"
43+
44+
- name: Load devbox shellenv
45+
uses: HatsuneMiku3939/direnv-action@v1
46+
with:
47+
direnvVersion: 2.32.3
48+
49+
- name: Set up Go tool cache
50+
uses: actions/cache@v4
51+
with:
52+
path: ~/.devbox/go
53+
key: devbox-go-tools.cache-${{ runner.os }}-${{ runner.arch }}
54+
55+
- name: Build
56+
run: make build
57+
58+
- name: Set up QEMU
59+
uses: docker/setup-qemu-action@v3
60+
with:
61+
platforms: linux/amd64,linux/arm64
62+
63+
- name: Set up cache for downloaded files
64+
uses: actions/cache@v4
65+
with:
66+
path: python-binaries
67+
key: python-downloaded-${{ runner.os }}-${{ matrix.arch }}
68+
restore-keys: |
69+
python-downloaded-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.python-version }}
70+
71+
- name: Generate Python Offsets for ${{ matrix.python-version }} on ${{ matrix.arch }}
72+
run: |
73+
export python_version="${{ matrix.python-version }}"
74+
75+
if ! ls python-binaries/${{ matrix.arch }}/${{ matrix.python-version }}/libpython"${python_version%.*}"*.so.1.0 1> /dev/null 2>&1; then
76+
mkdir -p python-binaries/${{ matrix.arch }}/${{ matrix.python-version }}
77+
docker run --rm --platform "linux/${{ matrix.arch }}" -v "${PWD}"/python-binaries/${{ matrix.arch }}/${{ matrix.python-version }}:/tmp -w /tmp docker.io/library/python:${{ matrix.python-version }} bash -c 'cp /usr/local/lib/libpython"${python_version%.*}"*.so.1.0 /tmp' || exit 0 # (some containers of python do not have arm64 version)
78+
fi
79+
80+
mkdir -p offsets-python/${{ matrix.arch }}
81+
./structlayout -r python -v ${{ matrix.python-version }} -o offsets-python/${{ matrix.arch }} python-binaries/${{ matrix.arch }}/${{ matrix.python-version }}/libpython"${python_version%.*}"*.so.1.0
82+
83+
git add offsets-python
84+
85+
cp $(git diff --name-only --staged | xargs) offsets-python || echo "No new or modified files - offsets
86+
are up to date"
87+
88+
- name: Upload Offsets
89+
uses: actions/upload-artifact@v4
90+
with:
91+
if-no-files-found: ignore
92+
name: python-${{ matrix.arch }}-${{ matrix.python-version }}
93+
path: offsets-python
94+
retention-days: 1
95+
96+
merge-and-create-branch:
97+
runs-on: ubuntu-latest
98+
needs: generate
99+
permissions:
100+
contents: write
101+
pull-requests: write
102+
steps:
103+
- name: Check out the code
104+
uses: actions/checkout@v4
105+
106+
- name: Install devbox
107+
uses: jetpack-io/[email protected]
108+
with:
109+
enable-cache: true
110+
111+
- name: Setup devbox
112+
run: devbox run -- echo "done!"
113+
114+
- name: Load devbox shellenv
115+
uses: HatsuneMiku3939/direnv-action@v1
116+
with:
117+
direnvVersion: 2.32.3
118+
119+
- name: Set up Go tool cache
120+
uses: actions/cache@v4
121+
with:
122+
path: ~/.devbox/go
123+
key: devbox-go-tools.cache-${{ runner.os }}-${{ runner.arch }}
124+
125+
- name: Build
126+
run: make build
127+
128+
- name: Download all artifacts
129+
uses: actions/download-artifact@v4
130+
with:
131+
path: offsets-python
132+
merge-multiple: true
133+
134+
- name: Print the layout files
135+
run: tree offsets-python
136+
137+
- name: Merge the layout files
138+
run: |
139+
target_archs=(
140+
amd64
141+
arm64
142+
)
143+
144+
rm -rf pkg/python/layout
145+
rm -rf pkg/python/initialstate
146+
for arch in "${target_archs[@]}"; do
147+
mkdir -p pkg/python/layout/"${arch}"
148+
./mergelayout -o pkg/python/layout/"${arch}" offsets-python/"${arch}"/layout/python_*.yaml
149+
150+
mkdir -p pkg/python/initialstate"/${arch}"
151+
./mergelayout -o pkg/python/initialstate/"${arch}" offsets-python/"${arch}"/initialstate/python_*.yaml
152+
done
153+
154+
# If there are no changes (i.e. no diff exists with the checked-out base branch),
155+
# no pull request will be created and the action exits silently.
156+
- name: Create a pull-request
157+
if: github.event_name != 'pull_request'
158+
uses: peter-evans/create-pull-request@v6
159+
with:
160+
token: ${{ secrets.GITHUB_TOKEN }}
161+
commit-message: "chore: update python layouts"
162+
title: "chore: Update Python layouts"
163+
branch: update-python-offsets-${{ github.run_number }}
164+
add-paths: pkg/python/layout, pkg/python/initialstate
165+
base: main
166+
labels: chore
167+
draft: false
168+
delete-branch: true

.github/workflows/generate-python.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
python-version: [
24-
2.7, 2.7.15, 2.7.16, 2.7.17, 2.7.18,
25-
3.3, 3.3.6, 3.3.7,
26-
3.4, 3.4.2, 3.4.3, 3.4.4, 3.4.5, 3.4.6, 3.4.7, 3.4.8, 3.4.9, 3.4.10,
27-
3.5.0, 3.5.1, 3.5.2, 3.5.3, 3.5.4, 3.5.5, 3.5.6, 3.5.7, 3.5.8, 3.5.9, 3.5.10,
28-
3.6.0, 3.6.1, 3.6.2, 3.6.3, 3.6.4, 3.6.5, 3.6.6, 3.6.7, 3.6.8, 3.6.9, 3.6.10, 3.6.11, 3.6.12, 3.6.13, 3.6.14, 3.6.15,
29-
3.7.0, 3.7.1, 3.7.2, 3.7.3, 3.7.4, 3.7.5, 3.7.6, 3.7.7, 3.7.8, 3.7.9, 3.7.10, 3.7.11, 3.7.12, 3.7.13, 3.7.14, 3.7.15, 3.7.16, 3.7.17,
3024
3.8.0, 3.8.1, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.8.10, 3.8.11, 3.8.12, 3.8.13, 3.8.14, 3.8.15, 3.8.16, 3.8.17, 3.8.18, 3.8.19,
3125
3.9.0, 3.9.1, 3.9.2, 3.9.3, 3.9.4, 3.9.5, 3.9.6, 3.9.7, 3.9.8, 3.9.9, 3.9.10, 3.9.11, 3.9.12, 3.9.13, 3.9.14, 3.9.15, 3.9.16, 3.9.17, 3.9.18, 3.9.19,
3226
3.10.0, 3.10.1, 3.10.2, 3.10.3, 3.10.4, 3.10.5, 3.10.6, 3.10.7, 3.10.8, 3.10.9, 3.10.10, 3.10.11, 3.10.12, 3.10.13, 3.10.14,

0 commit comments

Comments
 (0)