mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-08-18 12:11:39 +00:00
Add files to run PHP 8.1 tests inside a docker container
This commit is contained in:
Executable
+3
@@ -0,0 +1,3 @@
|
||||
# Build an image.
|
||||
set -x
|
||||
docker build --tag="php-curl-class/php81" .
|
||||
Executable
+15
@@ -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"
|
||||
Executable
+17
@@ -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}"
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
# Stop container.
|
||||
set -x
|
||||
docker stop "php81"
|
||||
@@ -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"]
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
# Attach to running container.
|
||||
|
||||
docker exec --interactive --tty "php81" bash -l
|
||||
Executable
+23
@@ -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
|
||||
Executable
+14
@@ -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
|
||||
Reference in New Issue
Block a user