Qual: Improve caching for phpstan (#28180)

# Qual: Improve caching for phpstan

The phpstan step does not seem to always choose the best cache.
This configuration update adds the target branch to the restore
feature.
Maybe it is more selective and better.
This commit is contained in:
MDW 2024-02-15 13:55:54 +01:00 committed by GitHub
parent d612e32c06
commit a68f6ed0d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,6 +8,11 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CACHE_KEY_PART: >
${{ ( github.event_name == 'pull_request' ) && github.base_ref
}}${{ ( github.event_name == 'pull_request' ) && '-' }}${{ github.head_ref }}
GITHUB_JSON: ${{ toJSON(github) }} # Helps in debugging Github Action
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job
@ -41,8 +46,11 @@ jobs:
uses: actions/cache/restore@v4
with:
path: ./.github/tmp
key: "phpstan-cache-${{ matrix.php-version }}-${{ github.run_id }}"
key: phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}-${{ github.run_id }}
restore-keys: |
phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}-
phpstan-cache-${{ matrix.php-version }}-${{ github.head_ref }}-
phpstan-cache-${{ matrix.php-version }}-${{ github.base_ref }}-
phpstan-cache-${{ matrix.php-version }}-
- name: Show debug into
run: cd ./.github/tmp && ls -al
@ -59,4 +67,4 @@ jobs:
if: ${{ success() || ( ! cancelled() && steps.cache.outputs.cache-hit != 'true' ) }}
with:
path: ./.github/tmp
key: "phpstan-cache-${{ matrix.php-version }}-${{ github.run_id }}"
key: phpstan-cache-${{ matrix.php-version }}-${{ env.CACHE_KEY_PART }}-${{ github.run_id }}