Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`.
13 changes: 9 additions & 4 deletions .github/workflows/laravel-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)) }}-

Expand All @@ -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)) != ''
Expand Down
Loading