Skip to content

Commit

Permalink
Replace docker-compose with docker compose to ensure GH actions c…
Browse files Browse the repository at this point in the history
…ontinue to run (#9212)
  • Loading branch information
Jinksi committed Aug 5, 2024
1 parent dbfd6b6 commit 5fd5ff2
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 22 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ Docker can be used to setup a local development environment:

* Ensure Docker is installed ([Docker Desktop](https://www.docker.com/products/docker-desktop) is a good option for developers)
* Follow the steps above in the Development section to build the project's JavaScript
* From the root of this project, run `docker-compose up -d`
* From the root of this project, run `docker compose up -d`
* Once <http://localhost:8082> displays the WordPress install screen, run `./bin/docker-setup.sh`
* The fully configured site can now be accessed on <http://localhost:8082>
* The prompt to run the setup wizard can be dismissed unless there is something specific you would like to configure

To shutdown:

* Use `docker-compose down` to stop the running containers
* The state of the environment will be persisted in `docker/wordpress` and `docker/data`. To restart the environment simply run `docker-compose up` again. To start afresh, delete these folders and let `docker-compose up` re-create them.
* Use `docker compose down` to stop the running containers
* The state of the environment will be persisted in `docker/wordpress` and `docker/data`. To restart the environment simply run `docker compose up` again. To start afresh, delete these folders and let `docker compose up` re-create them.

IDE setup:

Expand Down
4 changes: 2 additions & 2 deletions bin/check-test-coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ fi

echo "Installing the test environment..."

docker-compose exec -u www-data wordpress \
docker compose exec -u www-data wordpress \
/var/www/html/wp-content/plugins/woocommerce-payments/bin/install-wp-tests.sh

echo "Checking coverage..."

docker-compose exec -u www-data wordpress \
docker compose exec -u www-data wordpress \
php -d xdebug.remote_autostart=on \
/var/www/html/wp-content/plugins/woocommerce-payments/vendor/bin/phpunit \
--configuration "/var/www/html/wp-content/plugins/woocommerce-payments/$CONFIGURATION_FILE" \
Expand Down
2 changes: 1 addition & 1 deletion bin/cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ fi

command=${command:-bash}

docker-compose exec -u ${user} wordpress ${command}
docker compose exec -u ${user} wordpress ${command}
6 changes: 3 additions & 3 deletions bin/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ done

echo "Installing the test environment..."

docker-compose exec -u www-data wordpress \
docker compose exec -u www-data wordpress \
/var/www/html/wp-content/plugins/woocommerce-payments/bin/install-wp-tests.sh

if $WATCH_FLAG; then
echo "Running the tests on watch mode..."

# Change directory to WooCommerce Payments' root in order to have access to .phpunit-watcher.yml
docker-compose exec -u www-data wordpress bash -c \
docker compose exec -u www-data wordpress bash -c \
"cd /var/www/html/wp-content/plugins/woocommerce-payments && \
php -d xdebug.remote_autostart=on \
./vendor/bin/phpunit-watcher watch --configuration ./phpunit.xml.dist $*"
else
echo "Running the tests..."

docker-compose exec -u www-data wordpress \
docker compose exec -u www-data wordpress \
php -d xdebug.remote_autostart=on \
/var/www/html/wp-content/plugins/woocommerce-payments/vendor/bin/phpunit \
--configuration /var/www/html/wp-content/plugins/woocommerce-payments/phpunit.xml.dist \
Expand Down
4 changes: 4 additions & 0 deletions changelog/fix-9205-use-docker-compose-v2-commands
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Migrate to Docker Compose V2 for test runner environment setup scripts
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@
"hmr": "webpack server",
"start": "npm run watch",
"dev": "npm run up && npm run watch",
"up:recreate": "docker-compose up --build --force-recreate -d && ./bin/docker-setup.sh",
"up": "docker-compose up --build -d",
"down": "docker-compose down",
"wp": "docker-compose exec -u www-data wordpress wp",
"up:recreate": "docker compose up --build --force-recreate -d && ./bin/docker-setup.sh",
"up": "docker compose up --build -d",
"down": "docker compose down",
"wp": "docker compose exec -u www-data wordpress wp",
"install-if-deps-outdated": "node bin/install-if-deps-outdated.js",
"lint": "npm run lint:js && npm run lint:css && npm run lint:php",
"lint:css": "stylelint 'client/**/*.scss' 'client/**/*.css' 'assets/**/*.scss' 'assets/**/*.css'",
Expand All @@ -70,7 +70,7 @@
"tube:start": "./docker/bin/jt/tunnel.sh",
"tube:stop": "./docker/bin/jt/tunnel.sh break",
"psalm": "./bin/run-psalm.sh",
"xdebug:toggle": "docker-compose exec -u root wordpress /var/www/html/wp-content/plugins/woocommerce-payments/bin/xdebug-toggle.sh",
"xdebug:toggle": "docker compose exec -u root wordpress /var/www/html/wp-content/plugins/woocommerce-payments/bin/xdebug-toggle.sh",
"changelog": "./vendor/bin/changelogger add",
"cli": "./bin/cli.sh"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This guide follows the [WooCommerce guide to unit tests](https://github.com/wooc

## Setup for running tests in the docker containers

1. From the plugin directory, run `npm run up` or `docker-compose up -d`
1. From the plugin directory, run `npm run up` or `docker compose up -d`
2. Once the containers are up, run the tests from the plugin root directory using `npm test`
- Tests can be run in watch mode using `npm run test:watch` and `npm run test:php-watch` for JavaScript and PHP unit tests respectively

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/env/down.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ if [[ -f "$E2E_ROOT/config/local.env" ]]; then
fi

step "Stopping client containers"
docker-compose -f $E2E_ROOT/env/docker-compose.yml down
docker compose -f $E2E_ROOT/env/docker-compose.yml down

if [[ "$E2E_USE_LOCAL_SERVER" != false ]]; then
step "Stopping server containers"
docker-compose -f $E2E_ROOT/deps/wcp-server/docker-compose.yml down
docker compose -f $E2E_ROOT/deps/wcp-server/docker-compose.yml down
fi
6 changes: 3 additions & 3 deletions tests/e2e/env/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ if [[ "$E2E_USE_LOCAL_SERVER" != false ]]; then
echo "Secrets created"

step "Starting SERVER containers"
redirect_output docker-compose -f docker-compose.yml -f docker-compose.e2e.yml up --build --force-recreate -d
redirect_output docker compose -f docker-compose.yml -f docker-compose.e2e.yml up --build --force-recreate -d

# Get WordPress instance port number from running containers, and print a debug line to show if it works.
WP_LISTEN_PORT=$(docker ps | grep "$SERVER_CONTAINER" | sed -En "s/.*0:([0-9]+).*/\1/p")
Expand Down Expand Up @@ -104,9 +104,9 @@ if [[ ! -d "$DEV_TOOLS_PATH" ]]; then
fi

step "Starting CLIENT containers"
redirect_output docker-compose -f "$E2E_ROOT"/env/docker-compose.yml up --build --force-recreate -d wordpress
redirect_output docker compose -f "$E2E_ROOT"/env/docker-compose.yml up --build --force-recreate -d wordpress
if [[ -z $CI ]]; then
docker-compose -f "$E2E_ROOT"/env/docker-compose.yml up --build --force-recreate -d phpMyAdmin
docker compose -f "$E2E_ROOT"/env/docker-compose.yml up --build --force-recreate -d phpMyAdmin
fi

if [[ -n $CI ]]; then
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/env/up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ if [[ -f "$E2E_ROOT/config/local.env" ]]; then
fi

step "Starting client containers"
docker-compose -f "$E2E_ROOT/env/docker-compose.yml" start
docker compose -f "$E2E_ROOT/env/docker-compose.yml" start

if [[ "$E2E_USE_LOCAL_SERVER" != false ]]; then
step "Starting server containers"
docker-compose -f "$E2E_ROOT/deps/wcp-server/docker-compose.yml" start
docker compose -f "$E2E_ROOT/deps/wcp-server/docker-compose.yml" start
fi

0 comments on commit 5fd5ff2

Please sign in to comment.