mirror of
git://develop.git.wordpress.org/
synced 2025-01-16 12:29:54 +01:00
Build/Test Tools: Cache the results of PHP_CodeSniffer
across workflow runs.
When the `PHP_CodeSniffer` runs, it produces a cache file. When a cache file is present, only changed files are rescanned, making subsequent scans significantly faster. This adds the needed steps to the corresponding GitHub Actions workflows to cache these files across runs. The cache keys include the date of the previous Monday to ensure that the cache is flushed at least weekly. Since GitHub Action caches cannot be updated once created, the scans will take slightly longer as the week progresses and more PHP files are updated. The date within the cache key can be updated to purge twice weekly if the scan time starts to approach the current scan times. This change also introduces a `.cache` directory for all caching files related to build/test tools. Props johnbillion, jrf. Fixes #49783. git-svn-id: https://develop.svn.wordpress.org/trunk@52179 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c3222105d8
commit
ba620225c5
0
.cache/.gitkeep
Normal file
0
.cache/.gitkeep
Normal file
13
.github/workflows/coding-standards.yml
vendored
13
.github/workflows/coding-standards.yml
vendored
@ -48,6 +48,7 @@ jobs:
|
||||
# - Checks out the repository.
|
||||
# - Sets up PHP.
|
||||
# - Logs debug information.
|
||||
# - Configures caching for PHPCS scans.
|
||||
# - Installs Composer dependencies (use cache if possible).
|
||||
# - Make Composer packages available globally.
|
||||
# - Logs PHP_CodeSniffer debug information.
|
||||
@ -75,6 +76,18 @@ jobs:
|
||||
php --version
|
||||
composer --version
|
||||
|
||||
# This date is used to ensure that the PHPCS cache is cleared at least once every week.
|
||||
# http://man7.org/linux/man-pages/man1/date.1.html
|
||||
- name: "Get last Monday's date"
|
||||
id: get-date
|
||||
run: echo "::set-output name=date::$(/bin/date -u --date='last Mon' "+%F")"
|
||||
|
||||
- name: Cache PHPCS scan cache
|
||||
uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
|
||||
with:
|
||||
path: .cache/phpcs.json
|
||||
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcs-cache-${{ hashFiles('**/composer.json') }}
|
||||
|
||||
- name: Install Composer dependencies
|
||||
uses: ramsey/composer-install@92a7904348d4ad30236f3611e33b7f0c6f9edd70 # v1.1.0
|
||||
with:
|
||||
|
17
.github/workflows/php-compatibility.yml
vendored
17
.github/workflows/php-compatibility.yml
vendored
@ -20,7 +20,7 @@ on:
|
||||
- '**.php'
|
||||
# These files configure Composer. Changes could affect the outcome.
|
||||
- 'composer.*'
|
||||
# This file configures PHP Compatibility scanning. Changes could affect the outcome.
|
||||
# This file configures PHP compatibility scanning. Changes could affect the outcome.
|
||||
- 'phpcompat.xml.dist'
|
||||
# Changes to workflow files should always verify all workflows are successful.
|
||||
- '.github/workflows/*.yml'
|
||||
@ -42,7 +42,8 @@ jobs:
|
||||
# Performs the following steps:
|
||||
# - Checks out the repository.
|
||||
# - Sets up PHP.
|
||||
# - Logs debug information about the runner container.
|
||||
# - Logs debug information.
|
||||
# - Configures caching for PHP compatibility scans.
|
||||
# - Installs Composer dependencies (use cache if possible).
|
||||
# - Make Composer packages available globally.
|
||||
# - Logs PHP_CodeSniffer debug information.
|
||||
@ -69,6 +70,18 @@ jobs:
|
||||
php --version
|
||||
composer --version
|
||||
|
||||
# This date is used to ensure that the PHP compatibility cache is cleared at least once every week.
|
||||
# http://man7.org/linux/man-pages/man1/date.1.html
|
||||
- name: "Get last Monday's date"
|
||||
id: get-date
|
||||
run: echo "::set-output name=date::$(/bin/date -u --date='last Mon' "+%F")"
|
||||
|
||||
- name: Cache PHP compatibility scan cache
|
||||
uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
|
||||
with:
|
||||
path: .cache/phpcompat.json
|
||||
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcompat-cache-${{ hashFiles('**/composer.json') }}
|
||||
|
||||
- name: Install Composer dependencies
|
||||
uses: ramsey/composer-install@92a7904348d4ad30236f3611e33b7f0c6f9edd70 # v1.1.0
|
||||
with:
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,6 +10,7 @@ wp-tests-config.php
|
||||
/phpunit.xml
|
||||
/.phpcs.xml
|
||||
/phpcs.xml
|
||||
.cache/*
|
||||
/tests/phpunit/data/plugins/wordpress-importer
|
||||
/tests/phpunit/data/.trac-ticket-cache*
|
||||
/tests/qunit/compiled.html
|
||||
|
@ -11,7 +11,7 @@
|
||||
<arg name="extensions" value="php"/>
|
||||
|
||||
<!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next scan. -->
|
||||
<arg name="cache"/>
|
||||
<arg name="cache" value=".cache/phpcompat.json"/>
|
||||
|
||||
<!-- Set the memory limit to 256M.
|
||||
For most standard PHP configurations, this means the memory limit will temporarily be raised.
|
||||
|
@ -6,7 +6,7 @@
|
||||
<arg name="extensions" value="php"/>
|
||||
|
||||
<!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next scan. -->
|
||||
<arg name="cache"/>
|
||||
<arg name="cache" value=".cache/phpcs.json"/>
|
||||
|
||||
<!-- Set the memory limit to 256M.
|
||||
For most standard PHP configurations, this means the memory limit will temporarily be raised.
|
||||
|
Loading…
x
Reference in New Issue
Block a user