Skip to content

Commit 8f7f203

Browse files
committed
Automatically set up test environment, improve config
1 parent 5502d1e commit 8f7f203

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

.github/workflows/wp-tests-end-to-end.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ jobs:
2727
- name: Install Playwright browsers
2828
run: npx playwright install --with-deps
2929

30-
- name: Setup WordPress test environment
31-
run: composer run wp-setup
32-
33-
- name: Start WordPress test environment
34-
run: composer run wp-test-start
35-
3630
- name: Run WordPress end-to-end tests
3731
run: composer run wp-test-e2e
3832

.github/workflows/wp-tests-phpunit.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ jobs:
2424
echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
2525
echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
2626
27-
- name: Setup WordPress test environment
28-
run: composer run wp-setup
29-
30-
- name: Start WordPress test environment
31-
run: composer run wp-test-start
32-
3327
- name: Run WordPress PHPUnit tests
3428
run: node .github/workflows/wp-tests-phpunit-run.js
3529

composer.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,23 @@
5151
"npm --prefix wordpress run env:cli -- plugin install gutenberg",
5252
"npm --prefix wordpress run env:cli -- plugin install query-monitor"
5353
],
54+
"wp-test-ensure-env": [
55+
"if [ ! -f wordpress/src/wp-load.php ]; then composer run wp-setup; fi",
56+
"@putenv COMPOSE_IGNORE_ORPHANS=true",
57+
"cd wordpress && if [ -z \"$(node tools/local-env/scripts/docker.js ps -q)\" ]; then cd ..; composer run wp-test-start; fi"
58+
],
5459
"wp-test-php": [
55-
"rm -rf wordpress/src/wp-content/database && npm --prefix wordpress run test:php --"
60+
"@wp-test-ensure-env @no_additional_args",
61+
"rm -rf wordpress/src/wp-content/database/.ht.sqlite @no_additional_args",
62+
"npm --prefix wordpress run test:php -- @additional_args"
5663
],
5764
"wp-test-e2e": [
58-
"npm --prefix wordpress run test:e2e --"
65+
"@wp-test-ensure-env @no_additional_args",
66+
"npm --prefix wordpress run test:e2e -- @additional_args"
5967
],
6068
"wp-test-clean": [
61-
"npm --prefix wordpress run env:clean"
69+
"npm --prefix wordpress run env:clean",
70+
"rm -rf wordpress/src/wp-content/database/.ht.sqlite"
6271
]
6372
}
6473
}

0 commit comments

Comments
 (0)