Cache Node.js artifacts from maven-frontend-plugin on CI (#33815)

Closes #31835

Signed-off-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
Jon Koops 2024-10-17 08:06:45 +02:00 committed by GitHub
parent 946798aa01
commit 96b6cb4506
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -31,15 +31,6 @@ runs:
# Enable cross-os archive use the cache on both Linux and Windows # Enable cross-os archive use the cache on both Linux and Windows
enableCrossOsArchive: true enableCrossOsArchive: true
- id: download-node-for-windows
# This is necessary as the build which creates the cache will run on a Linux node and therefore will never download the Windows artifact by default.
# If we wouldn't download it manually, it would be downloaded on each Windows build, which proved to be unstable as downloads would randomly fail in the middle of the download.
if: inputs.create-cache-if-it-doesnt-exist == 'true' && steps.cache-maven-repository.outputs.cache-hit != 'true'
shell: bash
run: |
export VERSION=$(mvn help:evaluate -Dexpression=node.version -q -DforceStdout | cut -c 2-)
curl -Lf https://nodejs.org/dist/v${VERSION}/win-x64/node.exe --create-dirs -o ~/.m2/repository/com/github/eirslett/node/${VERSION}/node-${VERSION}-win-x64.exe
- shell: powershell - shell: powershell
name: Link the cached Maven repository to the OS-dependent location name: Link the cached Maven repository to the OS-dependent location
if: inputs.create-cache-if-it-doesnt-exist == 'false' && runner.os == 'Windows' if: inputs.create-cache-if-it-doesnt-exist == 'false' && runner.os == 'Windows'
@ -62,3 +53,19 @@ runs:
!~/.m2/repository/org/keycloak !~/.m2/repository/org/keycloak
key: ${{ steps.weekly-cache-key.outputs.key }} key: ${{ steps.weekly-cache-key.outputs.key }}
enableCrossOsArchive: true enableCrossOsArchive: true
- name: Get Node.js and PNPM versions
id: tooling-versions
shell: bash
run: |
echo "node=$(mvn help:evaluate -Dexpression=node.version -q -DforceStdout | cut -c 2-)" >> $GITHUB_OUTPUT
echo "pnpm=$(mvn help:evaluate -Dexpression=pnpm.version -q -DforceStdout)" >> $GITHUB_OUTPUT
# Downloading Node.js often fails due to network issues, therefore we cache the artifacts downloaded by the frontend plugin.
- uses: actions/cache@v4
name: Cache Node.js related artifacts
with:
path: |
~/.m2/repository/com/github/eirslett/node
~/.m2/repository/com/github/eirslett/pnpm
key: ${{ runner.os }}-frontend-plugin-artifacts-${{ steps.tooling-versions.outputs.node }}-${{ steps.tooling-versions.outputs.pnpm }}