Skip to content

Commit 6f24cd7

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. Removes the Codecov integration from CI (coverage can still be run locally via composer scripts). Simplifies the matrix by removing coverage-specific configurations. Renames composer scripts to reflect their integration test purpose: test → test-integration, test-ms → test-integration-ms. 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 6f24cd7

File tree

4 files changed

+22
-237
lines changed

4 files changed

+22
-237
lines changed

.github/workflows/integrations.yml

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,38 +27,34 @@ 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]
33-
coverage: [false]
3433
include:
3534
# Check upcoming WP.
36-
- php: '8.2'
37-
wordpress: 'trunk'
35+
- php: '8.3'
36+
wordpress: 'master'
3837
allowed_failure: true
39-
coverage: false
4038
# Check upcoming PHP.
41-
- php: '8.3'
42-
wordpress: 'latest'
39+
- php: '8.5'
40+
wordpress: '6.8'
4341
allowed_failure: true
44-
coverage: false
45-
# Code coverage on latest PHP and WP.
46-
- php: '8.2'
47-
wordpress: 'latest'
48-
allowed_failure: false
49-
coverage: true
5042
fail-fast: false
5143
continue-on-error: ${{ matrix.allowed_failure }}
5244

5345
steps:
5446
- name: Checkout code
5547
uses: actions/checkout@v4
5648

49+
- name: Install wordpress environment
50+
run: npm install -g @wordpress/env
51+
5752
- name: Setup PHP ${{ matrix.php }}
5853
uses: shivammathur/setup-php@v2
5954
with:
6055
php-version: ${{ matrix.php }}
61-
coverage: ${{ matrix.coverage && 'xdebug' || 'none' }}
56+
coverage: none
57+
tools: composer
6258

6359
- name: Setup problem matchers for PHP
6460
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
@@ -69,29 +65,10 @@ jobs:
6965
- name: Install Composer dependencies
7066
uses: ramsey/composer-install@v3
7167

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
68+
- name: Setup wp-env
69+
run: wp-env start
70+
env:
71+
WP_ENV_CORE: WordPress/WordPress#${{ matrix.wordpress }}
8172

8273
- name: Run integration tests
83-
if: ${{ matrix.coverage == false }}
84-
run: composer test --no-interaction
85-
86-
- name: Run integration tests with code coverage
87-
if: ${{ matrix.coverage == true }}
88-
run: composer coverage-ci --no-interaction
89-
90-
- name: Send coverage report to Codecov
91-
if: ${{ success() && matrix.coverage == true }}
92-
uses: codecov/codecov-action@v5
93-
with:
94-
files: ./clover.xml
95-
fail_ci_if_error: true
96-
token: ${{ secrets.CODECOV_TOKEN }}
97-
verbose: true
74+
run: composer test-integration --no-interaction

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)