From 64775078124457809089d56740f1a439d8c41cc3 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Fri, 26 Apr 2024 15:04:21 +0100 Subject: [PATCH] Use same dependency cache key naming logic Bring consistency across the whole pipeline --- .github/workflows/build-linux-arm.yml | 18 +++++++++++++++++- .github/workflows/build-linux-x86_64.yml | 7 ++++++- .github/workflows/build-macos-aarch64.yml | 7 ++++++- .github/workflows/build-macos-x86_64.yml | 7 ++++++- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-linux-arm.yml b/.github/workflows/build-linux-arm.yml index 08967a81..20f17fb9 100644 --- a/.github/workflows/build-linux-arm.yml +++ b/.github/workflows/build-linux-arm.yml @@ -47,12 +47,28 @@ jobs: steps: - uses: actions/checkout@v4 + # Cache composer dependencies + - id: cache-composer-deps + uses: actions/cache@v4 + with: + path: vendor + key: composer-dependencies + + # If there's no Composer cache, install dependencies + - if: steps.cache-composer-deps.outputs.cache-hit != 'true' + run: composer update --no-dev --classmap-authoritative + + - name: Generate hashed key for download cache + run: | + INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}') + echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV + # Cache downloaded source - id: cache-download uses: actions/cache@v4 with: path: downloads - key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }} + key: php-${{ env.INPUT_HASH }} # With or without debug - if: inputs.debug == true diff --git a/.github/workflows/build-linux-x86_64.yml b/.github/workflows/build-linux-x86_64.yml index e31b4154..262eb930 100644 --- a/.github/workflows/build-linux-x86_64.yml +++ b/.github/workflows/build-linux-x86_64.yml @@ -52,12 +52,17 @@ jobs: - if: steps.cache-composer-deps.outputs.cache-hit != 'true' run: composer update --no-dev --classmap-authoritative + - name: Generate hashed key for download cache + run: | + INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}') + echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV + # Cache downloaded source - id: cache-download uses: actions/cache@v4 with: path: downloads - key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }} + key: php-${{ env.INPUT_HASH }} # With or without debug - if: inputs.debug == true diff --git a/.github/workflows/build-macos-aarch64.yml b/.github/workflows/build-macos-aarch64.yml index df54dfb1..591b2ad4 100644 --- a/.github/workflows/build-macos-aarch64.yml +++ b/.github/workflows/build-macos-aarch64.yml @@ -67,12 +67,17 @@ jobs: - if: steps.cache-composer-deps.outputs.cache-hit != 'true' run: composer update --no-dev --classmap-authoritative + - name: Generate hashed key for download cache + run: | + INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}') + echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV + # Cache downloaded source - id: cache-download uses: actions/cache@v4 with: path: downloads - key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }} + key: php-${{ env.INPUT_HASH }} # With or without debug - if: inputs.debug == true diff --git a/.github/workflows/build-macos-x86_64.yml b/.github/workflows/build-macos-x86_64.yml index 97c7a7a6..6c3049cc 100644 --- a/.github/workflows/build-macos-x86_64.yml +++ b/.github/workflows/build-macos-x86_64.yml @@ -57,12 +57,17 @@ jobs: - if: steps.cache-composer-deps.outputs.cache-hit != 'true' run: composer update --no-dev --classmap-authoritative + - name: Generate hashed key for download cache + run: | + INPUT_HASH=$(echo "${{ runner.os }}-${{ inputs.version }}-${{ inputs.extensions }}" | sha256sum | awk '{print $1}') + echo "INPUT_HASH=${INPUT_HASH}" >> $GITHUB_ENV + # Cache downloaded source - id: cache-download uses: actions/cache@v4 with: path: downloads - key: php-${{ inputs.version }}-dependencies-${{ inputs.extensions }} + key: php-${{ env.INPUT_HASH }} # With or without debug - if: inputs.debug == true