Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8ea2480

Browse files
committedOct 16, 2024··
Cache Node.js artifacts from maven-frontend-plugin on CI
Closes #31835 Signed-off-by: Jon Koops <[email protected]>
1 parent 61fffce commit 8ea2480

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed
 

‎.github/actions/maven-cache/action.yml

+30-12
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,14 @@ runs:
2525
# Two asterisks are needed to make the follow-up exclusion work
2626
# see https://github.com/actions/toolkit/issues/713 for the upstream issue
2727
path: |
28-
~/.m2/repository/*/*
28+
~/.m2/repository/*/*/*/*
2929
!~/.m2/repository/org/keycloak
30+
!~/.m2/repository/com/github/eirslett/node
31+
!~/.m2/repository/com/github/eirslett/pnpm
3032
key: ${{ steps.weekly-cache-key.outputs.key }}
3133
# Enable cross-os archive use the cache on both Linux and Windows
3234
enableCrossOsArchive: true
3335

34-
- id: download-node-for-windows
35-
# 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.
36-
# 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.
37-
if: inputs.create-cache-if-it-doesnt-exist == 'true' && steps.cache-maven-repository.outputs.cache-hit != 'true'
38-
shell: bash
39-
run: |
40-
export VERSION=$(mvn help:evaluate -Dexpression=node.version -q -DforceStdout | cut -c 2-)
41-
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
42-
4336
- shell: powershell
4437
name: Link the cached Maven repository to the OS-dependent location
4538
if: inputs.create-cache-if-it-doesnt-exist == 'false' && runner.os == 'Windows'
@@ -58,7 +51,32 @@ runs:
5851
with:
5952
# This needs to repeat the same path pattern as above to find the matching cache
6053
path: |
61-
~/.m2/repository/*/*
54+
~/.m2/repository/*/*/*/*
6255
!~/.m2/repository/org/keycloak
56+
!~/.m2/repository/com/github/eirslett/node
57+
!~/.m2/repository/com/github/eirslett/pnpm
6358
key: ${{ steps.weekly-cache-key.outputs.key }}
64-
enableCrossOsArchive: true
59+
enableCrossOsArchive: true
60+
61+
- name: List the contents of the Maven repository
62+
shell: bash
63+
run: |
64+
ls -R ~/.m2/repository/org/apache || exit 0
65+
ls -R ~/.m2/repository/org/keycloak || exit 0
66+
ls -R ~/.m2/repository/com/github/eirslett || exit 0
67+
68+
- name: Get Node.js and PNPM versions
69+
id: tooling-versions
70+
shell: bash
71+
run: |
72+
echo "node=$(mvn help:evaluate -Dexpression=node.version -q -DforceStdout | cut -c 2-)" >> $GITHUB_OUTPUT
73+
echo "pnpm=$(mvn help:evaluate -Dexpression=pnpm.version -q -DforceStdout)" >> $GITHUB_OUTPUT
74+
75+
# Downloading Node.js often fails due to network issues, therefore we cache the artifacts downloaded by the frontend plugin.
76+
- uses: actions/cache@v4
77+
name: Cache Node.js related artifacts
78+
with:
79+
path: |
80+
~/.m2/repository/com/github/eirslett/node
81+
~/.m2/repository/com/github/eirslett/pnpm
82+
key: ${{ runner.os }}-frontend-plugin-artifacts-${{ steps.tooling-versions.outputs.node }}-${{ steps.tooling-versions.outputs.pnpm }}

0 commit comments

Comments
 (0)
Please sign in to comment.