Skip to content

Commit d4ca652

Browse files
committed
chore(CI): run tests on different distributions
1 parent 523f401 commit d4ca652

File tree

3 files changed

+106
-3
lines changed

3 files changed

+106
-3
lines changed

.github/workflows/ci.yml

+88
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,91 @@ 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+
runner = {
45+
"x86_64": "ubuntu-24.04",
46+
"i686": "ubuntu-24.04",
47+
"aarch64": "ubuntu-24.04-arm",
48+
"armv7l": "ubuntu-24.04-arm",
49+
"ppc64le": "ubuntu-24.04",
50+
"s390x": "ubuntu-24.04",
51+
"riscv64": "ubuntu-24.04",
52+
}
53+
reduced = [
54+
("almalinux:8", ("x86_64", "aarch64", "ppc64le", "s390x")),
55+
("almalinux:9", ("x86_64", "aarch64", "ppc64le", "s390x")),
56+
("centos:7", ("x86_64", "i686", "aarch64", "ppc64le", "s390x")),
57+
("debian:10", ("x86_64", "i686", "aarch64", "armv7l")),
58+
("debian:11", ("x86_64", "i686", "aarch64", "armv7l")),
59+
("debian:12", ("x86_64", "i686", "aarch64", "armv7l", "ppc64le", "s390x")),
60+
("ubuntu:18.04", ("x86_64", "i686", "aarch64", "armv7l", "ppc64le", "s390x")),
61+
("ubuntu:20.04", ("x86_64", "aarch64", "armv7l", "ppc64le", "s390x", "riscv64")),
62+
("ubuntu:22.04", ("x86_64", "aarch64", "armv7l", "ppc64le", "s390x", "riscv64")),
63+
("ubuntu:24.04", ("x86_64", "aarch64", "armv7l", "ppc64le", "s390x", "riscv64")),
64+
]
65+
expanded = [{"distro": distro, "platform": platform, "runner": runner[platform]} for distro, platforms in reduced for platform in platforms]
66+
print(json.dumps(expanded, indent=2))
67+
with open(os.environ["GITHUB_OUTPUT"], "at") as f:
68+
f.write(f"matrix={json.dumps(expanded)}")
69+
70+
distro_check:
71+
needs: distro_matrix
72+
name: ${{ matrix.distro }} ${{ matrix.platform }}
73+
runs-on: ${{ matrix.runner }}
74+
timeout-minutes: 10
75+
strategy:
76+
fail-fast: false
77+
matrix:
78+
include: ${{ fromJson(needs.distro_matrix.outputs.matrix) }}
79+
steps:
80+
- uses: actions/checkout@v4
81+
- name: Set up QEMU
82+
if: runner.arch == 'X64' && matrix.platform != 'x86_64'
83+
uses: docker/setup-qemu-action@v3
84+
- run: |
85+
# ${{ matrix.distro }} ${{ matrix.platform }} tests
86+
cat <<EOF > build.sh
87+
set -e
88+
set -x
89+
90+
case "${{ matrix.distro }}" in
91+
ubuntu*|debian*) apt-get update && apt-get -y install automake g++ make;;
92+
esac
93+
94+
c++ --version
95+
ld --version
96+
autoconf --version
97+
./bootstrap.sh
98+
mkdir build && cd build
99+
../configure
100+
make -j$(nproc) check || (cat tests/test-suite.log; exit 1)
101+
EOF
102+
103+
case "${{ matrix.platform }}" in
104+
x86_64) DOCKER_PLATFORM=amd64;;
105+
i686) DOCKER_PLATFORM=386;;
106+
aarch64) DOCKER_PLATFORM=arm64/v8;;
107+
armv7l) DOCKER_PLATFORM=arm/v7;;
108+
*) DOCKER_PLATFORM=${{ matrix.platform }};;
109+
esac
110+
111+
case "${{ matrix.distro }}" in
112+
centos:7) IMAGE=quay.io/pypa/manylinux2014_${{ matrix.platform }}:latest;;
113+
almalinux:8) IMAGE=quay.io/pypa/manylinux_2_28_${{ matrix.platform }}:latest;;
114+
almalinux:9) IMAGE=quay.io/pypa/manylinux_2_34_${{ matrix.platform }}:latest;;
115+
*) IMAGE=${{ matrix.distro }}
116+
esac
117+
118+
docker run --platform linux/${DOCKER_PLATFORM} -v $(pwd):/gha ${IMAGE} sh -ec "cd /gha && bash ./build.sh"

tests/replace-add-needed.sh

+11-1
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

+7-2
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)