Use a weekly cache key for PNPM store (#34656)

Closes #34655

Signed-off-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
Jon Koops 2024-11-06 08:25:49 +01:00 committed by GitHub
parent 65e90d2ff4
commit b44aee7535
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 60 additions and 48 deletions

View file

@ -24,9 +24,9 @@ runs:
with:
create-cache-if-it-doesnt-exist: true
- id: frontend-plugin-cache
name: Frontend Plugin Cache
uses: ./.github/actions/frontend-plugin-cache
- id: pnpm-store-cache
name: PNPM store cache
uses: ./.github/actions/pnpm-store-cache
- id: build-keycloak
name: Build Keycloak

View file

@ -0,0 +1,20 @@
name: Cache Cypress
description: Caches Cypress binary to speed up the build.
runs:
using: composite
steps:
- id: cache-key
name: Cache key based on Cypress version
shell: bash
run: echo "key=cypress-binary-$(jq -r '.devDependencies.cypress' js/apps/admin-ui/package.json)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Cache Cypress binary
with:
# See: https://docs.cypress.io/app/references/advanced-installation#Binary-cache
path: |
~/.cache/Cypress
/AppData/Local/Cypress/Cache
~/Library/Caches/Cypress
key: ${{ runner.os }}-${{ steps.cache-key.outputs.key }}

View file

@ -1,21 +0,0 @@
name: Frontend Plugin Cache
description: Caches NPM dependencies for the frontend-maven-plugin to speed up builds
runs:
using: composite
steps:
- name: Get PNPM version
id: pnpm-version
shell: bash
run: |
echo "version=$(./mvnw help:evaluate -Dexpression=pnpm.version -q -DforceStdout)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Cache PNPM store
with:
# See: https://pnpm.io/npmrc#store-dir
path: |
~/.local/share/pnpm/store
~/AppData/Local/pnpm/store
~/Library/pnpm/store
key: ${{ runner.os }}-frontend-plugin-pnpm-store-${{ steps.pnpm-version.outputs.version }}-${{ hashFiles('pnpm-lock.yaml') }}

View file

@ -25,9 +25,9 @@ runs:
name: Maven cache
uses: ./.github/actions/maven-cache
- id: frontend-plugin-cache
name: Frontend Plugin Cache
uses: ./.github/actions/frontend-plugin-cache
- id: pnpm-store-cache
name: PNPM store cache
uses: ./.github/actions/pnpm-store-cache
- id: download-keycloak
name: Download Keycloak Maven artifacts

View file

@ -20,26 +20,19 @@ runs:
shell: bash
run: corepack enable
- name: Get PNPM store directory
id: pnpm-cache
shell: bash
run: |
echo "store-path=$(pnpm store path --silent)" >> $GITHUB_OUTPUT
- name: PNPM store cache
uses: ./.github/actions/pnpm-store-cache
- uses: actions/cache@v4
name: Setup PNPM cache
with:
# Also cache Cypress binary.
path: |
~/.cache/Cypress
${{ steps.pnpm-cache.outputs.store-path }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Cypress binary cache
uses: ./.github/actions/cypress-cache
- name: Install dependencies
shell: bash
# Run the store prune after the installation to avoid having caches which grow over time
run: |
pnpm install --prefer-offline --frozen-lockfile
pnpm store prune
run: pnpm install --prefer-offline --frozen-lockfile
# This step is only needed to ensure that the Cypress binary is installed.
# If the binary was retrieved from the cache, this step is a no-op.
- name: Install Cypress dependencies
shell: bash
working-directory: js/apps/admin-ui
run: pnpm exec cypress install

View file

@ -0,0 +1,20 @@
name: Cache PNPM store
description: Caches the PNPM store to speed up the build.
runs:
using: composite
steps:
- id: weekly-cache-key
name: Key for weekly rotation of cache
shell: bash
run: echo "key=pnpm-store-`date -u "+%Y-%U"`" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Cache PNPM store
with:
# See: https://pnpm.io/npmrc#store-dir
path: |
~/.local/share/pnpm/store
~/AppData/Local/pnpm/store
~/Library/pnpm/store
key: ${{ runner.os }}-${{ steps.weekly-cache-key.outputs.key }}

View file

@ -11,6 +11,6 @@ runs:
name: Maven cache
uses: ./.github/actions/maven-cache
- id: frontend-plugin-cache
- id: pnpm-store-cache
name: Frontend Plugin Cache
uses: ./.github/actions/frontend-plugin-cache
uses: ./.github/actions/pnpm-store-cache