Skip to content

Commit 71008db

Browse files
committed
Automatically set up test environment, improve config
1 parent 905c0c4 commit 71008db

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

.github/workflows/wp-tests-end-to-end.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 end-to-end tests
3428
run: composer run wp-test-e2e
3529

.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: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,22 @@
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 @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": [
69+
"rm -rf wordpress/src/wp-content/database",
6170
"npm --prefix wordpress run env:clean"
6271
]
6372
}

0 commit comments

Comments
 (0)