-
Notifications
You must be signed in to change notification settings - Fork 1
172 lines (145 loc) · 6.24 KB
/
generate-python.yml
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Generate Python
on:
workflow_call:
push:
branches:
- main
- release
paths:
- ".github/workflows/generate-python.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
generate:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
python-version: [
2.7.8, 2.7.9, 2.7.10, 2.7.11, 2.7.12, 2.7.13, 2.7.14, 2.7.15, 2.7.16, 2.7.17, 2.7.18,
3.3.6, 3.3.7,
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,
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,
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,
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,
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.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.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.11.0, 3.11.1, 3.11.2, 3.11.3, 3.11.4, 3.11.5, 3.11.6, 3.11.7, 3.11.8
]
arch: [amd64, arm64]
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Install devbox
uses: jetpack-io/[email protected]
with:
enable-cache: true
- name: Setup devbox
run: devbox run -- echo "done!"
- name: Load devbox shellenv
uses: HatsuneMiku3939/direnv-action@v1
with:
direnvVersion: 2.32.3
- name: Set up Go tool cache
uses: actions/cache@v4
with:
path: ~/.devbox/go
key: devbox-go-tools.cache-${{ runner.os }}-${{ runner.arch }}
- name: Build
run: make build
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Set up cache for downloaded files
uses: actions/cache@v4
with:
path: python-binaries
key: python-downloaded-${{ runner.os }}-${{ matrix.arch }}
restore-keys: |
python-downloaded-${{ runner.os }}-${{ matrix.arch }}-${{ matrix.python-version }}
python-downloaded-${{ runner.os }}-${{ matrix.arch }}
- name: Generate Python Offsets for ${{ matrix.python-version }} on ${{ matrix.arch }}
run: |
export python_version="${{ matrix.python-version }}"
if ! ls python-binaries/${{ matrix.arch }}/${{ matrix.python-version }}/libpython"${python_version%.*}"*.so.1.0 1> /dev/null 2>&1; then
mkdir -p python-binaries/${{ matrix.arch }}/${{ matrix.python-version }}
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)
fi
mkdir -p offsets-python/${{ matrix.arch }}
./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
git add offsets-python
cp $(git diff --name-only --staged | xargs) offsets-python || echo "No new or modified files - offsets
are up to date"
- name: Upload Offsets
uses: actions/upload-artifact@v4
with:
if-no-files-found: ignore
name: python-${{ matrix.arch }}-${{ matrix.python-version }}
path: offsets-python
retention-days: 1
merge-and-create-branch:
runs-on: ubuntu-latest
needs: generate
permissions:
contents: write
pull-requests: write
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Install devbox
uses: jetpack-io/[email protected]
with:
enable-cache: true
- name: Setup devbox
run: devbox run -- echo "done!"
- name: Load devbox shellenv
uses: HatsuneMiku3939/direnv-action@v1
with:
direnvVersion: 2.32.3
- name: Set up Go tool cache
uses: actions/cache@v4
with:
path: ~/.devbox/go
key: devbox-go-tools.cache-${{ runner.os }}-${{ runner.arch }}
- name: Build
run: make build
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: offsets-python
merge-multiple: true
- name: Print the layout files
run: tree offsets-python
- name: Merge the layout files
run: |
target_archs=(
amd64
arm64
)
rm -rf pkg/python/layout
rm -rf pkg/python/initialstate
for arch in "${target_archs[@]}"; do
mkdir -p pkg/python/layout/"${arch}"
./mergelayout -o pkg/python/layout/"${arch}" offsets-python/"${arch}"/layout/python_*.yaml
mkdir -p pkg/python/initialstate"/${arch}"
./mergelayout -o pkg/python/initialstate/"${arch}" offsets-python/"${arch}"/initialstate/python_*.yaml
done
# If there are no changes (i.e. no diff exists with the checked-out base branch),
# no pull request will be created and the action exits silently.
- name: Create a pull-request
if: github.event_name != 'pull_request'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: update python layouts"
title: "chore: Update Python layouts"
branch: update-python-offsets-${{ github.run_number }}
add-paths: pkg/python/layout, pkg/python/initialstate
base: main
labels: chore
draft: false
delete-branch: true