From 9392f4be38e1f7c407841078ac4d6e9d4e6ec058 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sat, 29 Apr 2023 13:38:37 +0200 Subject: [PATCH 1/3] chore(CI): run tests on different distributions --- .github/workflows/ci.yml | 88 +++++++++++++++++++++++++++++++++++ tests/replace-add-needed.sh | 12 ++++- tests/set-interpreter-long.sh | 9 +++- 3 files changed, 106 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 887258ca..e78a2267 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,3 +28,91 @@ jobs: mkdir build && cd build ../configure --with-asan --with-ubsan make -j$(nproc) check + + distro_matrix: + name: build distribution matrix + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.matrix.outputs.matrix }} + steps: + - id: matrix + name: build matrix + shell: python + run: | + import os + import json + runner = { + "x86_64": "ubuntu-24.04", + "i686": "ubuntu-24.04", + "aarch64": "ubuntu-24.04-arm", + "armv7l": "ubuntu-24.04-arm", + "ppc64le": "ubuntu-24.04", + "s390x": "ubuntu-24.04", + "riscv64": "ubuntu-24.04", + } + reduced = [ + ("almalinux:8", ("x86_64", "aarch64", "ppc64le", "s390x")), + ("almalinux:9", ("x86_64", "aarch64", "ppc64le", "s390x")), + ("centos:7", ("x86_64", "i686", "aarch64", "ppc64le", "s390x")), + ("debian:10", ("x86_64", "i686", "aarch64", "armv7l")), + ("debian:11", ("x86_64", "i686", "aarch64", "armv7l")), + ("debian:12", ("x86_64", "i686", "aarch64", "armv7l", "ppc64le", "s390x")), + ("ubuntu:18.04", ("x86_64", "i686", "aarch64", "armv7l", "ppc64le", "s390x")), + ("ubuntu:20.04", ("x86_64", "aarch64", "armv7l", "ppc64le", "s390x", "riscv64")), + ("ubuntu:22.04", ("x86_64", "aarch64", "armv7l", "ppc64le", "s390x", "riscv64")), + ("ubuntu:24.04", ("x86_64", "aarch64", "armv7l", "ppc64le", "s390x", "riscv64")), + ] + expanded = [{"distro": distro, "platform": platform, "runner": runner[platform]} for distro, platforms in reduced for platform in platforms] + print(json.dumps(expanded, indent=2)) + with open(os.environ["GITHUB_OUTPUT"], "at") as f: + f.write(f"matrix={json.dumps(expanded)}") + + distro_check: + needs: distro_matrix + name: ${{ matrix.distro }} ${{ matrix.platform }} + runs-on: ${{ matrix.runner }} + timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + include: ${{ fromJson(needs.distro_matrix.outputs.matrix) }} + steps: + - uses: actions/checkout@v4 + - name: Set up QEMU + if: runner.arch == 'X64' && matrix.platform != 'x86_64' + uses: docker/setup-qemu-action@v3 + - run: | + # ${{ matrix.distro }} ${{ matrix.platform }} tests + cat < build.sh + set -e + set -x + + case "${{ matrix.distro }}" in + ubuntu*|debian*) apt-get update && apt-get -y install automake g++ make;; + esac + + c++ --version + ld --version + autoconf --version + ./bootstrap.sh + mkdir build && cd build + ../configure + make -j$(nproc) check || (cat tests/test-suite.log; exit 1) + EOF + + case "${{ matrix.platform }}" in + x86_64) DOCKER_PLATFORM=amd64;; + i686) DOCKER_PLATFORM=386;; + aarch64) DOCKER_PLATFORM=arm64/v8;; + armv7l) DOCKER_PLATFORM=arm/v7;; + *) DOCKER_PLATFORM=${{ matrix.platform }};; + esac + + case "${{ matrix.distro }}" in + centos:7) IMAGE=quay.io/pypa/manylinux2014_${{ matrix.platform }}:latest;; + almalinux:8) IMAGE=quay.io/pypa/manylinux_2_28_${{ matrix.platform }}:latest;; + almalinux:9) IMAGE=quay.io/pypa/manylinux_2_34_${{ matrix.platform }}:latest;; + *) IMAGE=${{ matrix.distro }} + esac + + docker run --platform linux/${DOCKER_PLATFORM} -v $(pwd):/gha ${IMAGE} sh -ec "cd /gha && bash ./build.sh" diff --git a/tests/replace-add-needed.sh b/tests/replace-add-needed.sh index 701cb953..f8c9282e 100755 --- a/tests/replace-add-needed.sh +++ b/tests/replace-add-needed.sh @@ -11,7 +11,17 @@ cp libbar.so "${SCRATCH}"/ cd "${SCRATCH}" -libcldd=$(ldd ./simple | awk '/ => / { print $3 }' | grep -E "(libc(-[0-9.]*)*.so|ld-musl)") +# QEMU & ldd are not playing well together in certain cases +CHECK_QEMU=0 +libcldd=$(ldd ./simple | awk '/ => / { print $3 }' | grep -E "(libc(-[0-9.]*)*.so|ld-musl)") || CHECK_QEMU=1 +if [ "${CHECK_QEMU}" -ne 0 ]; then + if [ -f /lib64/libc.so.6 ] && grep qemu /proc/1/cmdline >/dev/null 2>&1; then + libcldd=/lib64/libc.so.6 + else + echo "ldd ./simple failed" + exit 1 + fi +fi # We have to set the soname on these libraries ${PATCHELF} --set-soname libbar.so ./libbar.so diff --git a/tests/set-interpreter-long.sh b/tests/set-interpreter-long.sh index f1e0d2f9..d4246556 100755 --- a/tests/set-interpreter-long.sh +++ b/tests/set-interpreter-long.sh @@ -6,7 +6,12 @@ SCRATCH=scratch/$(basename "$0" .sh) oldInterpreter=$(../src/patchelf --print-interpreter ./simple) echo "current interpreter is $oldInterpreter" -if test "$(uname)" = Linux; then +RUN_EXPLICIT_INTERPRETER=0 +if [ "$(uname)" = Linux ] && ! grep qemu /proc/1/cmdline >/dev/null 2>&1; then # QEMU & ldd/ld.so are not playing well together in certain cases + RUN_EXPLICIT_INTERPRETER=1 +fi + +if [ "${RUN_EXPLICIT_INTERPRETER}" -ne 0 ]; then echo "running with explicit interpreter..." "$oldInterpreter" ./simple fi @@ -28,7 +33,7 @@ echo "running with new interpreter..." ln -s "$oldInterpreter" "$newInterpreter" "${SCRATCH}"/simple -if test "$(uname)" = Linux; then +if [ "${RUN_EXPLICIT_INTERPRETER}" -ne 0 ]; then echo "running with explicit interpreter..." "$oldInterpreter" "${SCRATCH}/simple" fi From 6d4f39fa5a2ccf6eff224d146e34beda0916c234 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sun, 26 Jan 2025 09:55:56 +0100 Subject: [PATCH 2/3] ci(fix): use tonistiigi/binfmt:qemu-v8.1.5 image for qemu --- .github/workflows/ci.yml | 5 +++++ .github/workflows/publish.yml | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e78a2267..bed21b7e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,6 +81,11 @@ jobs: - name: Set up QEMU if: runner.arch == 'X64' && matrix.platform != 'x86_64' uses: docker/setup-qemu-action@v3 + with: + # This should be temporary + # xref https://github.com/docker/setup-qemu-action/issues/188 + # xref https://github.com/tonistiigi/binfmt/issues/215 + image: tonistiigi/binfmt:qemu-v8.1.5 - run: | # ${{ matrix.distro }} ${{ matrix.platform }} tests cat < build.sh diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 88015d93..8d89b3f7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -72,6 +72,11 @@ jobs: - name: Set up QEMU if: matrix.platform != 'amd64' uses: docker/setup-qemu-action@v3 + with: + # This should be temporary + # xref https://github.com/docker/setup-qemu-action/issues/188 + # xref https://github.com/tonistiigi/binfmt/issues/215 + image: tonistiigi/binfmt:qemu-v8.1.5 - name: Set docker arch run: | From 8646ca40d100e5e92e469b2003a06a29234eac55 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sun, 26 Jan 2025 10:31:04 +0100 Subject: [PATCH 3/3] skip ubuntu:18.04 i686 for now --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bed21b7e..b67f8cca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,7 +57,7 @@ jobs: ("debian:10", ("x86_64", "i686", "aarch64", "armv7l")), ("debian:11", ("x86_64", "i686", "aarch64", "armv7l")), ("debian:12", ("x86_64", "i686", "aarch64", "armv7l", "ppc64le", "s390x")), - ("ubuntu:18.04", ("x86_64", "i686", "aarch64", "armv7l", "ppc64le", "s390x")), + ("ubuntu:18.04", ("x86_64", "aarch64", "armv7l", "ppc64le", "s390x")), ("ubuntu:20.04", ("x86_64", "aarch64", "armv7l", "ppc64le", "s390x", "riscv64")), ("ubuntu:22.04", ("x86_64", "aarch64", "armv7l", "ppc64le", "s390x", "riscv64")), ("ubuntu:24.04", ("x86_64", "aarch64", "armv7l", "ppc64le", "s390x", "riscv64")),