From 57efa880f6ead1e101c2003a4c2dd51c3ab29dbf Mon Sep 17 00:00:00 2001 From: Achim Fritz Date: Thu, 1 Aug 2024 23:09:41 +0200 Subject: [PATCH] [TASK] use docker compose v2 --- Build/Scripts/runTests.sh | 64 ++++++++----------------- Build/testing-docker/docker-compose.yml | 2 +- 2 files changed, 21 insertions(+), 45 deletions(-) diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh index 3d38b37..debc00a 100755 --- a/Build/Scripts/runTests.sh +++ b/Build/Scripts/runTests.sh @@ -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 @@ -35,14 +21,10 @@ setUpDockerComposeDotEnv() { # Load help text into $HELP read -r -d '' HELP < @@ -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 @@ -215,9 +191,9 @@ 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 @@ -225,39 +201,39 @@ case ${TEST_SUITE} in 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=$? ;; *) @@ -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 diff --git a/Build/testing-docker/docker-compose.yml b/Build/testing-docker/docker-compose.yml index 79d01d2..90a2933 100644 --- a/Build/testing-docker/docker-compose.yml +++ b/Build/testing-docker/docker-compose.yml @@ -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 "