2828 # - Sets up PHP.
2929 # - Configures caching for PHPCS scans.
3030 # - Installs Composer dependencies.
31- # - Make Composer packages available globally.
3231 # - Runs PHPCS on the full codebase.
3332 # - Generate a report for displaying issues as pull request annotations.
3433 phpcs :
6867 # passing a custom cache suffix ensures that the cache is flushed at least once per week.
6968 - name : Install Composer dependencies
7069 uses : ramsey/composer-install@a2636af0004d1c0499ffca16ac0b4cc94df70565 # v3.1.0
71- with :
72- custom-cache-suffix : ${{ steps.get-date.outputs.date }}
73-
74- - name : Make Composer packages available globally
75- run : echo "${PWD}/vendor/bin" >> "$GITHUB_PATH"
7670
7771 - name : Run PHPCS
7872 id : phpcs
@@ -89,12 +83,11 @@ jobs:
8983 # Performs the following steps:
9084 # - Checks out the repository.
9185 # - Sets up PHP.
92- # - Installs Composer dependencies.
9386 # - Configures caching for PHP static analysis scans.
94- # - Make Composer packages available globally.
87+ # - Installs Composer dependencies.
88+ # - Makes Composer packages available globally.
9589 # - Runs PHPStan static analysis (with Pull Request annotations).
9690 # - Saves the PHPStan result cache.
97- # - Ensures version-controlled files are not modified or deleted.
9891 phpstan :
9992 name : Run PHP static analysis
10093 runs-on : ubuntu-24.04
@@ -116,30 +109,26 @@ jobs:
116109 coverage : none
117110 tools : cs2pr
118111
119- # This date is used to ensure that the Composer cache is cleared at least once every week.
112+ # This date is used to ensure that the PHPCS cache is cleared at least once every week.
120113 # http://man7.org/linux/man-pages/man1/date.1.html
121114 - name : " Get last Monday's date"
122115 id : get-date
123116 run : echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> "$GITHUB_OUTPUT"
124117
125- # Since Composer dependencies are installed using `composer update` and no lock file is in version control,
126- # passing a custom cache suffix ensures that the cache is flushed at least once per week.
127- - name : Install Composer dependencies
128- uses : ramsey/composer-install@a2636af0004d1c0499ffca16ac0b4cc94df70565 # v3.1.0
129- with :
130- custom-cache-suffix : ${{ steps.get-date.outputs.date }}
131-
132- - name : Make Composer packages available globally
133- run : echo "${PWD}/vendor/bin" >> "$GITHUB_PATH"
134-
135118 - name : Cache PHP Static Analysis scan cache
136119 uses : actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
137120 with :
138121 path : tests/_output # This is defined in the base.neon file.
139- key : ' phpstan-result-cache-${{ github.run_id }}'
122+ key : ' phpstan-result-cache-${{ runner.os }}-date-${{ steps.get-date.outputs.date }}'
140123 restore-keys : |
141124 phpstan-result-cache-
142125
126+ - name : Install Composer dependencies
127+ uses : ramsey/composer-install@a2636af0004d1c0499ffca16ac0b4cc94df70565 # v3.1.0
128+
129+ - name : Make Composer packages available globally
130+ run : echo "${PWD}/vendor/bin" >> "$GITHUB_PATH"
131+
143132 - name : Run PHP static analysis tests
144133 id : phpstan
145134 run : phpstan analyse -vvv --error-format=checkstyle | cs2pr
@@ -149,36 +138,30 @@ jobs:
149138 if : ${{ !cancelled() }}
150139 with :
151140 path : tests/_output
152- key : ' phpstan-result-cache-${{ github.run_id }}'
141+ key : ' phpstan-result-cache-${{ runner.os }}-date-${{ steps.get-date.outputs.date }}'
153142
154143 # Runs the PHPUnit tests for WordPress.
155144 #
156145 # Performs the following steps:
157146 # - Sets environment variables.
158147 # - Checks out the repository.
159- # - Sets up Node.js.
160148 # - Sets up PHP.
161149 # - Installs Composer dependencies.
162- # - Installs npm dependencies
163- # - Logs general debug information about the runner.
164- # - Logs Docker debug information (about the Docker installation within the runner).
165- # - Starts the WordPress Docker container.
166- # - Logs the running Docker containers.
167- # - Logs debug information about what's installed within the WordPress Docker containers.
168- # - Install WordPress within the Docker container.
169- # - Run the PHPUnit tests.
170- # - Upload the code coverage report to Codecov.io.
171- # - Upload the HTML code coverage report as an artifact.
172- # - Ensures version-controlled files are not modified or deleted.
173- # - Checks out the WordPress Test reporter repository.
174- # - Submit the test results to the WordPress.org host test results.
150+ # - Sets up Node.js.
151+ # - Installs npm dependencies.
152+ # - Starts the WordPress Docker testing environment (with or without Xdebug coverage).
153+ # - Logs PHP and WordPress versions from the container.
154+ # - Runs PHPUnit tests (with coverage if enabled).
155+ # - Uploads code coverage report to Codecov.io (if coverage is enabled).
156+ # - Uploads HTML coverage report as an artifact (if coverage is enabled).
175157 phpunit :
176158 name : Test PHP ${{ matrix.php }} WP ${{ matrix.wp }}${{ matrix.coverage && ' with coverage' || '' }}
177159 runs-on : ubuntu-24.04
178160 strategy :
161+ fail-fast : false
179162 matrix :
180163 php : ['8.4', '8.3', '8.2', '8.1', '8.0', '7.4']
181- wp : [latest, trunk, '6.7' ]
164+ wp : [latest, trunk]
182165 coverage : [false]
183166 include :
184167 - php : ' 8.4'
@@ -213,12 +196,8 @@ jobs:
213196 php-version : ' ${{ matrix.php }}'
214197 coverage : none
215198
216- # Since Composer dependencies are installed using `composer update` and no lock file is in version control,
217- # passing a custom cache suffix ensures that the cache is flushed at least once per week.
218199 - name : Install Composer dependencies
219200 uses : ramsey/composer-install@a2636af0004d1c0499ffca16ac0b4cc94df70565 # v3.1.0
220- with :
221- custom-cache-suffix : $(/bin/date -u --date='last Mon' "+%F")
222201
223202 - name : Setup Node
224203 uses : actions/setup-node@v4
@@ -247,7 +226,6 @@ jobs:
247226 npm run wp-env -- run cli wp core version
248227
249228 - name : Run PHPUnit tests${{ matrix.coverage && ' with coverage report' || '' }}
250- continue-on-error : true
251229 id : phpunit
252230 run : |
253231 npm run test:php
0 commit comments