Build/Test Tools: Improve caching for PHPCS.

This improves the speed of the PHPCS scans between workflow runs in GitHub Action by creating a scan cache file for each unique set of arguments passed to `phpcs`.

Props jrf.
Fixes #57148. See #53841.

git-svn-id: https://develop.svn.wordpress.org/trunk@54921 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers 2022-12-01 20:11:48 +00:00
parent 5697adcecf
commit 1e65a9a78b

View File

@ -82,7 +82,9 @@ jobs:
- name: Cache PHPCS scan cache
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11
with:
path: .cache/phpcs.json
path: |
.cache/phpcs-src.json
.cache/phpcs-tests.json
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcs-cache-${{ hashFiles('**/composer.json', 'phpcs.xml.dist') }}
# Since Composer dependencies are installed using `composer update` and no lock file is in version control,
@ -97,7 +99,7 @@ jobs:
- name: Run PHPCS on all Core files
id: phpcs-core
run: phpcs -n --report-full --report-checkstyle=./.cache/phpcs-report.xml
run: phpcs -n --report-full --cache=./.cache/phpcs-src.json --report-checkstyle=./.cache/phpcs-report.xml
- name: Show PHPCS results in PR
if: ${{ always() && steps.phpcs-core.outcome == 'failure' }}
@ -105,7 +107,7 @@ jobs:
- name: Check test suite files for warnings
id: phpcs-tests
run: phpcs tests --report-full --report-checkstyle=./.cache/phpcs-tests-report.xml
run: phpcs tests --report-full --cache=./.cache/phpcs-tests.json --report-checkstyle=./.cache/phpcs-tests-report.xml
- name: Show test suite scan results in PR
if: ${{ always() && steps.phpcs-tests.outcome == 'failure' }}