Repository navigation
279 lines (246 loc) · 12.3 KB
/
Copy pathlinux_qemu.yml
File metadata and controls
279 lines (246 loc) · 12.3 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
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# To update pinned container digests and uv version: not handled by Dependabot.
# Containers: change tag and get new digest with
# docker pull <image>:<tag> && docker inspect --format='{{index .RepoDigests 0}}' <image>:<tag>
# uv: change version in URL and update checksum (curl -sL <url> | sha256sum)
#
# Meson's Python module doesn't support crosscompiling,
# and python dependencies may be another potential hurdle.
# There might also be a need to run runtime tests during configure time.
#
# The recommended practice is to rely on Docker to provide the x86_64 crosscompile toolchain,
# enabling native execution via binfmt.
#
# In simpler terms, everything except the crosscompile toolchain will be emulated.
name: Linux Qemu tests
on:
pull_request:
branches:
- main
- maintenance/**
paths-ignore:
- '**.pyi'
- '**.md'
- '**.rst'
- 'tools/stubtest/**'
workflow_dispatch:
defaults:
run:
shell: bash
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
env:
APT_TIMEOUT_MINUTES: 15
jobs:
linux_qemu:
# Only workflow_dispatch is enabled on forks.
# To enable this job and subsequent jobs on a fork for other events, comment out:
if: github.repository == 'numpy/numpy' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-22.04
continue-on-error: true
strategy:
fail-fast: false
matrix:
BUILD_PROP:
- [
"riscv64",
"riscv64-linux-gnu",
"riscv64/ubuntu:22.04",
"-Dallow-noblas=true",
"test_kind or test_multiarray or test_simd or test_umath or test_ufunc",
"riscv64"
]
env:
TOOLCHAIN_NAME: ${{ matrix.BUILD_PROP[1] }}
DOCKER_CONTAINER: ${{ matrix.BUILD_PROP[2] }}
MESON_OPTIONS: ${{ matrix.BUILD_PROP[3] }}
RUNTIME_TEST_FILTER: ${{ matrix.BUILD_PROP[4] }}
ARCH: ${{ matrix.BUILD_PROP[5] }}
TERM: xterm-256color
name: "${{ matrix.BUILD_PROP[0] }}"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: recursive
fetch-tags: true
persist-credentials: false
- name: Initialize binfmt_misc for qemu-user-static
run: |
docker run --rm --privileged tonistiigi/binfmt:qemu-v9.2.2-52@sha256:1b804311fe87047a4c96d38b4b3ef6f62fca8cd125265917a9e3dc3c996c39e6 --install all
- name: Install GCC cross-compilers
timeout-minutes: ${{ fromJSON(env.APT_TIMEOUT_MINUTES) }}
run: |
sudo apt update
sudo apt install -y ninja-build gcc-${TOOLCHAIN_NAME} g++-${TOOLCHAIN_NAME} gfortran-${TOOLCHAIN_NAME}
- name: Cache docker container
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: container-cache
with:
path: ~/docker_${{ matrix.BUILD_PROP[1] }}
key: container-${{ runner.os }}-${{ matrix.BUILD_PROP[1] }}-${{ matrix.BUILD_PROP[2] }}-${{ hashFiles('pyproject.toml') }}
- name: Creates new container
if: steps.container-cache.outputs.cache-hit != 'true'
run: |
docker run --platform=linux/${ARCH} --name the_container --interactive \
-v /:/host -v $(pwd):/numpy ${DOCKER_CONTAINER} /bin/bash -c "
# timeout-minutes can't reach inside 'docker run', so bound apt directly
timeout ${APT_TIMEOUT_MINUTES}m apt update &&
timeout ${APT_TIMEOUT_MINUTES}m apt install -y cmake git curl ca-certificates &&
# Fix expired Microsoft/azure-cli repo key (affects riscv64/ubuntu:22.04)
mkdir -p /etc/apt/keyrings &&
curl -sLS https://packages.microsoft.com/keys/microsoft.asc | \
gpg --dearmor | \
tee /etc/apt/keyrings/microsoft.gpg > /dev/null &&
chmod go+r /etc/apt/keyrings/microsoft.gpg &&
curl -LsSf https://astral.sh/uv/0.13.5/install.sh -o /tmp/uv-install.sh &&
echo '1c6e7f025499664633ac2dce43a210800510e9ef0625c52e034a8afdf8bf177a /tmp/uv-install.sh' | sha256sum -c - &&
sh /tmp/uv-install.sh &&
export PATH="/root/.local/bin:$PATH" &&
mkdir -p /lib64 && ln -s /host/lib64/ld-* /lib64/ &&
ln -s /host/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu &&
rm -rf /usr/${TOOLCHAIN_NAME} && ln -s /host/usr/${TOOLCHAIN_NAME} /usr/${TOOLCHAIN_NAME} &&
rm -rf /usr/lib/gcc/${TOOLCHAIN_NAME} && ln -s /host/usr/lib/gcc-cross/${TOOLCHAIN_NAME} /usr/lib/gcc/${TOOLCHAIN_NAME} &&
rm -f /usr/bin/gcc && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-gcc /usr/bin/gcc &&
rm -f /usr/bin/g++ && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-g++ /usr/bin/g++ &&
rm -f /usr/bin/gfortran && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-gfortran /usr/bin/gfortran &&
rm -f /usr/bin/ar && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ar /usr/bin/ar &&
rm -f /usr/bin/as && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-as /usr/bin/as &&
rm -f /usr/bin/ld && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ld /usr/bin/ld &&
rm -f /usr/bin/ld.bfd && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ld.bfd /usr/bin/ld.bfd &&
rm -f /usr/bin/ninja && ln -s /host/usr/bin/ninja /usr/bin/ninja &&
git config --global --add safe.directory /numpy &&
uv venv --python 3.12 .venv &&
source .venv/bin/activate &&
# Install build requirements, apart from ninja.
# The host ninja is used for the build
echo ninja > exclude.txt && uv pip install --group /numpy/pyproject.toml:dev-cli --excludes exclude.txt &&
uv pip install --group /numpy/pyproject.toml:test-extending --excludes exclude.txt &&
rm -f /usr/local/bin/ninja && mkdir -p /usr/local/bin && ln -s /host/usr/bin/ninja /usr/local/bin/ninja
"
docker commit the_container the_container
mkdir -p "~/docker_${TOOLCHAIN_NAME}"
docker save -o "~/docker_${TOOLCHAIN_NAME}/the_container.tar" the_container
- name: Load container from cache
if: steps.container-cache.outputs.cache-hit == 'true'
run: docker load -i "~/docker_${TOOLCHAIN_NAME}/the_container.tar"
- name: Meson Build
run: |
docker run --rm --platform=linux/${ARCH} -e "TERM=xterm-256color" \
-v $(pwd):/numpy -v /:/host the_container \
/bin/script -e -q -c "/bin/bash --noprofile --norc -eo pipefail -c '
source .venv/bin/activate && cd /numpy && spin build --clean -- ${MESON_OPTIONS}
'"
- name: Meson Log
if: always()
run: 'cat build/meson-logs/meson-log.txt'
- name: Run Tests
run: |
docker run --rm --platform=linux/${ARCH} -e "TERM=xterm-256color" \
-v $(pwd):/numpy -v /:/host the_container \
/bin/script -e -q -c "/bin/bash --noprofile --norc -eo pipefail -c '
export F90=/usr/bin/gfortran
source .venv/bin/activate && cd /numpy && spin test -- --timeout=600 --durations=10 -k \"${RUNTIME_TEST_FILTER}\"
'"
linux_loongarch64_qemu:
# Only workflow_dispatch is enabled on forks.
# To enable this job and subsequent jobs on a fork for other events, comment out:
if: github.repository == 'numpy/numpy' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-24.04
continue-on-error: true
strategy:
fail-fast: false
matrix:
BUILD_PROP:
- [
"loongarch64",
"loongarch64-linux-gnu",
"cnclarechen/numpy-loong64-debian:v1@sha256:1f35e614955fa9cba890172a73a068120f25f1cfcd59ad5521995e37cb7e2c3f",
"-Dallow-noblas=true",
"test_kind or test_multiarray or test_simd or test_umath or test_ufunc",
"loong64"
]
env:
TOOLCHAIN_NAME: ${{ matrix.BUILD_PROP[1] }}
DOCKER_CONTAINER: ${{ matrix.BUILD_PROP[2] }}
MESON_OPTIONS: ${{ matrix.BUILD_PROP[3] }}
RUNTIME_TEST_FILTER: ${{ matrix.BUILD_PROP[4] }}
ARCH: ${{ matrix.BUILD_PROP[5] }}
TERM: xterm-256color
name: "${{ matrix.BUILD_PROP[0] }}"
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: recursive
fetch-tags: true
persist-credentials: false
- name: Initialize binfmt_misc for qemu-user-static
run: |
docker run --rm --privileged tonistiigi/binfmt:qemu-v10.0.4-56@sha256:30cc9a4d03765acac9be2ed0afc23af1ad018aed2c28ea4be8c2eb9afe03fbd1 --install all
- name: Install GCC cross-compilers
timeout-minutes: ${{ fromJSON(env.APT_TIMEOUT_MINUTES) }}
run: |
sudo apt update
sudo apt install -y ninja-build gcc-14-${TOOLCHAIN_NAME} g++-14-${TOOLCHAIN_NAME} gfortran-14-${TOOLCHAIN_NAME}
- name: Cache docker container
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: container-cache
with:
path: ~/docker_${{ matrix.BUILD_PROP[1] }}
key: container-${{ runner.os }}-${{ matrix.BUILD_PROP[1] }}-${{ matrix.BUILD_PROP[2] }}-${{ hashFiles('pyproject.toml') }}
- name: Creates new container
if: steps.container-cache.outputs.cache-hit != 'true'
run: |
docker run --platform=linux/${ARCH} --name the_container --interactive \
-v /:/host -v $(pwd):/numpy ${DOCKER_CONTAINER} /bin/bash -c "
mkdir -p /lib64 && ln -s /host/lib64/ld-* /lib64/ &&
ln -s /host/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu &&
ln -s /host/usr/${TOOLCHAIN_NAME} /usr/${TOOLCHAIN_NAME} &&
ln -s /host/usr/lib/gcc-cross/${TOOLCHAIN_NAME} /usr/lib/gcc/${TOOLCHAIN_NAME} &&
mkdir -p /usr/libexec/gcc &&
rm -rf /usr/libexec/gcc/${TOOLCHAIN_NAME} && ln -s /host/usr/libexec/gcc/${TOOLCHAIN_NAME} /usr/libexec/gcc/${TOOLCHAIN_NAME} &&
rm -f /usr/bin/gcc && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-gcc-14 /usr/bin/gcc &&
rm -f /usr/bin/g++ && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-g++-14 /usr/bin/g++ &&
rm -f /usr/bin/gfortran && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-gfortran-14 /usr/bin/gfortran &&
rm -f /usr/bin/ar && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ar /usr/bin/ar &&
rm -f /usr/bin/as && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-as /usr/bin/as &&
rm -f /usr/bin/ld && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ld /usr/bin/ld &&
rm -f /usr/bin/ld.bfd && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ld.bfd /usr/bin/ld.bfd &&
rm -f /usr/bin/ninja && ln -s /host/usr/bin/ninja /usr/bin/ninja &&
git config --global --add safe.directory /numpy &&
python -m pip install --break-system-packages \
--extra-index-url https://mirrors.loong64.com/pypi/simple \
--only-binary=":all:" uv &&
export PATH="/root/.local/bin:$PATH" &&
uv venv --python 3.12 .venv &&
source .venv/bin/activate &&
# Install build requirements, apart from ninja.
# The host ninja is used for the build
echo ninja > exclude.txt && uv pip install --group /numpy/pyproject.toml:dev-cli --excludes exclude.txt &&
uv pip install --group /numpy/pyproject.toml:test-extending --excludes exclude.txt &&
rm -f /usr/local/bin/ninja && mkdir -p /usr/local/bin && ln -s /host/usr/bin/ninja /usr/local/bin/ninja
"
docker commit the_container the_container
mkdir -p "~/docker_${TOOLCHAIN_NAME}"
docker save -o "~/docker_${TOOLCHAIN_NAME}/the_container.tar" the_container
- name: Load container from cache
if: steps.container-cache.outputs.cache-hit == 'true'
run: docker load -i "~/docker_${TOOLCHAIN_NAME}/the_container.tar"
- name: Meson Build
run: |
docker run --rm --platform=linux/${ARCH} -e "TERM=xterm-256color" \
-v $(pwd):/numpy -v /:/host the_container \
/bin/script -e -q -c "/bin/bash --noprofile --norc -eo pipefail -c '
source .venv/bin/activate && cd /numpy/ && spin build --clean -- ${MESON_OPTIONS}
'"
- name: Meson Log
if: always()
run: 'cat build/meson-logs/meson-log.txt'
- name: Run Tests
run: |
docker run --rm --platform=linux/${ARCH} -e "TERM=xterm-256color" \
-v $(pwd):/numpy -v /:/host the_container \
/bin/script -e -q -c "/bin/bash --noprofile --norc -eo pipefail -c '
source .venv/bin/activate && cd /numpy && spin test -- -k \"${RUNTIME_TEST_FILTER}\"
'"