Skip to content

Commit

Permalink
Cache Node.js artifacts from maven-frontend-plugin on CI (keycloak#…
Browse files Browse the repository at this point in the history
…33815)

Closes keycloak#31835

Signed-off-by: Jon Koops <[email protected]>
  • Loading branch information
jonkoops authored and Petar-CV committed Oct 25, 2024
1 parent fc0708e commit 773ab17
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions .github/actions/maven-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,6 @@ runs:
# Enable cross-os archive use the cache on both Linux and Windows
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
name: Link the cached Maven repository to the OS-dependent location
if: inputs.create-cache-if-it-doesnt-exist == 'false' && runner.os == 'Windows'
Expand All @@ -61,4 +52,20 @@ runs:
~/.m2/repository/*/*
!~/.m2/repository/org/keycloak
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 }}

0 comments on commit 773ab17

Please sign in to comment.