Add files to run php80 tests inside a docker container

This commit is contained in:
Zach Borboa
2021-03-13 18:03:24 -05:00
parent eac149a259
commit b27d86cd13
10 changed files with 101 additions and 1 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ class Test
public static function getTestUrl($port)
{
if (getenv('PHP_CURL_CLASS_LOCAL_TEST') === 'yes' ||
in_array(getenv('TRAVIS_PHP_VERSION'), array('7.0', '7.1', '7.2', '7.3', '7.4', 'nightly'))) {
in_array(getenv('TRAVIS_PHP_VERSION'), array('7.0', '7.1', '7.2', '7.3', '7.4', '8.0', 'nightly'))) {
return 'http://127.0.0.1:' . $port . '/';
} else {
return self::TEST_URL;
+2
View File
@@ -178,6 +178,8 @@ elif [[ "${TRAVIS_PHP_VERSION}" == "7.3" ]]; then
start_php_servers
elif [[ "${TRAVIS_PHP_VERSION}" == "7.4" ]]; then
start_php_servers
elif [[ "${TRAVIS_PHP_VERSION}" == "8.0" ]]; then
start_php_servers
elif [[ "${TRAVIS_PHP_VERSION}" == "hhvm" || "${TRAVIS_PHP_VERSION}" == "hhvm-nightly" ]]; then
curl "https://nginx.org/keys/nginx_signing.key" | sudo apt-key add -
echo "deb https://nginx.org/packages/mainline/ubuntu/ trusty nginx" | sudo tee -a /etc/apt/sources.list
+3
View File
@@ -0,0 +1,3 @@
# Build an image.
set -x
docker build --tag="php-curl-class/php80" .
+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 "php80" ||
docker run \
--detach \
--interactive \
--mount "type=bind,src=${project_dir},dst=/data,readonly=true" \
--name="php80" \
--tty \
"php-curl-class/php80"
+18
View File
@@ -0,0 +1,18 @@
# 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 TRAVIS_PHP_VERSION="8.0" &&
(
[ ! -f "/tmp/.composer_updated" ] &&
composer --no-interaction update &&
touch "/tmp/.composer_updated" ||
exit 0
) &&
bash "tests/before_script.sh" &&
bash "tests/script.sh"
END
)
set -x
docker exec --tty "php80" sh -c "${command}"
+3
View File
@@ -0,0 +1,3 @@
# Stop container.
set -x
docker stop "php80"
+19
View File
@@ -0,0 +1,19 @@
FROM php:8.0-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 "php80" 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="php80" \
--rm \
--tty \
"php-curl-class/php80" /bin/bash