From 36683354f4bc4655c3ce0df69c2932b2a3cc66c3 Mon Sep 17 00:00:00 2001 From: Paul Isaris Date: Thu, 22 Oct 2026 13:28:48 +0300 Subject: [PATCH] Cache the Pint result in the Laravel static checks Pint checked every file on each run, about 25-40 s on a GitHub runner. The automatic Pint step now writes its cache to the runner's temporary folder, and the analysis cache step saves and restores it. Pint stores its version and rules in the cache, so an outdated cache is discarded. The guide explains how a custom lint-command can use the same cache. --- .github/workflows/README.md | 10 ++++++++-- .github/workflows/laravel-ci.yml | 13 +++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 6200aad..9240d27 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -251,10 +251,15 @@ When `types-command` is empty, it runs: - `vendor/bin/phpstan analyse` when `phpstan.neon` or `phpstan.neon.dist` exists - `npm run types`, or else `npm run type-check`, when `frontend` is true and the script exists -The job caches the PHPStan and Rector results, so later runs analyse only the -changed files. If `phpstan.neon` sets `tmpDir` or `rector.php` sets +The job caches the PHPStan, Rector and Pint results, so later runs analyse only +the changed files. If `phpstan.neon` sets `tmpDir` or `rector.php` sets `cacheDirectory`, set `analysis-cache-paths` to the same paths. +The automatic Pint step writes its cache to the runner's temporary folder. If +`lint-command` runs Pint, give Pint a cache file and add that file to +`analysis-cache-paths`. For example, set `"cache-file": ".pint.cache"` in +`pint.json`, and add `.pint.cache` to `analysis-cache-paths` and `.gitignore`. + ### Environment and database The `.env` file comes from `env-file`. An existing `.env` is kept. The action @@ -497,6 +502,7 @@ jobs: | The weekly security run stopped | GitHub disables scheduled workflows in a public repository after 60 days without activity. Open the workflow in the **Actions** tab and click **Enable workflow**. | | `Script files found in dev tool directories` | A script file is in `.vscode`, `.claude`, `.cursor` or `.idea`. Remove it, or review it and add it to `allowed-dev-scripts`. | | PHPStan or Rector re-analyse every file on each run | `analysis-cache-paths` does not match `tmpDir` in `phpstan.neon` or `cacheDirectory` in `rector.php`. | +| Pint checks every file on each run, with a custom `lint-command` | Pint has no cache file, or `analysis-cache-paths` does not include it. See [Laravel auto-detection](#laravel-auto-detection). | To test an unreleased change in this repository, point your caller at the branch: `uses: scify/.github/.github/workflows/laravel-ci.yml@my-branch`. diff --git a/.github/workflows/laravel-ci.yml b/.github/workflows/laravel-ci.yml index 85154e6..70e3f32 100644 --- a/.github/workflows/laravel-ci.yml +++ b/.github/workflows/laravel-ci.yml @@ -214,12 +214,15 @@ jobs: php artisan config:clear --ansi # ---- End of shared setup ---- - # Restoring the most recent result cache makes PHPStan and Rector re-analyse + # Restoring the most recent result cache makes PHPStan, Rector and Pint re-analyse # only the changed files. The key changes on every commit, so each run saves. - - name: Cache PHPStan and Rector results + # Pint's cache stores its version and rules, so Pint discards an outdated cache. + - name: Cache PHPStan, Rector and Pint results uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: - path: ${{ inputs.analysis-cache-paths }} + path: | + ${{ inputs.analysis-cache-paths }} + ${{ runner.temp }}/pint.cache key: analysis-${{ runner.os }}-${{ hashFiles(format('{0}/composer.lock', inputs.working-directory), format('{0}/rector.php', inputs.working-directory), format('{0}/phpstan.neon*', inputs.working-directory)) }}-${{ github.sha }} restore-keys: analysis-${{ runner.os }}-${{ hashFiles(format('{0}/composer.lock', inputs.working-directory), format('{0}/rector.php', inputs.working-directory), format('{0}/phpstan.neon*', inputs.working-directory)) }}- @@ -231,7 +234,9 @@ jobs: - name: Pint if: inputs.lint-command == '' && hashFiles(format('{0}/pint.json', inputs.working-directory)) != '' - run: vendor/bin/pint --test + env: + PINT_CACHE_FILE: ${{ runner.temp }}/pint.cache + run: vendor/bin/pint --test --cache-file="$PINT_CACHE_FILE" - name: Rector (dry run) if: inputs.lint-command == '' && hashFiles(format('{0}/rector.php', inputs.working-directory)) != ''