Skip to content

Commit

Permalink
CI: Provides cross-compile builds for armhf, ppc64le, and s390x
Browse files Browse the repository at this point in the history
  • Loading branch information
seiko2plus committed Aug 21, 2023
1 parent e8e523f commit b894655
Showing 1 changed file with 99 additions and 0 deletions.
99 changes: 99 additions & 0 deletions .github/workflows/linux_qemu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# 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: Test Linux Qemu

on:
pull_request:
branches:
- main
- maintenance/**

defaults:
run:
shell: bash

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
meson_spin:
if: "github.repository == 'numpy/numpy'"
runs-on: ubuntu-22.04
strategy:
matrix:
ARCH: [
["armhf", "arm-linux-gnueabihf", "arm32v7/ubuntu:22.04"],
]
env:
QEMU_NAME: ${{ matrix.ARCH[0] }}
TOOLCHAIN_NAME: ${{ matrix.ARCH[1] }}
DOCKER_CONTAINER: ${{ matrix.ARCH[2] }}
CC: ${{ matrix.ARCH[1] }}-gcc
CXX: ${{ matrix.ARCH[1] }}-g++

name: "Test Linux Qemu(${matrix.ARCH[0]})"
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
submodules: recursive
fetch-depth: 0

- name: Initialize binfmt_misc for qemu-user-static
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Creates new container
run: |
sudo apt update
sudo apt install -y ninja-build gcc-${TOOLCHAIN_NAME} g++-${TOOLCHAIN_NAME} gfortran-${TOOLCHAIN_NAME}
docker run --name the_container --interactive -v /:/host -v $(pwd):/numpy ${DOCKER_CONTAINER} /bin/bash -c "
apt update &&
apt install -y git python3 python-is-python3 python3-dev python3-pip
ln -s /host/lib64 /lib64 &&
ln -s /host/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu &&
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/${TOOLCHAIN_NAME}-gcc && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-gcc /usr/bin/${TOOLCHAIN_NAME}-gcc &&
rm -f /usr/bin/${TOOLCHAIN_NAME}-g++ && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-g++ /usr/bin/${TOOLCHAIN_NAME}-g++ &&
rm -f /usr/bin/${TOOLCHAIN_NAME}-gfortran && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-gfortran /usr/bin/${TOOLCHAIN_NAME}-gfortran &&
rm -f /usr/bin/${TOOLCHAIN_NAME}-ar && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ar /usr/bin/${TOOLCHAIN_NAME}-ar &&
rm -f /usr/bin/${TOOLCHAIN_NAME}-as && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-as /usr/bin/${TOOLCHAIN_NAME}-as &&
rm -f /usr/bin/${TOOLCHAIN_NAME}-ld && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ld /usr/bin/${TOOLCHAIN_NAME}-ld &&
rm -f /usr/bin/${TOOLCHAIN_NAME}-ld.bfd && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ld.bfd /usr/bin/${TOOLCHAIN_NAME}-ld.bfd &&
rm -f /usr/bin/ninja && ln -s /host/usr/bin/ninja /usr/bin/ninja
python -m pip install meson-python>=0.13.1 Cython>=3.0 wheel==0.38.1 spin==0.5
python -m pip install pytest pytest-xdist hypothesis typing_extensions
"
docker commit the_container the_container
- name: Build
run: |
sudo docker run --name the_build --interactive -v $(pwd):/numpy -v /:/host the_container /bin/bash -c "
uname -a &&
gcc --version &&
g++ --version &&
${TOOLCHAIN_NAME}-gfortran --version &&
python --version &&
git config --global --add safe.directory /numpy
cd /numpy &&
spin build --clean -- -Dallow-noblas=true
"
docker commit the_build the_build
- name: Meson Log
if: failure()
run: 'cat build/meson-logs/meson-log.txt'

- name: Run Tests
run: |
docker run --rm --interactive -v $(pwd):/numpy the_build /bin/bash -c "
cd /numpy && spin test -- -k 'test_simd or test_kind'
"

0 comments on commit b894655

Please sign in to comment.