Move tests docker configuration

Because we want to unify tests environment in the premium plugin. This step should allow us to reuse it easier.
[PREMIUM-230]
This commit is contained in:
Jan Lysý
2024-07-23 16:41:24 +02:00
committed by alex-mpoet
parent 6805d68ede
commit 22584747a0
8 changed files with 34 additions and 33 deletions

View File

@ -440,18 +440,18 @@ jobs:
- run:
name: 'Pull test docker images'
# Pull docker images with 3 retries
command: i='0';while ! docker-compose -f tests/docker/docker-compose.yml pull && ((i < 3)); do sleep 3 && i=$[$i+1]; done
command: i='0';while ! docker-compose -f ../tests_env/docker/docker-compose.yml pull && ((i < 3)); do sleep 3 && i=$[$i+1]; done
- run:
name: Create docker containers for test
# We experienced some failures when creating containers so we do it explicitly with one retry
command: |
cd tests/docker
cd ../tests_env/docker
docker-compose create || docker-compose create
- run:
# Some tools we use may need different version based on PHP version used in docker
name: Ensure correct versions of tools
command: |
cd tests/docker
cd ../tests_env/docker
docker-compose run --rm -w /project -e COMPOSER_DEV_MODE=1 --entrypoint "php tools/install.php" codeception_acceptance
- when:
condition: ${WOOCOMMERCE_VERSION}
@ -459,7 +459,7 @@ jobs:
- run:
name: Download WooCommerce Core
command: |
cd tests/docker
cd ../tests_env/docker
docker-compose run --rm -w /project --entrypoint "./do download:woo-commerce-zip ${WOOCOMMERCE_VERSION}" --no-deps -e WP_GITHUB_USERNAME=${WP_GITHUB_USERNAME} -e WP_GITHUB_TOKEN=${WP_GITHUB_TOKEN} codeception_acceptance
- when:
condition: << parameters.woo_subscriptions_version >>
@ -467,7 +467,7 @@ jobs:
- run:
name: Download WooCommerce Subscriptions
command: |
cd tests/docker
cd ../tests_env/docker
docker-compose run --rm -w /project --entrypoint "./do download:woo-commerce-subscriptions-zip << parameters.woo_subscriptions_version >>" --no-deps -e WP_GITHUB_USERNAME=${WP_GITHUB_USERNAME} -e WP_GITHUB_TOKEN=${WP_GITHUB_TOKEN} codeception_acceptance
- when:
condition: << parameters.woo_memberships_version >>
@ -475,7 +475,7 @@ jobs:
- run:
name: Download WooCommerce Memberships
command: |
cd tests/docker
cd ../tests_env/docker
docker-compose run --rm -w /project --entrypoint "./do download:woo-commerce-memberships-zip << parameters.woo_memberships_version >>" --no-deps -e WP_GITHUB_USERNAME=${WP_GITHUB_USERNAME} -e WP_GITHUB_TOKEN=${WP_GITHUB_TOKEN} codeception_acceptance
- when:
condition: << parameters.automate_woo_version >>
@ -483,7 +483,7 @@ jobs:
- run:
name: Download AutomateWoo
command: |
cd tests/docker
cd ../tests_env/docker
docker-compose run --rm -w /project --entrypoint "./do download:automate-woo-zip << parameters.automate_woo_version >>" --no-deps -e WP_GITHUB_USERNAME=${WP_GITHUB_USERNAME} -e WP_GITHUB_TOKEN=${WP_GITHUB_TOKEN} codeception_acceptance
- run:
name: Group acceptance tests
@ -504,7 +504,7 @@ jobs:
name: Run acceptance tests
command: |
mkdir -m 777 -p tests/_output/exceptions
cd tests/docker
cd ../tests_env/docker
args=(
--steps
--debug
@ -728,18 +728,18 @@ jobs:
- run:
name: 'Pull test docker images'
# Pull docker images with 3 retries
command: i='0';while ! docker-compose -f tests/docker/docker-compose.yml pull && ((i < 3)); do sleep 3 && i=$[$i+1]; done
command: i='0';while ! docker-compose -f ../tests_env/docker/docker-compose.yml pull && ((i < 3)); do sleep 3 && i=$[$i+1]; done
- run:
name: Create docker containers for test
# We experienced some failures when creating containers so we do it explicitly with one retry
command: |
cd tests/docker
cd ../tests_env/docker
docker-compose create || docker-compose create
- run:
# Some tools we use may need different version based on PHP version used in docker
name: Ensure correct versions of tools
command: |
cd tests/docker
cd ../tests_env/docker
docker-compose run --rm -w /project -e COMPOSER_DEV_MODE=1 --entrypoint "php tools/install.php" codeception_integration
- when:
condition: ${WOOCOMMERCE_VERSION}
@ -747,7 +747,7 @@ jobs:
- run:
name: Download WooCommerce Core
command: |
cd tests/docker
cd ../tests_env/docker
docker-compose run --rm -w /project --entrypoint "./do download:woo-commerce-zip ${WOOCOMMERCE_VERSION}" --no-deps -e WP_GITHUB_USERNAME=${WP_GITHUB_USERNAME} -e WP_GITHUB_TOKEN=${WP_GITHUB_TOKEN} codeception_integration
- when:
condition: << parameters.woo_subscriptions_version >>
@ -755,7 +755,7 @@ jobs:
- run:
name: Download WooCommerce Subscriptions
command: |
cd tests/docker
cd ../tests_env/docker
docker-compose run --rm -w /project --entrypoint "./do download:woo-commerce-subscriptions-zip << parameters.woo_subscriptions_version >>" --no-deps -e WP_GITHUB_USERNAME=${WP_GITHUB_USERNAME} -e WP_GITHUB_TOKEN=${WP_GITHUB_TOKEN} codeception_integration
- when:
condition: << parameters.woo_memberships_version >>
@ -763,7 +763,7 @@ jobs:
- run:
name: Download WooCommerce Memberships
command: |
cd tests/docker
cd ../tests_env/docker
docker-compose run --rm -w /project --entrypoint "./do download:woo-commerce-memberships-zip << parameters.woo_memberships_version >>" --no-deps -e WP_GITHUB_USERNAME=${WP_GITHUB_USERNAME} -e WP_GITHUB_TOKEN=${WP_GITHUB_TOKEN} codeception_integration
- when:
condition: << parameters.automate_woo_version >>
@ -771,13 +771,13 @@ jobs:
- run:
name: Download AutomateWoo
command: |
cd tests/docker
cd ../tests_env/docker
docker-compose run --rm -w /project --entrypoint "./do download:automate-woo-zip << parameters.automate_woo_version >>" --no-deps -e WP_GITHUB_USERNAME=${WP_GITHUB_USERNAME} -e WP_GITHUB_TOKEN=${WP_GITHUB_TOKEN} codeception_integration
- run:
name: 'PHP Integration tests'
command: |
mkdir -m 777 -p tests/_output/exceptions
cd tests/docker
cd ../tests_env/docker
args=(
--steps
--debug

View File

@ -65,7 +65,7 @@ function getLatestAndPreviousVersions(array $sortedVersions): array {
*/
function replaceLatestWordPressVersion(string $latestVersion): void {
replaceVersionInFile(
__DIR__ . './../../../mailpoet/tests/docker/docker-compose.yml',
__DIR__ . './../../../tests_env/docker/docker-compose.yml',
'/(wordpress:\${WORDPRESS_IMAGE_VERSION:-\s*)\d+\.\d+\.?\d*-php\d+\.\d+(})/',
'${1}' . $latestVersion . '${2}'
);

View File

@ -85,7 +85,7 @@ mailpoet/vendor/bin/codecept -> /project/vendor/bin/codecept
mailpoet/vendor/bin/wp -> /usr/local/bin/wp
```
- Add `XDEBUG_TRIGGER: 1` environment to `mailpoet/tests/docker/docker-compose.yml` -> codeception service to start triggering Xdebug
- Add `XDEBUG_TRIGGER: 1` environment to `tests_env/docker/docker-compose.yml` -> codeception service to start triggering Xdebug
- Make PHPStorm listen to connections by clicking on the phone icon
## Local development

View File

@ -493,7 +493,7 @@ class RoboFile extends \Robo\Tasks {
public function deleteDocker() {
return $this->taskExec(
'docker-compose down -v --remove-orphans --rmi all'
)->dir(__DIR__ . '/tests/docker')->run();
)->dir(__DIR__ . '/../tests_env/docker')->run();
}
/**
@ -503,7 +503,7 @@ class RoboFile extends \Robo\Tasks {
return $this
->taskExec(
'docker-compose down -v --remove-orphans'
)->dir(__DIR__ . '/tests/docker')
)->dir(__DIR__ . '/../tests_env/docker')
->addCode([$this, 'cleanupCachedFiles'])
->run();
}
@ -1637,7 +1637,7 @@ class RoboFile extends \Robo\Tasks {
(isset($opts['skip-group']) && $opts['skip-group'] ? '--skip-group ' . $opts['skip-group'] . ' ' : '') .
(isset($opts['stop-on-fail']) && $opts['stop-on-fail'] ? '-f ' : '') .
(isset($opts['file']) && $opts['file'] ? $opts['file'] : '')
)->dir(__DIR__ . '/tests/docker')->run();
)->dir(__DIR__ . '/../tests_env/docker')->run();
}
private function getParallelism(int $multiplier = 1, int $min = 4, int $max = 32): int {

View File

@ -8,12 +8,12 @@ services:
volumes:
- wp-core:/wp-core
- mailhog-data:/mailhog-data
- ../..:/project
- ../..:/wp-core/wp-content/plugins/mailpoet
- ../../../mailpoet-premium:/project/mailpoet-premium
- ../../mailpoet:/project
- ../../mailpoet:/wp-core/wp-content/plugins/mailpoet
- ../../mailpoet-premium:/project/mailpoet-premium
- ./codeception/docker-entrypoint.sh:/docker-entrypoint.sh
- ../../../dev/php.ini:/usr/local/etc/php/conf.d/php_user.ini
- ../../../dev/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
- ../../dev/php.ini:/usr/local/etc/php/conf.d/php_user.ini
- ../../dev/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
entrypoint: /docker-entrypoint.sh
environment:
WP_ROOT: /wp-core
@ -35,12 +35,12 @@ services:
volumes:
- wp-core:/wp-core
- mailhog-data:/mailhog-data
- ../..:/project
- ../..:/wp-core/wp-content/plugins/mailpoet
- ../../../mailpoet-premium:/project/mailpoet-premium
- ../../mailpoet:/project
- ../../mailpoet:/wp-core/wp-content/plugins/mailpoet
- ../../mailpoet-premium:/project/mailpoet-premium
- ./codeception/docker-entrypoint.sh:/docker-entrypoint.sh
- ../../../dev/php.ini:/usr/local/etc/php/conf.d/php_user.ini
- ../../../dev/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
- ../../dev/php.ini:/usr/local/etc/php/conf.d/php_user.ini
- ../../dev/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
entrypoint: /docker-entrypoint.sh
environment:
WP_ROOT: /wp-core
@ -79,8 +79,9 @@ services:
volumes:
- wp-core:/var/www/html
- ./install-extensions.sh:/usr/local/bin/install-extensions.sh
- ../..:/var/www/html/wp-content/plugins/mailpoet
- ../../../mailpoet-premium:/project/mailpoet-premium
- ../../mailpoet:/project
- ../../mailpoet:/var/www/html/wp-content/plugins/mailpoet
- ../../mailpoet-premium:/project/mailpoet-premium
tmpfs:
- /var/www/html/wp-content/uploads/mailpoet/
ports: