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