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: - run:
name: 'Pull test docker images' name: 'Pull test docker images'
# Pull docker images with 3 retries # 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: - run:
name: Create docker containers for test name: Create docker containers for test
# We experienced some failures when creating containers so we do it explicitly with one retry # We experienced some failures when creating containers so we do it explicitly with one retry
command: | command: |
cd tests/docker cd ../tests_env/docker
docker-compose create || docker-compose create docker-compose create || docker-compose create
- run: - run:
# Some tools we use may need different version based on PHP version used in docker # Some tools we use may need different version based on PHP version used in docker
name: Ensure correct versions of tools name: Ensure correct versions of tools
command: | 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 docker-compose run --rm -w /project -e COMPOSER_DEV_MODE=1 --entrypoint "php tools/install.php" codeception_acceptance
- when: - when:
condition: ${WOOCOMMERCE_VERSION} condition: ${WOOCOMMERCE_VERSION}
@ -459,7 +459,7 @@ jobs:
- run: - run:
name: Download WooCommerce Core name: Download WooCommerce Core
command: | 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 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: - when:
condition: << parameters.woo_subscriptions_version >> condition: << parameters.woo_subscriptions_version >>
@ -467,7 +467,7 @@ jobs:
- run: - run:
name: Download WooCommerce Subscriptions name: Download WooCommerce Subscriptions
command: | 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 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: - when:
condition: << parameters.woo_memberships_version >> condition: << parameters.woo_memberships_version >>
@ -475,7 +475,7 @@ jobs:
- run: - run:
name: Download WooCommerce Memberships name: Download WooCommerce Memberships
command: | 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 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: - when:
condition: << parameters.automate_woo_version >> condition: << parameters.automate_woo_version >>
@ -483,7 +483,7 @@ jobs:
- run: - run:
name: Download AutomateWoo name: Download AutomateWoo
command: | 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 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: - run:
name: Group acceptance tests name: Group acceptance tests
@ -504,7 +504,7 @@ jobs:
name: Run acceptance tests name: Run acceptance tests
command: | command: |
mkdir -m 777 -p tests/_output/exceptions mkdir -m 777 -p tests/_output/exceptions
cd tests/docker cd ../tests_env/docker
args=( args=(
--steps --steps
--debug --debug
@ -728,18 +728,18 @@ jobs:
- run: - run:
name: 'Pull test docker images' name: 'Pull test docker images'
# Pull docker images with 3 retries # 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: - run:
name: Create docker containers for test name: Create docker containers for test
# We experienced some failures when creating containers so we do it explicitly with one retry # We experienced some failures when creating containers so we do it explicitly with one retry
command: | command: |
cd tests/docker cd ../tests_env/docker
docker-compose create || docker-compose create docker-compose create || docker-compose create
- run: - run:
# Some tools we use may need different version based on PHP version used in docker # Some tools we use may need different version based on PHP version used in docker
name: Ensure correct versions of tools name: Ensure correct versions of tools
command: | 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 docker-compose run --rm -w /project -e COMPOSER_DEV_MODE=1 --entrypoint "php tools/install.php" codeception_integration
- when: - when:
condition: ${WOOCOMMERCE_VERSION} condition: ${WOOCOMMERCE_VERSION}
@ -747,7 +747,7 @@ jobs:
- run: - run:
name: Download WooCommerce Core name: Download WooCommerce Core
command: | 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 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: - when:
condition: << parameters.woo_subscriptions_version >> condition: << parameters.woo_subscriptions_version >>
@ -755,7 +755,7 @@ jobs:
- run: - run:
name: Download WooCommerce Subscriptions name: Download WooCommerce Subscriptions
command: | 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 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: - when:
condition: << parameters.woo_memberships_version >> condition: << parameters.woo_memberships_version >>
@ -763,7 +763,7 @@ jobs:
- run: - run:
name: Download WooCommerce Memberships name: Download WooCommerce Memberships
command: | 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 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: - when:
condition: << parameters.automate_woo_version >> condition: << parameters.automate_woo_version >>
@ -771,13 +771,13 @@ jobs:
- run: - run:
name: Download AutomateWoo name: Download AutomateWoo
command: | 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 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: - run:
name: 'PHP Integration tests' name: 'PHP Integration tests'
command: | command: |
mkdir -m 777 -p tests/_output/exceptions mkdir -m 777 -p tests/_output/exceptions
cd tests/docker cd ../tests_env/docker
args=( args=(
--steps --steps
--debug --debug

View File

@ -65,7 +65,7 @@ function getLatestAndPreviousVersions(array $sortedVersions): array {
*/ */
function replaceLatestWordPressVersion(string $latestVersion): void { function replaceLatestWordPressVersion(string $latestVersion): void {
replaceVersionInFile( 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+(})/', '/(wordpress:\${WORDPRESS_IMAGE_VERSION:-\s*)\d+\.\d+\.?\d*-php\d+\.\d+(})/',
'${1}' . $latestVersion . '${2}' '${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 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 - Make PHPStorm listen to connections by clicking on the phone icon
## Local development ## Local development

View File

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

View File

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