Skip to content

Commit fa704f4

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. The WordPress matrix now uses concrete version numbers ('6.8') and 'master' instead of 'latest' and 'trunk', as wp-env expects actual Git branch/tag references. Renames composer scripts to reflect their integration test purpose: test → test-integration, test-ms → test-integration-ms. Updates clover.xml output path to .phpunit.cache/coverage/ and adds a workflow step to copy the coverage report from the wp-env container for Codecov upload. 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 fa704f4

File tree

4 files changed

+29
-216
lines changed

4 files changed

+29
-216
lines changed

.github/workflows/integrations.yml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,24 @@ jobs:
2727

2828
strategy:
2929
matrix:
30-
php: [ '7.4', '8.2' ]
30+
php: [ '7.4', '8.3' ]
3131
wordpress: [ '6.4', '6.8' ]
3232
allowed_failure: [false]
3333
coverage: [false]
3434
include:
3535
# Check upcoming WP.
36-
- php: '8.2'
37-
wordpress: 'trunk'
36+
- php: '8.3'
37+
wordpress: 'master'
3838
allowed_failure: true
3939
coverage: false
4040
# Check upcoming PHP.
41-
- php: '8.3'
42-
wordpress: 'latest'
41+
- php: '8.5'
42+
wordpress: '6.8'
4343
allowed_failure: true
4444
coverage: false
4545
# Code coverage on latest PHP and WP.
46-
- php: '8.2'
47-
wordpress: 'latest'
46+
- php: '8.4'
47+
wordpress: '6.8'
4848
allowed_failure: false
4949
coverage: true
5050
fail-fast: false
@@ -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,24 +73,25 @@ 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 }}
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 }}
8887
run: composer coverage-ci --no-interaction
8988

89+
- name: Copy coverage report from wp-env
90+
if: ${{ success() && matrix.coverage == true }}
91+
run: |
92+
CONTAINER_ID=$(docker compose -f /home/runner/.wp-env/docker-compose.yml ps -q tests-wordpress)
93+
docker cp "$CONTAINER_ID:/var/www/html/wp-content/plugins/ad-code-manager/.phpunit.cache/coverage/clover.xml" ./clover.xml
94+
9095
- name: Send coverage report to Codecov
9196
if: ${{ success() && matrix.coverage == true }}
9297
uses: codecov/codecov-action@v5

bin/install-wp-tests.sh

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

composer.json

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@
3535
"coverage": [
3636
"@php ./vendor/bin/phpunit --coverage-html ./.phpunit.cache/coverage-html"
3737
],
38-
"coverage-ci": [
39-
"@php ./vendor/bin/phpunit"
40-
],
38+
"coverage-ci": "wp-env run tests-cli --env-cwd=wp-content/plugins/ad-code-manager ./vendor/bin/phpunit",
4139
"cs": [
4240
"@php ./vendor/bin/phpcs -q"
4341
],
@@ -51,27 +49,18 @@
5149
"lint-ci": [
5250
"@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git --checkstyle"
5351
],
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-
]
52+
"test-integration": "wp-env run tests-cli --env-cwd=wp-content/plugins/ad-code-manager ./vendor/bin/phpunit --no-coverage --order-by=random",
53+
"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'"
6454
},
6555
"scripts-descriptions": {
6656
"coverage": "Run tests with code coverage reporting",
67-
"coverage-ci": "Run tests with code coverage reporting and send results to stdout",
57+
"coverage-ci": "Run integration tests with code coverage reporting in wp-env",
6858
"cs": "Run PHP Code Sniffer",
6959
"cs-fix": "Run PHP Code Sniffer and fix violations",
7060
"i18n": "Generate a POT file for translation",
7161
"lint": "Run PHP linting",
7262
"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"
63+
"test-integration": "Run integration tests in wp-env",
64+
"test-integration-ms": "Run integration tests in multisite mode in wp-env"
7665
}
7766
}

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</include>
2828
<report>
2929
<text outputFile="php://stdout"/>
30-
<clover outputFile="clover.xml"/>
30+
<clover outputFile=".phpunit.cache/coverage/clover.xml"/>
3131
</report>
3232
</coverage>
3333
</phpunit>

0 commit comments

Comments
 (0)