-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update actions/cache action to v4.0.1
Signed-off-by: Fabiana Campanari <[email protected]>
- Loading branch information
1 parent
c1db24d
commit 362e66f
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# This is the composite action: | ||
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action | ||
# | ||
# Composite actions have some limitations: | ||
# - many contexts are unavailable, e.g. `runner` | ||
# - `env` can be specified per-step only | ||
# - if `run` is used, `shell` must be explicitly specified | ||
name: 'Calculate matrix for `node_modules` prefetch' | ||
inputs: | ||
repo: | ||
description: 'Repository name' | ||
required: true | ||
token: | ||
description: 'GitHub token' | ||
required: true | ||
node-version: | ||
description: 'Node version' | ||
required: true | ||
outputs: | ||
matrix: | ||
description: 'Matrix of OSes to prefetch `node_modules` for' | ||
value: ${{ steps.os-matrix-prefetch.outputs.os-matrix-prefetch }} | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Calculate cache keys | ||
id: cache-keys | ||
env: | ||
HASH: ${{ hashFiles('pnpm-lock.yaml') }} | ||
shell: bash | ||
run: | | ||
echo 'MACOS_KEY=node_modules-macOS-${{ inputs.node-version }}-${{ env.HASH }}' >> "$GITHUB_ENV" | ||
echo 'WINDOWS_KEY=node_modules-Windows-${{ inputs.node-version }}-${{ env.HASH }}' >> "$GITHUB_ENV" | ||
- name: Check cache miss for MacOS | ||
id: macos-cache | ||
uses: actions/cache/restore@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1 | ||
with: | ||
path: node_modules | ||
key: ${{ env.MACOS_KEY }} | ||
lookup-only: true | ||
enableCrossOsArchive: true | ||
|
||
- name: Check cache miss for Windows | ||
id: windows-cache | ||
uses: actions/cache/restore@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1 | ||
with: | ||
path: node_modules | ||
key: ${{ env.WINDOWS_KEY }} | ||
lookup-only: true | ||
enableCrossOsArchive: true | ||
|
||
- name: Dispatch `node_modules` prefetch for MacOS and Windows | ||
id: os-matrix-prefetch | ||
env: | ||
MACOS_MISS: ${{ steps.macos-cache.outputs.cache-hit != 'true' && 'true' || '' }} | ||
WINDOWS_MISS: ${{ steps.windows-cache.outputs.cache-hit != 'true' && 'true' || '' }} | ||
PREFETCH_MAC_ONLY: '["macos-latest"]' | ||
PREFETCH_WINDOWS_ONLY: '["windows-latest"]' | ||
PREFETCH_BOTH: '["macos-latest", "windows-latest"]' | ||
PREFETCH_FALLBACK: '["ubuntu-latest"]' | ||
shell: bash | ||
run: | | ||
echo 'os-matrix-prefetch=${{ | ||
(env.OS_MATRIX_IS_FULL && env.WINDOWS_MISS && env.MACOS_MISS && env.PREFETCH_BOTH) || | ||
(env.OS_MATRIX_IS_FULL && env.MACOS_MISS && env.PREFETCH_MAC_ONLY) || | ||
(env.OS_MATRIX_IS_FULL && env.WINDOWS_MISS && env.PREFETCH_WINDOWS_ONLY) || | ||
env.PREFETCH_FALLBACK | ||
}}' >> "$GITHUB_OUTPUT" |