From a68f6ed0d1dc0c8eddf289977b5ebc1fa7227564 Mon Sep 17 00:00:00 2001 From: MDW Date: Thu, 15 Feb 2024 13:55:54 +0100 Subject: [PATCH] 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. --- .github/workflows/phpstan.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index a0f619cb393..156da172ac7 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -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 }}