Skip to content

A free open source IT asset/license management system

Implement PHPStan result caching in GitHub Actions

Markus Staab274efb448cf0
diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml
index 8ca624c93d..d29d3d218a 100644
--- a/.github/workflows/static-analysis.yml
+++ b/.github/workflows/static-analysis.yml
@@ -44,12 +44,30 @@ jobs:
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
+ # Use a warm PHPStan result cache when possible to speedup analysis
+ - name: "Restore PHPStan result cache"
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: "/tmp/phpstan"
+ key: "result-cache-v1-${{ matrix.php-version }}-${{ github.run_id }}"
+ restore-keys: |
+ result-cache-v1-${{ matrix.php-version }}-
+
# PHPStan analyses types / dead code / undefined properties, PHPMD covers
# the classes PHPStan doesn't (unused parameters, unused locals). Both
# honor their baselines so this job only fails on NEW findings, not the
# 3400+ pre-existing ones inherited from before analyzer adoption.
+
- name: PHPStan
run: composer analyse:phpstan
- name: PHPMD
run: composer analyse:phpmd
+
+ # Persist the PHPStan cache for re-use on the next run
+ - name: "Save result cache"
+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ if: ${{ !cancelled() }}
+ with:
+ path: "/tmp/phpstan"
+ key: "result-cache-v1-${{ matrix.php-version }}-${{ github.run_id }}"