This is an automated email from the ASF dual-hosted git repository.

adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 0f848e4e24 HDDS-10273. Intermittent build failure while downloading 
NodeJS (#6686)
0f848e4e24 is described below

commit 0f848e4e241a899a86a15d94f54eccfdc8ab77e2
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Fri Jun 7 10:50:31 2024 +0200

    HDDS-10273. Intermittent build failure while downloading NodeJS (#6686)
---
 .github/workflows/populate-cache.yml | 24 ++++++++++++--
 dev-support/ci/download-nodejs.sh    | 63 ++++++++++++++++++++++++++++++++++++
 hadoop-ozone/recon/pom.xml           |  2 +-
 pom.xml                              |  3 ++
 4 files changed, 89 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/populate-cache.yml 
b/.github/workflows/populate-cache.yml
index d4c9cd8120..788418b2d7 100644
--- a/.github/workflows/populate-cache.yml
+++ b/.github/workflows/populate-cache.yml
@@ -28,6 +28,7 @@ on:
       - '.github/workflows/populate-cache.yml'
   schedule:
     - cron: '20 3 * * *'
+  workflow_dispatch:
 
 jobs:
   build:
@@ -52,16 +53,35 @@ jobs:
           distribution: 'temurin'
           java-version: 8
 
+      - name: Get NodeJS version
+        id: nodejs-version
+        if: steps.restore-cache.outputs.cache-hit != 'true'
+        run: echo "nodejs-version=$(mvn help:evaluate 
-Dexpression=nodejs.version -q -DforceStdout)" >> $GITHUB_OUTPUT
+
+      - name: Restore NodeJS tarballs
+        id: restore-nodejs
+        if: steps.restore-cache.outputs.cache-hit != 'true'
+        uses: actions/cache@v4
+        with:
+          path: ~/.m2/repository/com/github/eirslett/node
+          key: nodejs-${{ steps.nodejs-version.outputs.nodejs-version }}
+
+      - name: Download NodeJS
+        if: steps.restore-cache.outputs.cache-hit != 'true' && 
steps.restore-nodejs.outputs.cache-hit != 'true'
+        run: dev-support/ci/download-nodejs.sh
+        env:
+          NODEJS_VERSION: ${{ steps.nodejs-version.outputs.nodejs-version }}
+
       - name: Fetch dependencies
         if: steps.restore-cache.outputs.cache-hit != 'true'
-        run: mvn --batch-mode --fail-never --no-transfer-progress 
--show-version -Pgo-offline -Pdist clean verify
+        run: mvn --batch-mode --no-transfer-progress --show-version 
-Pgo-offline -Pdist clean verify
 
       - name: Delete Ozone jars from repo
         if: steps.restore-cache.outputs.cache-hit != 'true'
         run: rm -fr ~/.m2/repository/org/apache/ozone
 
       - name: List repo contents
-        if: steps.restore-cache.outputs.cache-hit != 'true'
+        if: always()
         run: find ~/.m2/repository -type f | sort | xargs ls -lh
 
       - name: Save cache for Maven dependencies
diff --git a/dev-support/ci/download-nodejs.sh 
b/dev-support/ci/download-nodejs.sh
new file mode 100755
index 0000000000..2eef8dd062
--- /dev/null
+++ b/dev-support/ci/download-nodejs.sh
@@ -0,0 +1,63 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# This script gets a list of the changed files from git, and matches
+# that list against a set of regexes, each of which corresponds to a
+# test group.  For each set of matches, a flag is set to let github
+# actions know to run that test group.
+
+# Downloads Node.js for multiple platforms (Linux, Mac)
+
+set -u -o pipefail
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+cd "${DIR}/../.." || exit 1
+
+: ${REPO_DIR:="${HOME}/.m2/repository"}
+
+mkdir -p "${REPO_DIR}"
+
+declare -i rc=1
+
+if [[ -z "${NODEJS_VERSION:-}" ]]; then
+  NODEJS_VERSION=$(mvn help:evaluate -Dexpression=nodejs.version -q 
-DforceStdout)
+fi
+
+if [[ -n "${NODEJS_VERSION}" ]]; then
+  rc=0
+  for platform in darwin-x64 linux-x64; do
+    
url="https://nodejs.org/dist/v${NODEJS_VERSION}/node-v${NODEJS_VERSION}-${platform}.tar.gz";
+    
output="${REPO_DIR}/com/github/eirslett/node/${NODEJS_VERSION}/node-${NODEJS_VERSION}-${platform}.tar.gz"
+    mkdir -pv "$(dirname "${output}")"
+
+    irc=1
+    for i in 1 2 3; do
+      echo "Downloading ${url}, attempt ${i}"
+      if curl --location --continue-at - -o "${output}" "${url}"; then
+        irc=0
+        break
+      fi
+      sleep 2
+    done
+
+    if [[ ${rc} -eq 0 ]]; then
+      rc=${irc}
+    fi
+  done
+fi
+
+exit ${rc}
diff --git a/hadoop-ozone/recon/pom.xml b/hadoop-ozone/recon/pom.xml
index 2895840aaf..917a691c54 100644
--- a/hadoop-ozone/recon/pom.xml
+++ b/hadoop-ozone/recon/pom.xml
@@ -103,7 +103,7 @@
               <goal>install-node-and-npm</goal>
             </goals>
             <configuration>
-              <nodeVersion>v16.14.2</nodeVersion>
+              <nodeVersion>v${nodejs.version}</nodeVersion>
             </configuration>
           </execution>
           <execution>
diff --git a/pom.xml b/pom.xml
index f1a910985f..a0f01b5c94 100644
--- a/pom.xml
+++ b/pom.xml
@@ -294,6 +294,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xs
     <spring.version>5.3.34</spring.version>
     <jooq.version>3.11.10</jooq.version>
 
+    <!-- Node.js version number (without the v prefix required by 
frontend-maven-plugin) -->
+    <nodejs.version>16.14.2</nodejs.version>
+
     <vault.driver.version>5.1.0</vault.driver.version>
     <native.lib.tmp.dir></native.lib.tmp.dir>
     <properties.maven.plugin.version>1.2.1</properties.maven.plugin.version>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to