Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(CI): run tests on different distributions #581

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,96 @@ 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", "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
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 <<EOF > 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"
5 changes: 5 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
12 changes: 11 additions & 1 deletion tests/replace-add-needed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions tests/set-interpreter-long.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Loading