From 20acac3aaccfbd7262c07835c73de265d0598437 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Thu, 30 Mar 2023 13:13:20 -0500 Subject: [PATCH] CLDR-16522 deps add .node-version file @ v18.15.0 (#2823) - add a .node-version file, defacto format defined at https://github.com/shadowspawn/node-version-usage - mvn/ant code to use the .node-version file within frontend-maven-plugin, workaround for https://github.com/eirslett/frontend-maven-plugin/issues/1047 - use the nodenv/actions/node-version@v3 action which reads .node-version in relevant places - turn on webpack's persistent cache, and cache it across builds - also, move some maven plugin dependencies up to tools/pom.xml I'm keeping package dependencies (such as mysql) in cldr-apps/pom.xml --- .github/workflows/gh-pages.yml | 4 +-- .github/workflows/js.yml | 13 +++++++- .github/workflows/maven.yml | 8 +++++ .node-version | 1 + tools/cldr-apps/js/webpack.config.js | 4 +++ tools/cldr-apps/pom.xml | 46 +++++++++++++++++++++++----- tools/pom.xml | 29 ++++++++++++++++++ 7 files changed, 94 insertions(+), 11 deletions(-) create mode 100644 .node-version diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 1c625913c0f..cf1f1e6bc97 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -28,9 +28,7 @@ jobs: restore-keys: | ${{ runner.os }}-nodetr- nodetr- - - uses: actions/setup-node@v3 - with: - node-version: '16' + - uses: nodenv/actions/node-version@v3 # setup using .node-version - name: Run TR archiver # Note: will update ToC if out of date run: 'cd tools/scripts/tr-archive/ && npm ci && npm run build' diff --git a/.github/workflows/js.yml b/.github/workflows/js.yml index 7bf9b33232b..75f936a8bb8 100644 --- a/.github/workflows/js.yml +++ b/.github/workflows/js.yml @@ -3,10 +3,12 @@ name: JavaScript Tests on: push: paths: + - '.node-version' - 'tools/cldr-apps/js/**' - '.github/workflows/js.yml' pull_request: paths: + - '.node-version' - 'tools/cldr-apps/js/**' - '.github/workflows/js.yml' @@ -17,6 +19,15 @@ jobs: - uses: actions/checkout@v3 with: lfs: false # not needed for this job, as we don’t currently do a Java build + - uses: nodenv/actions/node-version@v3 # setup using .node-version + - name: Cache webpack + uses: actions/cache@v3 + with: + path: tools/cldr-apps/target/webpack_cache + key: ${{ runner.os }}-webpack-${{ hashFiles('tools/cldr-apps/package*') }}-${{ hashFiles('tools/cldr-apps/src/**') }} + restore-keys: | + ${{ runner.os }}-webpack- + webpack- - name: Cache npm repository uses: actions/cache@v3 with: @@ -31,5 +42,5 @@ jobs: # stopgap: fail this if it takes too long timeout-minutes: 10 run: (cd tools/cldr-apps/js && npm t) - - name: Run Webpack build + - name: Run Webpack production build run: (cd tools/cldr-apps/js && npm run build) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 6952305d0c7..d5f2e804444 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -46,6 +46,14 @@ jobs: restore-keys: | ${{ runner.os }}-node- node- + - name: Cache webpack + uses: actions/cache@v3 + with: + path: tools/cldr-apps/target/webpack_cache + key: ${{ runner.os }}-webpack-${{ hashFiles('tools/cldr-apps/package*') }}-${{ hashFiles('tools/cldr-apps/src/**') }} + restore-keys: | + ${{ runner.os }}-webpack- + webpack- - name: Lint GitHub Actions run: npx yaml-lint .github/workflows/*.yml - name: Build with Maven diff --git a/.node-version b/.node-version new file mode 100644 index 00000000000..e048c8ca198 --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +v18.15.0 diff --git a/tools/cldr-apps/js/webpack.config.js b/tools/cldr-apps/js/webpack.config.js index e2a20fd21fa..7707bdb673e 100644 --- a/tools/cldr-apps/js/webpack.config.js +++ b/tools/cldr-apps/js/webpack.config.js @@ -7,6 +7,10 @@ module.exports = (env, argv) => { const DEV = (mode === 'development'); return { entry: "./src/index.js", + cache: { + type: 'filesystem', + cacheDirectory: path.resolve(__dirname, '../target/webpack_cache'), + }, output: { filename: "bundle.js", path: path.resolve(__dirname, "..", "src", "main", "webapp", "dist"), diff --git a/tools/cldr-apps/pom.xml b/tools/cldr-apps/pom.xml index 8236e1cb7b0..01eef91b818 100644 --- a/tools/cldr-apps/pom.xml +++ b/tools/cldr-apps/pom.xml @@ -152,6 +152,44 @@ ${project.artifactId} + + maven-antrun-plugin + + + initialize + + + node.version= + + + + + + + + + run + + + + + + org.codehaus.mojo + properties-maven-plugin + + + initialize + + read-project-properties + + + + ${project.basedir}/target/node-version.properties + + + + + maven-clean-plugin @@ -166,7 +204,6 @@ maven-war-plugin org.apache.maven.plugins - 3.2.3 @@ -181,7 +218,6 @@ io.openliberty.tools liberty-maven-plugin - 3.5.1 cldr @@ -196,7 +232,6 @@ maven-resources-plugin - 2.5 copy-resources @@ -219,7 +254,6 @@ org.apache.maven.plugins maven-failsafe-plugin - 2.22.2 ${default.http.port} @@ -248,7 +282,6 @@ com.github.eirslett frontend-maven-plugin - 1.12.1 install node and npm @@ -284,8 +317,7 @@ - v16.17.1 - 8.15.0 + ${node.version} ${project.basedir}/js diff --git a/tools/pom.xml b/tools/pom.xml index 51baa2dbc4d..6f5d10b1601 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -196,6 +196,26 @@ -Xmx6g -enableassertions + + io.openliberty.tools + liberty-maven-plugin + 3.5.1 + + + com.github.eirslett + frontend-maven-plugin + 1.12.1 + + + org.apache.maven.plugins + maven-failsafe-plugin + 2.22.2 + + + org.codehaus.mojo + properties-maven-plugin + 1.1.0 + maven-jar-plugin 3.0.2 @@ -204,6 +224,15 @@ maven-install-plugin 3.0.1 + + maven-antrun-plugin + 3.1.0 + + + maven-war-plugin + org.apache.maven.plugins + 3.2.3 + maven-deploy-plugin 2.8.2