Make WordPress Core


Ignore:
Timestamp:
11/16/2021 02:17:26 PM (3 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.