Make WordPress Core

Changeset 52179


Ignore:
Timestamp:
11/16/2021 02:17:26 PM (2 years ago)
Author:
desrosj
Message:

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.

Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/coding-standards.yml

    r52130 r52179  
    4949  # - Sets up PHP.
    5050  # - Logs debug information.
     51  # - Configures caching for PHPCS scans.
    5152  # - Installs Composer dependencies (use cache if possible).
    5253  # - Make Composer packages available globally.
     
    7576          php --version
    7677          composer --version
     78
     79      # This date is used to ensure that the PHPCS cache is cleared at least once every week.
     80      # http://man7.org/linux/man-pages/man1/date.1.html
     81      - name: "Get last Monday's date"
     82        id: get-date
     83        run: echo "::set-output name=date::$(/bin/date -u --date='last Mon' "+%F")"
     84
     85      - name: Cache PHPCS scan cache
     86        uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
     87        with:
     88          path: .cache/phpcs.json
     89          key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcs-cache-${{ hashFiles('**/composer.json') }}
    7790
    7891      - name: Install Composer dependencies
  • trunk/.github/workflows/php-compatibility.yml

    r52130 r52179  
    2121      # These files configure Composer. Changes could affect the outcome.
    2222      - 'composer.*'
    23       # This file configures PHP Compatibility scanning. Changes could affect the outcome.
     23      # This file configures PHP compatibility scanning. Changes could affect the outcome.
    2424      - 'phpcompat.xml.dist'
    2525      # Changes to workflow files should always verify all workflows are successful.
     
    4343  # - Checks out the repository.
    4444  # - Sets up PHP.
    45   # - Logs debug information about the runner container.
     45  # - Logs debug information.
     46  # - Configures caching for PHP compatibility scans.
    4647  # - Installs Composer dependencies (use cache if possible).
    4748  # - Make Composer packages available globally.
     
    6970          php --version
    7071          composer --version
     72
     73      # This date is used to ensure that the PHP compatibility cache is cleared at least once every week.
     74      # http://man7.org/linux/man-pages/man1/date.1.html
     75      - name: "Get last Monday's date"
     76        id: get-date
     77        run: echo "::set-output name=date::$(/bin/date -u --date='last Mon' "+%F")"
     78
     79      - name: Cache PHP compatibility scan cache
     80        uses: actions/cache@26968a09c0ea4f3e233fdddbafd1166051a095f6 # v2.1.4
     81        with:
     82          path: .cache/phpcompat.json
     83          key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcompat-cache-${{ hashFiles('**/composer.json') }}
    7184
    7285      - name: Install Composer dependencies
  • trunk/.gitignore

    r52081 r52179  
    1111/.phpcs.xml
    1212/phpcs.xml
     13.cache/*
    1314/tests/phpunit/data/plugins/wordpress-importer
    1415/tests/phpunit/data/.trac-ticket-cache*
  • trunk/phpcompat.xml.dist

    r52148 r52179  
    1212
    1313    <!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next scan. -->
    14     <arg name="cache"/>
     14    <arg name="cache" value=".cache/phpcompat.json"/>
    1515
    1616    <!-- Set the memory limit to 256M.
  • trunk/phpcs.xml.dist

    r51659 r52179  
    77
    88    <!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next scan. -->
    9     <arg name="cache"/>
     9    <arg name="cache" value=".cache/phpcs.json"/>
    1010
    1111    <!-- Set the memory limit to 256M.
Note: See TracChangeset for help on using the changeset viewer.