Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Use .env for SUITES value
Browse files Browse the repository at this point in the history
  • Loading branch information
markkelnar committed Apr 1, 2021
1 parent cf6f37c commit 91a3935
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .env.dist → .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion .github/workflows/testing-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions bin/run-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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;;
Expand Down
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
ADMIN_EMAIL: [email protected]
ADMIN_USERNAME: admin
ADMIN_PASSWORD: password
USING_XDEBUG: $USING_XDEBUG
USING_XDEBUG: ${USING_XDEBUG:-}
ports:
- '8091:80'
networks:
Expand All @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion docker/app.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions docker/testing.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
27 changes: 14 additions & 13 deletions docker/testing.entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@

# Processes parameters and runs Codeception.
run_tests() {
echo "Running Tests"
if [[ -n "$COVERAGE" ]]; then
local coverage="--coverage --coverage-xml"
fi
if [[ -n "$DEBUG" ]]; then
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
}
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -136,5 +138,4 @@ if [ -f "${TESTS_OUTPUT}/failed" ]; then
exit 1
else
echo "Woohoo! It's working!"
exit 0
fi

0 comments on commit 91a3935

Please sign in to comment.