Add files to run PHP 8.1 tests inside a docker container

This commit is contained in:
Zach Borboa
2022-09-30 19:39:50 -07:00
parent bf54ee6d9a
commit 5bfe59109a
8 changed files with 97 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
# Build an image.
set -x
docker build --tag="php-curl-class/php81" .
+15
View File
@@ -0,0 +1,15 @@
# Run image to create container.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
set -x
cd "${SCRIPT_DIR}/../../.."
project_dir="${PWD}"
docker start "php81" ||
docker run \
--detach \
--interactive \
--mount "type=bind,src=${project_dir},dst=/data,readonly=true" \
--name="php81" \
--tty \
"php-curl-class/php81"
+17
View File
@@ -0,0 +1,17 @@
# Run tests inside container.
command=$(cat <<-END
mkdir --parents "/tmp/php-curl-class" &&
rsync --delete --exclude=".git" --exclude="vendor" --exclude="composer.lock" --links --recursive "/data/" "/tmp/php-curl-class/" &&
cd "/tmp/php-curl-class" &&
export CI_PHP_VERSION="8.1" &&
(
[ ! -f "/tmp/.composer_updated" ] &&
composer --no-interaction update &&
touch "/tmp/.composer_updated" ||
exit 0
) &&
bash "tests/run.sh"
END
)
set -x
docker exec --tty "php81" sh -c "${command}"
+3
View File
@@ -0,0 +1,3 @@
# Stop container.
set -x
docker stop "php81"
+19
View File
@@ -0,0 +1,19 @@
FROM php:8.1-cli
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get --assume-yes --quiet update
RUN apt-get --assume-yes --quiet install git && \
apt-get --assume-yes --quiet install libpng-dev && \
apt-get --assume-yes --quiet install rsync && \
apt-get --assume-yes --quiet install zip
RUN curl --silent --show-error "https://getcomposer.org/installer" | php && \
mv "composer.phar" "/usr/local/bin/composer" && \
composer global require --no-interaction "phpunit/phpunit"
RUN docker-php-ext-configure gd && \
docker-php-ext-install gd
ENV PATH /root/.composer/vendor/bin:$PATH
CMD ["bash"]
+3
View File
@@ -0,0 +1,3 @@
# Attach to running container.
docker exec --interactive --tty "php81" bash -l
+23
View File
@@ -0,0 +1,23 @@
bash "1_build.sh"
if [[ $? -ne 0 ]]; then
echo "Error: Build failed"
exit 1
fi
bash "2_start.sh"
if [[ $? -ne 0 ]]; then
echo "Error: Start failed"
exit 1
fi
bash "3_test.sh"
if [[ $? -ne 0 ]]; then
echo "Error: Test failed"
exit 1
fi
bash "4_stop.sh"
if [[ $? -ne 0 ]]; then
echo "Error: Stop failed"
exit 1
fi
+14
View File
@@ -0,0 +1,14 @@
# Run image to create container and attach to it.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
set -x
cd "${SCRIPT_DIR}/../../.."
project_dir="${PWD}"
docker run \
--interactive \
--mount "type=bind,src=${project_dir},dst=/data,readonly=true" \
--name="php81" \
--rm \
--tty \
"php-curl-class/php81" /bin/bash