Skip to content

Commit 176a4ab

Browse files
committed
chore(CI): run tests on different distributions
1 parent 769337c commit 176a4ab

File tree

3 files changed

+104
-3
lines changed

3 files changed

+104
-3
lines changed

.github/workflows/ci.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,89 @@ jobs:
2828
mkdir build && cd build
2929
../configure --with-asan --with-ubsan
3030
make -j$(nproc) check
31+
32+
distro_matrix:
33+
name: build distribution matrix
34+
runs-on: ubuntu-latest
35+
outputs:
36+
matrix: ${{ steps.matrix.outputs.matrix }}
37+
steps:
38+
- id: matrix
39+
name: build matrix
40+
shell: python
41+
run: |
42+
import os
43+
import json
44+
reduced = [
45+
("almalinux:8", ("x86_64", "aarch64", "ppc64le", "s390x")),
46+
("almalinux:9", ("x86_64", "aarch64", "ppc64le", "s390x")),
47+
("centos:7", ("x86_64", "i686", "aarch64", "ppc64le", "s390x")),
48+
("debian:10", ("x86_64", "i686", "aarch64", "armv7l")),
49+
("debian:11", ("x86_64", "i686", "aarch64", "armv7l")),
50+
("debian:12", ("x86_64", "i686", "aarch64", "armv7l", "ppc64le", "s390x")),
51+
("ubuntu:18.04", ("x86_64", "i686", "aarch64", "armv7l", "ppc64le", "s390x")),
52+
("ubuntu:20.04", ("x86_64", "aarch64", "armv7l", "ppc64le", "s390x", "riscv64")),
53+
("ubuntu:22.04", ("x86_64", "aarch64", "armv7l", "ppc64le", "s390x", "riscv64")),
54+
("ubuntu:24.04", ("x86_64", "aarch64", "armv7l", "ppc64le", "s390x", "riscv64")),
55+
]
56+
expanded = [{"distro": distro, "platform": platform} for distro, platforms in reduced for platform in platforms]
57+
print(json.dumps(expanded, indent=2))
58+
with open(os.environ["GITHUB_OUTPUT"], "at") as f:
59+
f.write(f"matrix={json.dumps(expanded)}")
60+
61+
distro_check:
62+
needs: distro_matrix
63+
name: ${{ matrix.distro }} ${{ matrix.platform }}
64+
runs-on: ubuntu-latest
65+
strategy:
66+
fail-fast: false
67+
matrix:
68+
include: ${{ fromJson(needs.distro_matrix.outputs.matrix) }}
69+
steps:
70+
- uses: actions/checkout@v4
71+
- name: Set up QEMU
72+
uses: docker/setup-qemu-action@v3
73+
- run: |
74+
# ${{ matrix.distro }} ${{ matrix.platform }} tests
75+
cat <<EOF > build.sh
76+
set -e
77+
set -x
78+
79+
case "${{ matrix.distro }}" in
80+
ubuntu:18.04)
81+
apt-get update
82+
apt-get -y install software-properties-common
83+
add-apt-repository -y ppa:ubuntu-toolchain-r/test
84+
apt-get update
85+
apt-get -y install automake g++-11 make
86+
update-alternatives --install /usr/bin/c++ c++ $(which g++-11) 100
87+
update-alternatives --install /usr/bin/cc cc $(which gcc-11) 100
88+
;;
89+
ubuntu*|debian*) apt-get update && apt-get -y install automake g++ make;;
90+
esac
91+
92+
c++ --version
93+
ld --version
94+
autoconf --version
95+
./bootstrap.sh
96+
mkdir build && cd build
97+
../configure
98+
make -j$(nproc) check || (cat tests/test-suite.log; exit 1)
99+
EOF
100+
101+
case "${{ matrix.platform }}" in
102+
x86_64) DOCKER_PLATFORM=amd64;;
103+
i686) DOCKER_PLATFORM=386;;
104+
aarch64) DOCKER_PLATFORM=arm64/v8;;
105+
armv7l) DOCKER_PLATFORM=arm/v7;;
106+
*) DOCKER_PLATFORM=${{ matrix.platform }};;
107+
esac
108+
109+
case "${{ matrix.distro }}" in
110+
centos:7) IMAGE=quay.io/pypa/manylinux2014_${{ matrix.platform }}:latest;;
111+
almalinux:8) IMAGE=quay.io/pypa/manylinux_2_28_${{ matrix.platform }}:latest;;
112+
almalinux:9) IMAGE=quay.io/pypa/manylinux_2_34_${{ matrix.platform }}:latest;;
113+
*) IMAGE=${{ matrix.distro }}
114+
esac
115+
116+
docker run --platform linux/${DOCKER_PLATFORM} -v $(pwd):/gha ${IMAGE} sh -ec "cd /gha && bash ./build.sh"

tests/replace-add-needed.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,17 @@ cp libbar.so "${SCRATCH}"/
1111

1212
cd "${SCRATCH}"
1313

14-
libcldd=$(ldd ./simple | awk '/ => / { print $3 }' | grep -E "(libc(-[0-9.]*)*.so|ld-musl)")
14+
# QEMU & ldd are not playing well together in certain cases
15+
CHECK_QEMU=0
16+
libcldd=$(ldd ./simple | awk '/ => / { print $3 }' | grep -E "(libc(-[0-9.]*)*.so|ld-musl)") || CHECK_QEMU=1
17+
if [ "${CHECK_QEMU}" -ne 0 ]; then
18+
if [ -f /lib64/libc.so.6 ] && grep qemu /proc/1/cmdline >/dev/null 2>&1; then
19+
libcldd=/lib64/libc.so.6
20+
else
21+
echo "ldd ./simple failed"
22+
exit 1
23+
fi
24+
fi
1525

1626
# We have to set the soname on these libraries
1727
${PATCHELF} --set-soname libbar.so ./libbar.so

tests/set-interpreter-long.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ SCRATCH=scratch/$(basename "$0" .sh)
66
oldInterpreter=$(../src/patchelf --print-interpreter ./simple)
77
echo "current interpreter is $oldInterpreter"
88

9-
if test "$(uname)" = Linux; then
9+
RUN_EXPLICIT_INTERPRETER=0
10+
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
11+
RUN_EXPLICIT_INTERPRETER=1
12+
fi
13+
14+
if [ "${RUN_EXPLICIT_INTERPRETER}" -ne 0 ]; then
1015
echo "running with explicit interpreter..."
1116
"$oldInterpreter" ./simple
1217
fi
@@ -28,7 +33,7 @@ echo "running with new interpreter..."
2833
ln -s "$oldInterpreter" "$newInterpreter"
2934
"${SCRATCH}"/simple
3035

31-
if test "$(uname)" = Linux; then
36+
if [ "${RUN_EXPLICIT_INTERPRETER}" -ne 0 ]; then
3237
echo "running with explicit interpreter..."
3338
"$oldInterpreter" "${SCRATCH}/simple"
3439
fi

0 commit comments

Comments
 (0)