diff --git a/tests/dockerfiles/php81/1_build.sh b/tests/dockerfiles/php81/1_build.sh new file mode 100755 index 0000000..9c0fe70 --- /dev/null +++ b/tests/dockerfiles/php81/1_build.sh @@ -0,0 +1,3 @@ +# Build an image. +set -x +docker build --tag="php-curl-class/php81" . diff --git a/tests/dockerfiles/php81/2_start.sh b/tests/dockerfiles/php81/2_start.sh new file mode 100755 index 0000000..1eeea23 --- /dev/null +++ b/tests/dockerfiles/php81/2_start.sh @@ -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" diff --git a/tests/dockerfiles/php81/3_test.sh b/tests/dockerfiles/php81/3_test.sh new file mode 100755 index 0000000..87f2d0b --- /dev/null +++ b/tests/dockerfiles/php81/3_test.sh @@ -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}" diff --git a/tests/dockerfiles/php81/4_stop.sh b/tests/dockerfiles/php81/4_stop.sh new file mode 100755 index 0000000..b1b8959 --- /dev/null +++ b/tests/dockerfiles/php81/4_stop.sh @@ -0,0 +1,3 @@ +# Stop container. +set -x +docker stop "php81" diff --git a/tests/dockerfiles/php81/Dockerfile b/tests/dockerfiles/php81/Dockerfile new file mode 100644 index 0000000..d6b4ed9 --- /dev/null +++ b/tests/dockerfiles/php81/Dockerfile @@ -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"] diff --git a/tests/dockerfiles/php81/attach.sh b/tests/dockerfiles/php81/attach.sh new file mode 100755 index 0000000..8211a85 --- /dev/null +++ b/tests/dockerfiles/php81/attach.sh @@ -0,0 +1,3 @@ +# Attach to running container. + +docker exec --interactive --tty "php81" bash -l diff --git a/tests/dockerfiles/php81/run.sh b/tests/dockerfiles/php81/run.sh new file mode 100755 index 0000000..ced63cf --- /dev/null +++ b/tests/dockerfiles/php81/run.sh @@ -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 diff --git a/tests/dockerfiles/php81/run_interactive.sh b/tests/dockerfiles/php81/run_interactive.sh new file mode 100755 index 0000000..dee76fb --- /dev/null +++ b/tests/dockerfiles/php81/run_interactive.sh @@ -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