From 91a39356e245151ee7eb276d1f799146acc512ac Mon Sep 17 00:00:00 2001 From: Mark Kelnar Date: Thu, 1 Apr 2021 13:03:45 -0500 Subject: [PATCH] Use .env for SUITES value --- .env.dist => .env | 2 +- .github/workflows/testing-integration.yml | 1 - bin/run-docker.sh | 4 ---- docker-compose.yml | 6 +++-- docker/app.Dockerfile | 2 +- docker/testing.Dockerfile | 3 +-- docker/testing.entrypoint.sh | 27 ++++++++++++----------- 7 files changed, 21 insertions(+), 24 deletions(-) rename .env.dist => .env (96%) diff --git a/.env.dist b/.env similarity index 96% rename from .env.dist rename to .env index c9ce93c..ed0daed 100644 --- a/.env.dist +++ b/.env @@ -26,6 +26,6 @@ TESTS_DATA=tests/_data TESTS_SUPPORT=tests/_support TESTS_ENVS=tests/_envs -CORE_BRANCH=develop +CORE_VERSION=v1.3.3 SKIP_TESTS_CLEANUP=1 SUITES=wpunit diff --git a/.github/workflows/testing-integration.yml b/.github/workflows/testing-integration.yml index 98d8572..79ae68c 100644 --- a/.github/workflows/testing-integration.yml +++ b/.github/workflows/testing-integration.yml @@ -72,7 +72,6 @@ jobs: USING_XDEBUG: ${{ matrix.coverage }} DEBUG: ${{ matrix.debug }} SKIP_TESTS_CLEANUP: ${{ matrix.coverage }} - LOWEST: ${{ matrix.lowest }} run: composer run-test - name: Push Codecoverage to Coveralls.io diff --git a/bin/run-docker.sh b/bin/run-docker.sh index 6ddf4d1..8486ef0 100644 --- a/bin/run-docker.sh +++ b/bin/run-docker.sh @@ -61,14 +61,10 @@ case "$subcommand" in ;; a ) docker-compose up --scale testing=0;; t ) - source ${env_file} docker-compose run --rm \ - -e SUITES=${SUITES-} \ -e COVERAGE=${COVERAGE-} \ -e USING_XDEBUG=${USING_XDEBUG-} \ -e DEBUG=${DEBUG-} \ - -e SKIP_TESTS_CLEANUP=${SKIP_TESTS_CLEANUP-} \ - -e LOWEST=${LOWEST-} \ testing --scale app=0 ;; \? ) print_usage_instructions;; diff --git a/docker-compose.yml b/docker-compose.yml index 453deff..f6a7a88 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,7 +19,7 @@ services: ADMIN_EMAIL: admin@example.com ADMIN_USERNAME: admin ADMIN_PASSWORD: password - USING_XDEBUG: $USING_XDEBUG + USING_XDEBUG: ${USING_XDEBUG:-} ports: - '8091:80' networks: @@ -46,11 +46,13 @@ services: - '.:/var/www/html/wp-content/plugins/wp-graphql-acf' - './.log/testing:/var/log/apache2' - './codeception.dist.yml:/var/www/html/wp-content/plugins/wp-graphql-acf/codeception.yml' - env_file: .env.dist + env_file: + - .env environment: DB_HOST: app_db WP_URL: 'http://localhost' WP_DOMAIN: 'localhost' + SUITES: ${SUITES:-} networks: testing: diff --git a/docker/app.Dockerfile b/docker/app.Dockerfile index d1aa3dc..355aea2 100644 --- a/docker/app.Dockerfile +++ b/docker/app.Dockerfile @@ -68,7 +68,7 @@ RUN echo "Installing XDebug 3 (in disabled state)" \ ; # Set xdebug configuration off by default. See the entrypoint.sh. -ENV USING_XDEBUG=0 +ENV USING_XDEBUG=${USING_XDEBUG} # Set up entrypoint WORKDIR /var/www/html diff --git a/docker/testing.Dockerfile b/docker/testing.Dockerfile index a400af5..cdec274 100644 --- a/docker/testing.Dockerfile +++ b/docker/testing.Dockerfile @@ -19,6 +19,7 @@ RUN apt-get install zip unzip -y \ && pecl install pcov ENV COVERAGE=0 +ENV SUITES=${SUITES:-zz} # Install composer ENV COMPOSER_ALLOW_SUPERUSER=1 @@ -30,8 +31,6 @@ RUN curl -sS https://getcomposer.org/installer | php -- \ # Add composer global binaries to PATH ENV PATH "$PATH:~/.composer/vendor/bin" - - # Configure php RUN echo "date.timezone = UTC" >> /usr/local/etc/php/php.ini diff --git a/docker/testing.entrypoint.sh b/docker/testing.entrypoint.sh index cf06434..36f6aa5 100644 --- a/docker/testing.entrypoint.sh +++ b/docker/testing.entrypoint.sh @@ -2,7 +2,6 @@ # Processes parameters and runs Codeception. run_tests() { - echo "Running Tests" if [[ -n "$COVERAGE" ]]; then local coverage="--coverage --coverage-xml" fi @@ -10,9 +9,14 @@ run_tests() { local debug="--debug" fi - local suites=${1:-" ;"} - IFS=';' read -ra target_suites <<< "$suites" - for suite in "${target_suites[@]}"; do + local suites=$1 + if [[ -z "$suites" ]]; then + echo "No test suites specified. Must specify variable SUITES." + exit 1 + fi + + for suite in $suites ; do + echo "Running Test Suite $suite" vendor/bin/codecept run -c codeception.dist.yml ${suite} ${coverage:-} ${debug:-} --no-exit done } @@ -63,13 +67,11 @@ if [ ! -f "$PROJECT_DIR/c3.php" ]; then curl -L 'https://raw.github.com/Codeception/c3/2.0/c3.php' > "$PROJECT_DIR/c3.php" fi -if [[ -n "$LOWEST" ]]; then - PREFER_LOWEST="--prefer-source" -fi - # Install dependencies -COMPOSER_MEMORY_LIMIT=-1 composer update --prefer-source ${PREFER_LOWEST} -COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-source --no-interaction +echo "Running composer update" +COMPOSER_MEMORY_LIMIT=-1 composer update +echo "Running composer install" +COMPOSER_MEMORY_LIMIT=-1 composer install --no-interaction # Install pcov/clobber if PHP7.1+ if version_gt $PHP_VERSION 7.0 && [[ -n "$COVERAGE" ]] && [[ -z "$USING_XDEBUG" ]]; then @@ -79,7 +81,7 @@ if version_gt $PHP_VERSION 7.0 && [[ -n "$COVERAGE" ]] && [[ -z "$USING_XDEBUG" echo "pcov.directory = /var/www/html/wp-content/plugins/wp-graphql" >> /usr/local/etc/php/conf.d/docker-php-ext-pcov.ini COMPOSER_MEMORY_LIMIT=-1 composer require --dev pcov/clobber vendor/bin/pcov clobber -elif [[ -n "$COVERAGE" ]] && [[ -z "$USING_XDEBUG" ]]; then +elif [[ -n "$COVERAGE" ]] && [[ -n "$USING_XDEBUG" ]]; then echo "Using XDebug for codecoverage" fi @@ -88,7 +90,7 @@ echo "Setting Codeception output directory permissions" chmod 777 ${TESTS_OUTPUT} # Run tests -run_tests ${SUITES} +run_tests "${SUITES}" # Remove c3.php if [ -f "$PROJECT_DIR/c3.php" ] && [ "$SKIP_TESTS_CLEANUP" != "1" ]; then @@ -136,5 +138,4 @@ if [ -f "${TESTS_OUTPUT}/failed" ]; then exit 1 else echo "Woohoo! It's working!" - exit 0 fi