Skip to content

Commit c4dfe8d

Browse files
committed
Add files to run php74 tests inside a docker container
1 parent f850bc7 commit c4dfe8d

File tree

6 files changed

+72
-0
lines changed

6 files changed

+72
-0
lines changed

tests/dockerfiles/php74/1_build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Build an image.
2+
set -x
3+
docker build --tag="php-curl-class/php74" .

tests/dockerfiles/php74/2_start.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Run image to create container.
2+
3+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4+
set -x
5+
cd "${SCRIPT_DIR}/../../.."
6+
project_dir="${PWD}"
7+
8+
docker start "php74" ||
9+
docker run \
10+
--detach \
11+
--interactive \
12+
--mount "type=bind,src=${project_dir},dst=/data,readonly=true" \
13+
--name="php74" \
14+
--tty \
15+
"php-curl-class/php74"

tests/dockerfiles/php74/3_test.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Run tests inside container.
2+
command=$(cat <<-END
3+
mkdir --parents "/tmp/php-curl-class" &&
4+
rsync --delete --exclude=".git" --exclude="vendor" --exclude="composer.lock" --links --recursive "/data/" "/tmp/php-curl-class/" &&
5+
cd "/tmp/php-curl-class" &&
6+
export TRAVIS_PHP_VERSION="7.4" &&
7+
(
8+
[ ! -f "/tmp/.composer_updated" ] &&
9+
composer --no-interaction update &&
10+
touch "/tmp/.composer_updated" ||
11+
exit 0
12+
) &&
13+
bash "tests/before_script.sh" &&
14+
bash "tests/script.sh"
15+
END
16+
)
17+
set -x
18+
docker exec --interactive --tty "php74" sh -c "${command}"

tests/dockerfiles/php74/4_stop.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Stop container.
2+
set -x
3+
docker stop "php74"

tests/dockerfiles/php74/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM php:7.4-cli
2+
ENV DEBIAN_FRONTEND noninteractive
3+
4+
RUN apt-get --assume-yes --quiet update
5+
6+
RUN apt-get --assume-yes --quiet install git && \
7+
apt-get --assume-yes --quiet install libpng-dev && \
8+
apt-get --assume-yes --quiet install rsync && \
9+
apt-get --assume-yes --quiet install zip
10+
11+
RUN curl --silent --show-error "https://getcomposer.org/installer" | php && \
12+
mv "composer.phar" "/usr/local/bin/composer" && \
13+
composer global require --no-interaction "phpunit/phpunit"
14+
15+
RUN docker-php-ext-configure gd && \
16+
docker-php-ext-install gd
17+
18+
ENV PATH /root/.composer/vendor/bin:$PATH
19+
CMD ["bash"]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Run image to create container and attach to it.
2+
3+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4+
set -x
5+
cd "${SCRIPT_DIR}/../../.."
6+
project_dir="${PWD}"
7+
8+
docker run \
9+
--interactive \
10+
--mount "type=bind,src=${project_dir},dst=/data,readonly=true" \
11+
--name="php74" \
12+
--rm \
13+
--tty \
14+
"php-curl-class/php74" /bin/bash

0 commit comments

Comments
 (0)