|
| 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 | + ["armhf", "arm-linux-gnueabihf", "arm32v7/ubuntu:22.04"], |
| 34 | + ] |
| 35 | + env: |
| 36 | + QEMU_NAME: ${{ matrix.ARCH[0] }} |
| 37 | + TOOLCHAIN_NAME: ${{ matrix.ARCH[1] }} |
| 38 | + DOCKER_CONTAINER: ${{ matrix.ARCH[2] }} |
| 39 | + |
| 40 | + name: "Test Linux Qemu(${matrix.ARCH[0]})" |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 |
| 43 | + with: |
| 44 | + submodules: recursive |
| 45 | + fetch-depth: 0 |
| 46 | + |
| 47 | + - name: Initialize binfmt_misc for qemu-user-static |
| 48 | + run: | |
| 49 | + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes |
| 50 | +
|
| 51 | + - name: Creates new container |
| 52 | + run: | |
| 53 | + sudo apt update |
| 54 | + sudo apt install -y ninja-build gcc-${TOOLCHAIN_NAME} g++-${TOOLCHAIN_NAME} gfortran-${TOOLCHAIN_NAME} |
| 55 | + docker run --name the_container --interactive -v /:/host -v $(pwd):/numpy ${DOCKER_CONTAINER} /bin/bash -c " |
| 56 | + apt update && |
| 57 | + apt install -y build-essential git python3 python-is-python3 python3-dev python3-pip && |
| 58 | + ln -s /host/lib64 /lib64 && |
| 59 | + ln -s /host/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu && |
| 60 | + mkdir -p /usr/${TOOLCHAIN_NAME} && mount --rbind /host/usr/${TOOLCHAIN_NAME} /usr/${TOOLCHAIN_NAME} && |
| 61 | + rm -rf /usr/lib/gcc/${TOOLCHAIN_NAME} && ln -s /host/usr/lib/gcc-cross/${TOOLCHAIN_NAME} /usr/lib/gcc/${TOOLCHAIN_NAME} && |
| 62 | + rm -f /usr/bin/${TOOLCHAIN_NAME}-gcc && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-gcc /usr/bin/${TOOLCHAIN_NAME}-gcc && |
| 63 | + rm -f /usr/bin/${TOOLCHAIN_NAME}-g++ && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-g++ /usr/bin/${TOOLCHAIN_NAME}-g++ && |
| 64 | + rm -f /usr/bin/${TOOLCHAIN_NAME}-gfortran && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-gfortran /usr/bin/${TOOLCHAIN_NAME}-gfortran && |
| 65 | + rm -f /usr/bin/${TOOLCHAIN_NAME}-ar && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ar /usr/bin/${TOOLCHAIN_NAME}-ar && |
| 66 | + rm -f /usr/bin/${TOOLCHAIN_NAME}-as && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-as /usr/bin/${TOOLCHAIN_NAME}-as && |
| 67 | + rm -f /usr/bin/${TOOLCHAIN_NAME}-ld && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ld /usr/bin/${TOOLCHAIN_NAME}-ld && |
| 68 | + rm -f /usr/bin/${TOOLCHAIN_NAME}-ld.bfd && ln -s /host/usr/bin/${TOOLCHAIN_NAME}-ld.bfd /usr/bin/${TOOLCHAIN_NAME}-ld.bfd && |
| 69 | + rm -f /usr/bin/ninja && ln -s /host/usr/bin/ninja /usr/bin/ninja && |
| 70 | + python -m pip install meson-python>=0.13.1 Cython>=3.0 wheel==0.38.1 spin==0.5 && |
| 71 | + python -m pip install pytest pytest-xdist hypothesis typing_extensions |
| 72 | + " |
| 73 | + docker commit the_container the_container |
| 74 | +
|
| 75 | + - name: Build |
| 76 | + run: | |
| 77 | + sudo docker run --name the_build --interactive -v $(pwd):/numpy -v /:/host the_container /bin/bash -c " |
| 78 | + uname -a && |
| 79 | + gcc --version && |
| 80 | + g++ --version && |
| 81 | + python --version && |
| 82 | + git config --global --add safe.directory /numpy |
| 83 | + cd /numpy && |
| 84 | + spin build --clean -- -Dallow-noblas=true |
| 85 | + " |
| 86 | + docker commit the_build the_build |
| 87 | +
|
| 88 | + - name: Meson Log |
| 89 | + if: failure() |
| 90 | + run: 'cat build/meson-logs/meson-log.txt' |
| 91 | + |
| 92 | + - name: Run Tests |
| 93 | + run: | |
| 94 | + docker run --rm --interactive -v $(pwd):/numpy the_build /bin/bash -c " |
| 95 | + cd /numpy && spin test -- -k 'test_simd or test_kind' |
| 96 | + " |
0 commit comments