-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_docker.sh
More file actions
executable file
·35 lines (28 loc) · 962 Bytes
/
test_docker.sh
File metadata and controls
executable file
·35 lines (28 loc) · 962 Bytes
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
#!/bin/bash -ex
# Define the PHP versions
PHP_VERSIONS=("7.4" "8.0" "8.1" "8.2" "8.3" "8.4")
# Loop through each PHP version
for VERSION in "${PHP_VERSIONS[@]}"; do
DOCKERFILE="./Dockerfile"
IMAGE_NAME="php-ci:${VERSION}"
# Check if the Dockerfile exists
if [ -f "$DOCKERFILE" ]; then
echo "Building Docker image for PHP ${VERSION}..."
docker build -f "$DOCKERFILE" -t "$IMAGE_NAME" --build-arg PHP_VERSION="${VERSION}" -q .
if [ $? -eq 0 ]; then
echo "Successfully built ${IMAGE_NAME}. Running tests..."
docker run --rm "$IMAGE_NAME" bash -c "composer run lint"
if [ $? -eq 0 ]; then
echo "Tests passed for PHP ${VERSION}."
else
echo "Tests failed for PHP ${VERSION}." >&2
fi
else
echo "Failed to build Docker image for PHP ${VERSION}." >&2
fi
else
echo "Dockerfile for PHP ${VERSION} not found. Skipping..." >&2
fi
echo
done
echo "All builds and tests complete."