Skip to content

Commit

Permalink
Merge pull request #70 from b13/task/docker-compose-v2
Browse files Browse the repository at this point in the history
[TASK] use docker compose v2
  • Loading branch information
achimfritz authored Aug 2, 2024
2 parents feb5eca + 57efa88 commit fa9ff54
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 45 deletions.
64 changes: 20 additions & 44 deletions Build/Scripts/runTests.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
#!/usr/bin/env bash

#
# TYPO3 core test runner based on docker and docker-compose.
#

# Function to write a .env file in Build/testing-docker/local
# This is read by docker-compose and vars defined here are
# used in Build/testing-docker/local/docker-compose.yml
setUpDockerComposeDotEnv() {
# Delete possibly existing local .env file if exists
[ -e .env ] && rm .env
# Set up a new .env file for docker-compose
echo "COMPOSE_PROJECT_NAME=local" >> .env
# To prevent access rights of files created by the testing, the docker image later
# runs with the same user that is currently executing the script. docker-compose can't
# use $UID directly itself since it is a shell variable and not an env variable, so
# we have to set it explicitly here.
echo "HOST_UID=`id -u`" >> .env
# Your local home directory for composer and npm caching
echo "HOST_HOME=${HOME}" >> .env
# Your local user
echo "ROOT_DIR"=${ROOT_DIR} >> .env
echo "HOST_USER=${USER}" >> .env
echo "TEST_FILE=${TEST_FILE}" >> .env
Expand All @@ -35,14 +21,10 @@ setUpDockerComposeDotEnv() {

# Load help text into $HELP
read -r -d '' HELP <<EOF
test runner. Execute unit test suite and some other details.
Also used by travis-ci for test execution.
Successfully tested with docker version 18.06.1-ce and docker-compose 1.21.2.
test runner.
Usage: $0 [options] [file]
No arguments: Run all unit tests with PHP 7.4
Options:
-s <...>
Expand Down Expand Up @@ -111,18 +93,12 @@ Examples:
./Build/Scripts/runTests.sh -p 7.3
EOF

# Test if docker-compose exists, else exit out with error
if ! type "docker-compose" > /dev/null; then
echo "This script relies on docker and docker-compose. Please install" >&2
exit 1
fi

# Go to the directory this script is located, so everything else is relative
# to this dir, no matter from where this script is called.
THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
cd "$THIS_SCRIPT_DIR" || exit 1

# Go to directory that contains the local docker-compose.yml file
cd ../testing-docker || exit 1

# Option defaults
Expand Down Expand Up @@ -215,49 +191,49 @@ fi
case ${TEST_SUITE} in
acceptance)
setUpDockerComposeDotEnv
docker-compose run acceptance_backend_mariadb10
docker compose run acceptance_backend_mariadb10
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
cgl)
# Active dry-run for cgl needs not "-n" but specific options
if [ -n "${CGLCHECK_DRY_RUN}" ]; then
CGLCHECK_DRY_RUN="--dry-run --diff"
fi
setUpDockerComposeDotEnv
docker-compose run cgl
docker compose run cgl
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
composerInstall)
setUpDockerComposeDotEnv
docker-compose run composer_install
docker compose run composer_install
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
composerValidate)
setUpDockerComposeDotEnv
docker-compose run composer_validate
docker compose run composer_validate
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
functional)
setUpDockerComposeDotEnv
case ${DBMS} in
mariadb)
docker-compose run functional_mariadb10
docker compose run functional_mariadb10
SUITE_EXIT_CODE=$?
;;
mssql)
docker-compose run functional_mssql2019latest
docker compose run functional_mssql2019latest
SUITE_EXIT_CODE=$?
;;
postgres)
docker-compose run functional_postgres10
docker compose run functional_postgres10
SUITE_EXIT_CODE=$?
;;
sqlite)
docker-compose run functional_sqlite
docker compose run functional_sqlite
SUITE_EXIT_CODE=$?
;;
*)
Expand All @@ -266,25 +242,25 @@ case ${TEST_SUITE} in
echo "${HELP}" >&2
exit 1
esac
docker-compose down
docker compose down
;;
lint)
setUpDockerComposeDotEnv
docker-compose run lint
docker compose run lint
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
phpstan)
setUpDockerComposeDotEnv
docker-compose run phpstan
docker compose run phpstan
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
unit)
setUpDockerComposeDotEnv
docker-compose run unit
docker compose run unit
SUITE_EXIT_CODE=$?
docker-compose down
docker compose down
;;
update)
# pull typo3/core-testing-*:latest versions of those ones that exist locally
Expand Down
2 changes: 1 addition & 1 deletion Build/testing-docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ services:
if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
set -x
fi
php -dxdebug.mode=off .Build/vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix -v ${CGLCHECK_DRY_RUN} \
php -dxdebug.mode=off .Build/vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix -v ${CGLCHECK_DRY_RUN} \\
--config=Build/php-cs-fixer.php --using-cache=no
"
Expand Down

0 comments on commit fa9ff54

Please sign in to comment.