-
Notifications
You must be signed in to change notification settings - Fork 1
/
tests.sh
executable file
·85 lines (75 loc) · 2.36 KB
/
tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash -ex
# Define the Dockerfile and image names
declare -a dockerfiles=(
"tests/Dockerfile-8.0-alpine"
"tests/Dockerfile-8.0-buster"
"tests/Dockerfile-8.0-bullseye"
"tests/Dockerfile-8.1-alpine"
"tests/Dockerfile-8.1-buster"
"tests/Dockerfile-8.1-bullseye"
"tests/Dockerfile-8.1-bookworm"
"tests/Dockerfile-8.2-alpine"
"tests/Dockerfile-8.2-buster"
"tests/Dockerfile-8.2-bullseye"
"tests/Dockerfile-8.2-bookworm"
"tests/Dockerfile-8.3-alpine"
"tests/Dockerfile-8.3-bullseye"
"tests/Dockerfile-8.3-bookworm"
)
# Cleanup any spillover
docker rm -f dummy || true
rm -rf outputs/
mkdir -p outputs/
# Define the corresponding image names
declare -a images=(
"alpine/8.0"
"buster/8.0"
"bullseye/8.0"
"alpine/8.1"
"buster/8.1"
"bullseye/8.1"
"bookworm/8.1"
"alpine/8.2"
"buster/8.2"
"bullseye/8.2"
"bookworm/8.2"
"alpine/8.3"
"bullseye/8.3"
"bookworm/8.3"
)
# Define the architectures to test
declare -a archs=(
"linux/arm64"
"linux/amd64"
"linux/arm64/v8"
"linux/arm/v7"
"linux/386"
"linux/mips64le"
"linux/ppc64le"
"linux/s390x"
)
# Loop over the architectures
for arch in "${archs[@]}"; do
# Loop over the Dockerfiles and images to build and run the tests
for i in "${!dockerfiles[@]}"; do
echo "Testing ${images[$i]} on architecture: $arch"
# Build the Docker image for the specific architecture
docker buildx build -q --platform $arch -f "${dockerfiles[$i]}" . -t "${images[$i]}-${arch##*/}" --load
# Create a temporary file to hold the output
output=$(mktemp)
# Run the Docker container and capture the output
if ! docker run -v "$(pwd)/tests:/tests" -it --rm "${images[$i]}-${arch##*/}" php /tests/TestSuite.php > "$output" 2>&1; then
echo "Test failed for image: ${images[$i]} on architecture: $arch"
cat "$output"
exit 1
fi
# Remove the temporary file
rm "$output"
# Grab the build
mkdir -p "outputs/${arch}/${images[$i]}"
ext_path=$(docker run -v "$(pwd):/build" --name=dummy -it "${images[$i]}-${arch##*/}" php-config --extension-dir | tr -d '\r')
docker cp "dummy:${ext_path}/bprof.so" "outputs/${arch}/${images[$i]}/bprof.so"
docker rm -f dummy || true
done
done
docker system prune -f