Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: GitHub Actions - use actions/cache for Composer in composite action #7415

Merged
merged 3 commits into from
Nov 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 36 additions & 1 deletion .github/composite-actions/install-composer-deps/action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Install composer deps"
name: "Install Composer deps"

inputs:
flags:
Expand All @@ -8,6 +8,41 @@ inputs:
runs:
using: "composite"
steps:
# Warning!
# Use $GITHUB_ENV instead of $GITHUB_OUTPUT.
#
# The actions/cache is, on calling it in this composite action, reading the cache,
# and then also register a shutdown function for the whole workflow, to write the cache afterwards.
#
# That registered shutdown function does _NOT_ have access to inputs.* nor steps.*.outputs for
# `path` parameter, which is evaluated on both stages (read and write), yet `key` parameters
# are evaluated on start only and are not affected by this issue.
#
# Unfortunately, when the issue is faced, it does not break the build, simply raises a warning
# and completing the build successfully, yet without storing the cache:
# > Warning: Input required and not supplied: path
#
# Refs:
# - https://github.com/actions/cache/issues/638#issuecomment-1793564996
# - https://github.com/actions/cache/issues/803#issuecomment-1793565071
# - https://github.com/actions/runner/issues/2009#issuecomment-1793565031

- name: Get Composer cache params
shell: bash
run: |
echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
echo "COMPOSER_CACHE_PHP=$(php -r 'echo PHP_VERSION;')" >> $GITHUB_ENV

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: Composer-${{ runner.os }}-${{ env.COMPOSER_CACHE_PHP }}-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
Composer-${{ runner.os }}-${{ env.COMPOSER_CACHE_PHP }}-${{ hashFiles('**/composer.json') }}-
Composer-${{ runner.os }}-${{ env.COMPOSER_CACHE_PHP }}-
Composer-${{ runner.os }}-

- name: Install dependencies
uses: nick-invision/retry@v2
with:
Expand Down