From e94cf49827120fd9e4a1033dae29130de90fba7c Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Tue, 26 Mar 2019 14:55:37 +0100 Subject: [PATCH] Disable SCRIPT_DEBUG for local e2e tests run --- bin/install-wordpress.sh | 31 ++++++++++++++++--------------- bin/reset-e2e-tests.sh | 3 --- bin/run-e2e-tests.sh | 14 -------------- docker-compose.yml | 31 +++++++++++++++++++++++-------- package.json | 2 +- 5 files changed, 40 insertions(+), 41 deletions(-) delete mode 100755 bin/run-e2e-tests.sh diff --git a/bin/install-wordpress.sh b/bin/install-wordpress.sh index 1c7f19e4c2f7f..233bf8a8b145c 100755 --- a/bin/install-wordpress.sh +++ b/bin/install-wordpress.sh @@ -65,6 +65,7 @@ fi # Make sure the uploads and upgrade folders exist and we have permissions to add files. echo -e $(status_message "Ensuring that files can be uploaded...") docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm $CONTAINER chmod 767 /var/www/html/wp-content/plugins +docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm $CONTAINER chmod 767 /var/www/html/wp-config.php docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm $CONTAINER chmod 767 /var/www/html/wp-settings.php docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm $CONTAINER mkdir -p /var/www/html/wp-content/uploads docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm $CONTAINER chmod -v 767 /var/www/html/wp-content/uploads @@ -90,21 +91,6 @@ if [ "$CURRENT_URL" != "http://localhost:$HOST_PORT" ]; then docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI option update siteurl "http://localhost:$HOST_PORT" --quiet fi -# Configure site constants. -echo -e $(status_message "Configuring site constants...") -WP_DEBUG_CURRENT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json WP_DEBUG) -if [ $WP_DEBUG != $WP_DEBUG_CURRENT ]; then - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI config set WP_DEBUG $WP_DEBUG --raw --type=constant --quiet - WP_DEBUG_RESULT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json WP_DEBUG) - echo -e $(status_message "WP_DEBUG: $WP_DEBUG_RESULT...") -fi -SCRIPT_DEBUG_CURRENT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json SCRIPT_DEBUG) -if [ $SCRIPT_DEBUG != $SCRIPT_DEBUG_CURRENT ]; then - docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI config set SCRIPT_DEBUG $SCRIPT_DEBUG --raw --type=constant --quiet - SCRIPT_DEBUG_RESULT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json SCRIPT_DEBUG) - echo -e $(status_message "SCRIPT_DEBUG: $SCRIPT_DEBUG_RESULT...") -fi - # Activate Gutenberg. echo -e $(status_message "Activating Gutenberg...") docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI plugin activate gutenberg --quiet @@ -119,3 +105,18 @@ fi # Install a dummy favicon to avoid 404 errors. echo -e $(status_message "Installing a dummy favicon...") docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm $CONTAINER touch /var/www/html/favicon.ico + +# Configure site constants. +echo -e $(status_message "Configuring site constants...") +WP_DEBUG_CURRENT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json WP_DEBUG) +if [ $WP_DEBUG != $WP_DEBUG_CURRENT ]; then + docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI config set WP_DEBUG $WP_DEBUG --raw --type=constant --quiet + WP_DEBUG_RESULT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json WP_DEBUG) + echo -e $(status_message "WP_DEBUG: $WP_DEBUG_RESULT...") +fi +SCRIPT_DEBUG_CURRENT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json SCRIPT_DEBUG) +if [ $SCRIPT_DEBUG != $SCRIPT_DEBUG_CURRENT ]; then + docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run --rm -u 33 $CLI config set SCRIPT_DEBUG $SCRIPT_DEBUG --raw --type=constant --quiet + SCRIPT_DEBUG_RESULT=$(docker-compose $DOCKER_COMPOSE_FILE_OPTIONS run -T --rm -u 33 $CLI config get --type=constant --format=json SCRIPT_DEBUG) + echo -e $(status_message "SCRIPT_DEBUG: $SCRIPT_DEBUG_RESULT...") +fi diff --git a/bin/reset-e2e-tests.sh b/bin/reset-e2e-tests.sh index 8f6b45c2d7f0d..fb1e080f9da04 100755 --- a/bin/reset-e2e-tests.sh +++ b/bin/reset-e2e-tests.sh @@ -3,8 +3,5 @@ # Exit if any command fails. set -e -# Include useful functions. -. "$(dirname "$0")/includes.sh" - # Set up WordPress site used for end-to-end (e2e) tests. . "$(dirname "$0")/install-wordpress.sh" --e2e_tests diff --git a/bin/run-e2e-tests.sh b/bin/run-e2e-tests.sh deleted file mode 100755 index 98a6c17930972..0000000000000 --- a/bin/run-e2e-tests.sh +++ /dev/null @@ -1,14 +0,0 @@ -# Exit if any command fails -set -e - -# Change to the expected directory -cd "$(dirname "$0")/../" - -# Setup local environement -( ./bin/setup-local-env.sh ) - -if [ "$E2E_ROLE" = "author" ]; then - WP_PASSWORD=authpass WP_USERNAME=author npm run test-e2e -else - npm run test-e2e -fi diff --git a/docker-compose.yml b/docker-compose.yml index 7093c39a82823..f7733df2c71b6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,16 +4,18 @@ services: wordpress: image: wordpress + restart: always ports: - 8888:80 environment: + WORDPRESS_DB_HOST: mysql WORDPRESS_DB_PASSWORD: example ABSPATH: /usr/src/wordpress/ WORDPRESS_DEBUG: 1 WORDPRESS_CONFIG_EXTRA: | - define('SCRIPT_DEBUG', true ); + define( 'SCRIPT_DEBUG', true ); volumes: - - wordpress:/var/www/html + - wordpress_data:/var/www/html - .:/var/www/html/wp-content/plugins/gutenberg - ./packages/e2e-tests/plugins:/var/www/html/wp-content/plugins/gutenberg-test-plugins - ./packages/e2e-tests/mu-plugins:/var/www/html/wp-content/mu-plugins @@ -22,9 +24,10 @@ services: cli: image: wordpress:cli + restart: always user: xfs volumes: - - wordpress:/var/www/html + - wordpress_data:/var/www/html - .:/var/www/html/wp-content/plugins/gutenberg depends_on: - mysql @@ -32,12 +35,14 @@ services: mysql: image: mysql:5.7 + restart: always environment: MYSQL_ROOT_PASSWORD: example MYSQL_DATABASE: wordpress_test wordpress_phpunit: image: chriszarate/wordpress-phpunit + restart: always environment: PHPUNIT_DB_HOST: mysql volumes: @@ -48,33 +53,43 @@ services: composer: image: composer + restart: always volumes: - .:/app wordpress_e2e_tests: image: wordpress + restart: always ports: - 8889:80 environment: + WORDPRESS_DB_HOST: mysql WORDPRESS_DB_NAME: wordpress_e2e_tests WORDPRESS_DB_PASSWORD: example ABSPATH: /usr/src/wordpress/ WORDPRESS_DEBUG: 1 WORDPRESS_CONFIG_EXTRA: | - define('SCRIPT_DEBUG', true ); + define( 'SCRIPT_DEBUG', true ); volumes: - - wordpress_e2e_tests:/var/www/html + - wordpress_e2e_tests_data:/var/www/html - .:/var/www/html/wp-content/plugins/gutenberg - ./packages/e2e-tests/plugins:/var/www/html/wp-content/plugins/gutenberg-test-plugins - ./packages/e2e-tests/mu-plugins:/var/www/html/wp-content/mu-plugins + depends_on: + - mysql cli_e2e_tests: image: wordpress:cli + restart: always + user: xfs volumes: - - wordpress_e2e_tests:/var/www/html + - wordpress_e2e_tests_data:/var/www/html - .:/var/www/html/wp-content/plugins/gutenberg + depends_on: + - mysql + - wordpress_e2e_tests volumes: testsuite: - wordpress: - wordpress_e2e_tests: + wordpress_data: + wordpress_e2e_tests_data: diff --git a/package.json b/package.json index 19e694f2e373e..f63075eaa1525 100644 --- a/package.json +++ b/package.json @@ -183,7 +183,7 @@ "publish:dev": "npm run build:packages && lerna publish --npm-tag next", "publish:prod": "npm run build:packages && lerna publish", "test": "npm run lint && npm run test-unit", - "pretest-e2e": "./bin/reset-e2e-tests.sh", + "pretest-e2e": "cross-env SCRIPT_DEBUG=false ./bin/reset-e2e-tests.sh", "test-e2e": "wp-scripts test-e2e --config packages/e2e-tests/jest.config.js", "test-e2e:watch": "npm run test-e2e -- --watch", "test-php": "npm run lint-php && npm run test-unit-php",