File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Prepare WordPress
2+ description : Set up the WordPress repository.
3+ runs :
4+ using : composite
5+ steps :
6+ - name : Resolve WordPress cache key
7+ id : wordpress
8+ shell : bash
9+ env :
10+ # The setup script builds the "wordpress" folder and copies "db.copy" into it.
11+ SETUP_HASH : ${{ hashFiles( 'wp-setup.sh', 'packages/plugin-sqlite-database-integration/db.copy' ) }}
12+ run : |
13+ version="$( sed -n 's/^WP_VERSION="\(.*\)"$/\1/p' wp-setup.sh )"
14+ commit="$( git ls-remote --exit-code https://github.com/WordPress/wordpress-develop.git "refs/heads/$version" | cut -f1 )"
15+ echo "cache-key=wordpress-$( node --version )-$commit-$SETUP_HASH" >> "$GITHUB_OUTPUT"
16+
17+ - name : Restore WordPress from the cache
18+ id : cache
19+ uses : actions/cache/restore@v6
20+ with :
21+ path : wordpress
22+ key : ${{ steps.wordpress.outputs.cache-key }}
23+
24+ - name : Set up WordPress
25+ if : steps.cache.outputs.cache-hit != 'true'
26+ shell : bash
27+ run : composer run wp-test-ensure-php-env
28+
29+ # Save now rather than using "actions/cache", which saves at the end of the job.
30+ # Saving after the tests would also cache files they create, like the SQLite database.
31+ - name : Save WordPress to the cache
32+ if : steps.cache.outputs.cache-hit != 'true'
33+ uses : actions/cache/save@v6
34+ with :
35+ path : wordpress
36+ key : ${{ steps.wordpress.outputs.cache-key }}
Original file line number Diff line number Diff line change 2828 echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
2929
3030 - name : Prepare WordPress
31- run : composer run wp-setup
31+ uses : ./.github/actions/wordpress
3232
3333 - name : Run end-to-end tests
3434 uses : ./.github/actions/playwright
3535 with :
3636 test-script : test-e2e
37-
38- - name : Stop Docker containers
39- if : always()
40- run : composer run wp-test-clean
Original file line number Diff line number Diff line change @@ -31,12 +31,11 @@ jobs:
3131 echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
3232 echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
3333
34+ - name : Prepare WordPress
35+ uses : ./.github/actions/wordpress
36+
3437 - name : Run SQLite plugin single-site PHPUnit tests
3538 run : composer run wp-test-sqlite-plugin-php
3639
3740 - name : Run SQLite plugin multisite PHPUnit tests
3841 run : composer run wp-test-sqlite-plugin-php-multisite
39-
40- - name : Stop Docker containers
41- if : always()
42- run : composer run wp-test-clean
Original file line number Diff line number Diff line change 2828 echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
2929
3030 - name : Prepare WordPress
31- run : composer run wp-setup
31+ uses : ./.github/actions/wordpress
3232
3333 - name : Run WordPress end-to-end tests
3434 uses : ./.github/actions/playwright
3535 with :
3636 test-script : wp-test-e2e
37-
38- - name : Stop Docker containers
39- if : always()
40- run : composer run wp-test-clean
Original file line number Diff line number Diff line change 2727 echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
2828 echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
2929
30+ - name : Prepare WordPress
31+ uses : ./.github/actions/wordpress
32+
3033 - name : Run WordPress PHPUnit tests
3134 run : node .github/workflows/wp-tests-phpunit-run.js
32-
33- - name : Stop Docker containers
34- if : always()
35- run : composer run wp-test-clean
Original file line number Diff line number Diff line change 5959 " npm --prefix wordpress run env:cli -- plugin install gutenberg --version=22.3.0" ,
6060 " npm --prefix wordpress run env:cli -- plugin install query-monitor"
6161 ],
62- "wp-test-ensure-env" : [
63- " if [ ! -f wordpress/src/ wp-load .php ]; then composer run wp-setup; fi" ,
62+ "wp-test-ensure-php- env" : [
63+ " if [ ! -f wordpress/wp-tests-config .php ]; then composer run wp-setup; fi" ,
6464 " @putenv COMPOSE_IGNORE_ORPHANS=true" ,
65+ " if [ ! -f wordpress/vendor/autoload.php ]; then npm --prefix wordpress run env:composer -- update -W; fi"
66+ ],
67+ "wp-test-ensure-env" : [
68+ " @wp-test-ensure-php-env" ,
6569 " cd wordpress && if [ -z \" $(DOTENV_CONFIG_QUIET=true node tools/local-env/scripts/docker.js ps -q)\" ]; then cd ..; composer run wp-test-start; fi"
6670 ],
6771 "wp-test-php" : [
68- " @wp-test-ensure-env @no_additional_args" ,
72+ " @wp-test-ensure-php- env @no_additional_args" ,
6973 " @wp-test-remove-database @no_additional_args" ,
7074 " cd wordpress && node tools/local-env/scripts/docker.js run --rm php php -d zend.enable_gc=0 -d opcache.enable_cli=1 -d opcache.memory_consumption=256 -d opcache.jit=tracing -d opcache.jit_buffer_size=64M ./vendor/bin/phpunit @additional_args"
7175 ],
Original file line number Diff line number Diff line change @@ -88,3 +88,13 @@ cp "$WP_DIR/.env.example" "$WP_DIR/.env"
8888echo " Installing dependencies..."
8989npm --prefix " $WP_DIR " install
9090npm --prefix " $WP_DIR " run build:dev
91+
92+ # 10. Create "wp-tests-config.php" like "tools/local-env/scripts/install.js" does, so PHPUnit doesn't need "env:install".
93+ echo " Creating the 'wp-tests-config.php' file..."
94+ sed \
95+ -e " s/youremptytestdbnamehere/wordpress_develop_tests/" \
96+ -e " s/yourusernamehere/root/" \
97+ -e " s/yourpasswordhere/password/" \
98+ -e " s/localhost/mysql/" \
99+ " $WP_DIR /wp-tests-config-sample.php" > " $WP_DIR /wp-tests-config.php"
100+ printf " \ndefine( 'FS_METHOD', 'direct' );\n" >> " $WP_DIR /wp-tests-config.php"
You can’t perform that action at this time.
0 commit comments