Skip to content

Commit b7aa5ac

Browse files
committed
chore(CI): run tests on different distributions
1 parent b49de1b commit b7aa5ac

File tree

3 files changed

+106
-3
lines changed

3 files changed

+106
-3
lines changed

.github/workflows/ci.yml

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