From c6e076b0d7e50a40bdfddc1ae671110a54ef8449 Mon Sep 17 00:00:00 2001 From: "Mateusz \"Serafin\" Gajewski" Date: Mon, 30 Sep 2024 13:02:53 +0200 Subject: [PATCH] Cache NodeJS in GHA --- .github/actions/setup/action.yml | 29 +++++++++++++++++++++++++++++ .gitignore | 1 + .mvn/maven.config | 1 + core/trino-web-ui/pom.xml | 2 +- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 66f8ed473321..fdd65a9ded66 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -42,6 +42,35 @@ runs: with: distribution: 'temurin' # use same JDK distro as in Trino docker images java-version: ${{ inputs.java-version }} + - name: Get NodeJS version from parent pom + shell: bash + run: | + node_version=$(grep -m 1 '' "pom.xml" | sed -n 's/.*\(.*\)<\/dep.frontend-node.version>.*/\1/p') + if [ -n "$node_version" ]; then + echo "node version is $node_version" + echo "NODE_VERSION=$node_version" >>${GITHUB_ENV} + exit 0 + fi + - name: Cache and Restore local NodeJS + id: cache-nodejs + if: ${{ format('{0}', inputs.cache) == 'true' && env.NODE_VERSION != '' }} + uses: actions/cache@v4 + with: + # Note: must be same set of paths as for cache:restore mode + path: .node + key: ${{ runner.os }}-nodejs-${{ env.NODE_VERSION }} + restore-keys: | + ${{ runner.os }}-nodejs- + - name: Restore local NodeJS + id: cache_restore-nodejs + if: ${{ format('{0}', inputs.cache) == 'restore' && env.NODE_VERSION != '' }} + uses: actions/cache/restore@v4 + with: + # Note: must be same set of paths as for cache:true mode + path: .node + key: ${{ runner.os }}-nodejs-${{ env.NODE_VERSION }} + restore-keys: | + ${{ runner.os }}-nodejs- - name: Cache and Restore local Maven repo id: cache if: ${{ format('{0}', inputs.cache) == 'true' }} diff --git a/.gitignore b/.gitignore index 2b0cf1060315..9ab8de9022e8 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,4 @@ product-test-reports .github/bin/redshift/.cluster-identifier **/dependency-reduced-pom.xml core/trino-web-ui/src/main/resources/webapp/dist/ +.node diff --git a/.mvn/maven.config b/.mvn/maven.config index bc69b417b1a9..b88efb72ec98 100644 --- a/.mvn/maven.config +++ b/.mvn/maven.config @@ -10,3 +10,4 @@ -b smart -Dair.main.basedir=${session.rootDirectory} +-Dnode.tmpdir=${session.rootDirectory}/.node/ diff --git a/core/trino-web-ui/pom.xml b/core/trino-web-ui/pom.xml index 4391e47531fc..7923130251a6 100644 --- a/core/trino-web-ui/pom.xml +++ b/core/trino-web-ui/pom.xml @@ -79,7 +79,7 @@ com.github.eirslett frontend-maven-plugin - ${project.build.directory} + ${node.tmpdir}