Skip to content

Commit 73336eb

Browse files
GaryJonesclaude
andcommitted
ci: migrate integration tests from SVN to wp-env
Modernises the integration test infrastructure to use wp-env instead of the legacy SVN-based test setup. GitHub-hosted runners no longer include SVN by default, causing test failures. This migration aligns with WordPress's recommended testing approach and ensures consistency between local development and CI environments. Updates the workflow to install wp-env, removes MySQL service configuration (now provided by wp-env), and eliminates the prepare-ci script. Adds yoast/phpunit-polyfills ^2.0 for PHPUnit 9 compatibility and renames composer scripts to reflect their integration test purpose. Removes bin/install-wp-tests.sh (182 lines) which is no longer needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 4982398 commit 73336eb

File tree

3 files changed

+16
-208
lines changed

3 files changed

+16
-208
lines changed

.github/workflows/integrations.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,15 @@ jobs:
5454
- name: Checkout code
5555
uses: actions/checkout@v4
5656

57+
- name: Install wordpress environment
58+
run: npm install -g @wordpress/env
59+
5760
- name: Setup PHP ${{ matrix.php }}
5861
uses: shivammathur/setup-php@v2
5962
with:
6063
php-version: ${{ matrix.php }}
6164
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
65+
tools: composer
6266

6367
- name: Setup problem matchers for PHP
6468
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
@@ -69,19 +73,14 @@ jobs:
6973
- name: Install Composer dependencies
7074
uses: ramsey/composer-install@v3
7175

72-
- name: Start MySQL Service
73-
run: sudo systemctl start mysql.service
74-
75-
- name: Setting mysql_native_password for PHP <= 7.3
76-
if: ${{ matrix.php <= 7.3 }}
77-
run: mysql -u root -proot -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';"
78-
79-
- name: Prepare environment for integration tests
80-
run: composer prepare-ci --no-interaction
76+
- name: Setup wp-env
77+
run: wp-env start
78+
env:
79+
WP_ENV_CORE: WordPress/WordPress#${{ matrix.wordpress == 'latest' && 'master' || matrix.wordpress }}
8180

8281
- name: Run integration tests
8382
if: ${{ matrix.coverage == false }}
84-
run: composer test --no-interaction
83+
run: composer test-integration --no-interaction
8584

8685
- name: Run integration tests with code coverage
8786
if: ${{ matrix.coverage == true }}

bin/install-wp-tests.sh

Lines changed: 0 additions & 181 deletions
This file was deleted.

composer.json

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"automattic/vipwpcs": "^3",
2323
"php-parallel-lint/php-parallel-lint": "^1.0",
2424
"phpcompatibility/phpcompatibility-wp": "^2.1",
25+
"yoast/phpunit-polyfills": "^2.0",
2526
"yoast/wp-test-utils": "^1"
2627
},
2728
"config": {
@@ -35,9 +36,7 @@
3536
"coverage": [
3637
"@php ./vendor/bin/phpunit --coverage-html ./.phpunit.cache/coverage-html"
3738
],
38-
"coverage-ci": [
39-
"@php ./vendor/bin/phpunit"
40-
],
39+
"coverage-ci": "wp-env run tests-cli --env-cwd=wp-content/plugins/ad-code-manager ./vendor/bin/phpunit",
4140
"cs": [
4241
"@php ./vendor/bin/phpcs -q"
4342
],
@@ -51,27 +50,18 @@
5150
"lint-ci": [
5251
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git --checkstyle"
5352
],
54-
"prepare-ci": [
55-
"bash bin/install-wp-tests.sh wordpress_test root root localhost"
56-
],
57-
"test": [
58-
"@php ./vendor/bin/phpunit --no-coverage --order-by=random"
59-
],
60-
"test-ms": [
61-
"@putenv WP_MULTISITE=1",
62-
"@composer test"
63-
]
53+
"test-integration": "wp-env run tests-cli --env-cwd=wp-content/plugins/ad-code-manager ./vendor/bin/phpunit --no-coverage --order-by=random",
54+
"test-integration-ms": "wp-env run tests-cli --env-cwd=wp-content/plugins/ad-code-manager /bin/bash -c 'WP_MULTISITE=1 ./vendor/bin/phpunit --no-coverage --order-by=random'"
6455
},
6556
"scripts-descriptions": {
6657
"coverage": "Run tests with code coverage reporting",
67-
"coverage-ci": "Run tests with code coverage reporting and send results to stdout",
58+
"coverage-ci": "Run integration tests with code coverage reporting in wp-env",
6859
"cs": "Run PHP Code Sniffer",
6960
"cs-fix": "Run PHP Code Sniffer and fix violations",
7061
"i18n": "Generate a POT file for translation",
7162
"lint": "Run PHP linting",
7263
"lint-ci": "Run PHP linting and send results to stdout",
73-
"prepare-ci": "Prepare the environment for integration tests",
74-
"test": "Run all tests for the Ad Code Manager plugin",
75-
"test-ms": "Run integration tests for the Ad Code Manager plugin in multisite mode"
64+
"test-integration": "Run integration tests in wp-env",
65+
"test-integration-ms": "Run integration tests in multisite mode in wp-env"
7666
}
7767
}

0 commit comments

Comments
 (0)