Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 30c232d

Browse files
committed
CI: Provides cross-compile builds for armhf, ppc64le, and s390x
1 parent e8e523f commit 30c232d

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

.github/workflows/linux_qemu.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Meson's Python module doesn't support crosscompiling,
2+
# and python dependencies may be another potential hurdle.
3+
# There might also be a need to run runtime tests during configure time.
4+
#
5+
# The recommended practice is to rely on Docker to provide the x86_64 crosscompile toolchain,
6+
# enabling native execution via binfmt.
7+
#
8+
# In simpler terms, everything except the crosscompile toolchain will be emulated.
9+
10+
name: Test Linux Qemu
11+
12+
on:
13+
pull_request:
14+
branches:
15+
- main
16+
- maintenance/**
17+
18+
defaults:
19+
run:
20+
shell: bash
21+
22+
concurrency:
23+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
meson_spin:
28+
if: "github.repository == 'numpy/numpy'"
29+
runs-on: ubuntu-22.04
30+
strategy:
31+
matrix:
32+
ARCH: [
33+
[
34+
"arm-linux-gnueabihf",
35+
"arm32v7/ubuntu:22.04",
36+
"test_kind or test_simd"
37+
],
38+
]
39+
env:
40+
TOOLCHAIN_NAME: ${{ matrix.ARCH[0] }}
41+
DOCKER_CONTAINER: ${{ matrix.ARCH[1] }}
42+
RUNTIME_TEST_FILTER: ${{ matrix.ARCH[2] }}
43+
44+
name: "Test Linux Qemu(${matrix.ARCH[0]})"
45+
steps:
46+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
47+
with:
48+
submodules: recursive
49+
fetch-depth: 0
50+
51+
- name: Initialize binfmt_misc for qemu-user-static
52+
run: |
53+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
54+
55+
- name: Creates new container
56+
run: |
57+
sudo apt update
58+
sudo apt install -y ninja-build gcc-${TOOLCHAIN_NAME} g++-${TOOLCHAIN_NAME} gfortran-${TOOLCHAIN_NAME}
59+
docker run --name the_container --interactive -v /:/host -v $(pwd):/numpy ${DOCKER_CONTAINER} /bin/bash -c "
60+
apt update &&
61+
apt install -y git python3 python-is-python3 python3-dev python3-pip &&
62+
ln -s /host/lib64 /lib64 &&
63+
ln -s /host/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu &&
64+
rm -rf /usr/${TOOLCHAIN_NAME} && ln -s /host/usr/${TOOLCHAIN_NAME} /usr/${TOOLCHAIN_NAME} &&
65+
rm -rf /usr/lib/gcc/${TOOLCHAIN_NAME} && ln -s /host/usr/lib/gcc-cross/${TOOLCHAIN_NAME} /usr/lib/gcc/${TOOLCHAIN_NAME} &&
66+
rm -f /usr/bin/gcc && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-gcc /usr/bin/gcc &&
67+
rm -f /usr/bin/g++ && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-g++ /usr/bin/g++ &&
68+
rm -f /usr/bin/gfortran && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-gfortran /usr/bin/gfortran &&
69+
rm -f /usr/bin/ar && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ar /usr/bin/ar &&
70+
rm -f /usr/bin/as && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-as /usr/bin/as &&
71+
rm -f /usr/bin/ld && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ld /usr/bin/ld &&
72+
rm -f /usr/bin/ld.bfd && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ld.bfd /usr/bin/ld.bfd &&
73+
rm -f /usr/bin/ninja && ln -s /host/usr/bin/ninja /usr/bin/ninja &&
74+
python -m pip install meson-python>=0.13.1 Cython>=3.0 wheel==0.38.1 spin==0.5 &&
75+
python -m pip install pytest pytest-xdist hypothesis typing_extensions
76+
"
77+
docker commit the_container the_container
78+
79+
- name: Build
80+
run: |
81+
sudo docker run --name the_build --interactive -v $(pwd):/numpy -v /:/host the_container /bin/bash -c "
82+
uname -a &&
83+
gcc --version &&
84+
g++ --version &&
85+
python --version &&
86+
git config --global --add safe.directory /numpy
87+
cd /numpy &&
88+
spin build --clean -- -Dallow-noblas=true
89+
"
90+
docker commit the_build the_build
91+
92+
- name: Meson Log
93+
if: failure()
94+
run: 'cat build/meson-logs/meson-log.txt'
95+
96+
- name: Run Tests
97+
run: |
98+
docker run --rm --interactive -v $(pwd):/numpy -v /:/host the_build /bin/bash -c "
99+
export F90=/usr/bin/gfortran
100+
cd /numpy && spin test -- -k ${RUNTIME_TEST_FILTER}
101+
"

0 commit comments

Comments
 (0)