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

slawrence pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil-infrastructure.git


The following commit(s) were added to refs/heads/main by this push:
     new 45e3436  Improve error handling of the check-release script
45e3436 is described below

commit 45e3436fc7ed3226201fdba777f74b91e89ececa
Author: Steve Lawrence <[email protected]>
AuthorDate: Fri Jan 30 12:56:28 2026 -0500

    Improve error handling of the check-release script
    
    - If we fail to download dist/maven files (e.g. incorrect URL, temporary
      server issue), we currently ignore it and end up with confusing errors
      about non-reproducible builds. Instead, detect the failure and error.
    - Detect if the DIST_URL parameter is empty and error. This URL is
      required and leads to weird behaviors if accidentally excluded.
    
    These changes required some refactorings, including moving the
    test_files and print_results functions/colors to the top of the script
    and adding a usage function
---
 containers/check-release/src/check-release.sh | 157 ++++++++++++++------------
 1 file changed, 87 insertions(+), 70 deletions(-)

diff --git a/containers/check-release/src/check-release.sh 
b/containers/check-release/src/check-release.sh
index bdcf4aa..dff9d4e 100755
--- a/containers/check-release/src/check-release.sh
+++ b/containers/check-release/src/check-release.sh
@@ -15,12 +15,69 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-if [[ "$#" -lt "2" || "$#" -gt 3 ]]
-then
-       echo "error: incorrect number of arguments" >&2
-       echo "Usage: $0 <DIST_URL> <MAVEN_URL> [LOCAL_RELEASE_DIR]" >&2
-       exit 1
-fi
+RED="\x1b[31m"
+GREEN="\033[32m"
+YELLOW="\033[33m"
+RESET="\033[0m"
+PASS="$GREEN✔$RESET"
+FAIL="$RED✘$RESET"
+WARN="$YELLOW‼$RESET"
+
+FAILURE_COUNT=0
+
+# Read a list of newline separated paths from a file ($1) and commands from
+# stdin to evaluate for each line in the file. Each line in the file is
+# expected to be a path to a file, but it is not enforced. All {} strings in 
the
+# commands are replaced with the current line in the file prior to evaluation.
+# The commands are also evaluated in a new bash process, so they are free to
+# include commands like 'cd' or 'exit' without affecting the main script. Note
+# this means they cannot access variables or functions in the current process
+# scope. For each line, this outputs a pass/fail icon (based on the exit code
+# of the last command) followed by the line. A count of all failures is tallied
+# in the FAILURE_COUNT variable.
+#
+# Usage tips:
+#
+# It is recommended to wrap {} in apostrophes to avoid unexpected variable or
+# other expansions.
+#
+# Process substitution can be used for the file list to to avoid the need to
+# create actual files.
+#
+# Commands are read from stdin to support the recommended use of heredocs. In
+# general, tests should use <<-'CMD' commands CMD, especially if no variable
+# expansion or process substitution is wanted or needed. If that is needed,
+# tests should usually use <<-CMD commands CMD.
+#
+# Usage examples:
+#
+# test_files all_text_files.txt <<-'CMD'
+#     gpg --verify '{}.asc' '{}'
+# CMD
+#
+# test_files <(find dir/ -name '*.txt') <<-CMD
+#     cmp '{}' "$OTHER_DIR"/'{}'
+# CMD
+#
+test_files() {
+       FILE_LIST="$1"
+       CMDS=$(cat)
+       while IFS= read -r LINE
+       do
+               CMDS_TO_EVAL="${CMDS//\{\}/$LINE}"
+               bash -c "$CMDS_TO_EVAL" &> /dev/null
+               RC=$?
+               print_result $RC $LINE
+               [ $RC -eq 0 ] || FAILURE_COUNT=$((FAILURE_COUNT + 1))
+       done < "$FILE_LIST"
+}
+
+print_result() {
+       RC=$1
+       MESSAGE=$2
+       [ $RC -eq 0 ] && echo -ne "$PASS" || echo -ne "$FAIL"
+       echo " $MESSAGE"
+}
 
 download_dir() {
        # force a trailing slash by removing a slash it if exists and then 
adding
@@ -46,14 +103,38 @@ download_dir() {
                --cut-dirs=$CUT_DIRS \
                "$URL"
 
+       RC=$?
+       if [ $RC -ne 0 ]; then
+               print_result $RC "Failed to download URL: $URL" >&2
+               exit 1
+       fi
+
        # wget on some systems (e.g. Ubuntu 22.04) leaves behind .tmp files used
        # when downloading files, likely related to --reject=index.html. Delete
        # those if they exist.
        find "$(basename "$URL")" -name '*.tmp' -delete
 }
 
+
+usage() {
+       echo "Usage: $0 <DIST_URL> <MAVEN_URL> [LOCAL_RELEASE_DIR]" >&2
+}
+
+if [[ "$#" -lt "2" || "$#" -gt 3 ]]
+then
+       echo "error: incorrect number of arguments" >&2
+       usage
+       exit 1
+fi
+
 # URL of release candidate directory in dist/dev, e.g. 
https://dist.apache.org/repos/dist/dev/daffodil/1.0.0-rc1
 DIST_URL=$1
+if [ -z "$DIST_URL" ]
+then
+  echo "error: DIST_URL parameter must not be empty" >&2
+  usage
+  exit 1
+fi
 
 # URL of maven staging repository, e.g. 
https://repository.apache.org/content/repositories/orgapachedaffodil-1234
 MAVEN_URL=$2
@@ -111,70 +192,6 @@ else
        printf "\n==== Skipping Download, release-download/ directory already 
exists ====\n"
 fi
 
-RED="\x1b[31m"
-GREEN="\033[32m"
-YELLOW="\033[33m"
-RESET="\033[0m"
-PASS="$GREEN✔$RESET"
-FAIL="$RED✘$RESET"
-WARN="$YELLOW‼$RESET"
-
-FAILURE_COUNT=0
-
-# Read a list of newline separated paths from a file ($1) and commands from
-# stdin to evaluate for each line in the file. Each line in the file is
-# expected to be a path to a file, but it is not enforced. All {} strings in 
the
-# commands are replaced with the current line in the file prior to evaluation.
-# The commands are also evaluated in a new bash process, so they are free to
-# include commands like 'cd' or 'exit' without affecting the main script. Note
-# this means they cannot access variables or functions in the current process
-# scope. For each line, this outputs a pass/fail icon (based on the exit code
-# of the last command) followed by the line. A count of all failures is tallied
-# in the FAILURE_COUNT variable.
-#
-# Usage tips:
-#
-# It is recommended to wrap {} in apostrophes to avoid unexpected variable or
-# other expansions.
-#
-# Process substitution can be used for the file list to to avoid the need to
-# create actual files.
-#
-# Commands are read from stdin to support the recommended use of heredocs. In
-# general, tests should use <<-'CMD' commands CMD, especially if no variable
-# expansion or process substitution is wanted or needed. If that is needed,
-# tests should usually use <<-CMD commands CMD.
-#
-# Usage examples:
-#
-# test_files all_text_files.txt <<-'CMD'
-#     gpg --verify '{}.asc' '{}'
-# CMD
-#
-# test_files <(find dir/ -name '*.txt') <<-CMD
-#     cmp '{}' "$OTHER_DIR"/'{}'
-# CMD
-#
-test_files() {
-       FILE_LIST="$1"
-       CMDS=$(cat)
-       while IFS= read -r LINE
-       do
-               CMDS_TO_EVAL="${CMDS//\{\}/$LINE}"
-               bash -c "$CMDS_TO_EVAL" &> /dev/null
-               RC=$?
-               print_result $RC $LINE
-               [ $RC -eq 0 ] || FAILURE_COUNT=$((FAILURE_COUNT + 1))
-       done < "$FILE_LIST"
-}
-
-print_result() {
-       RC=$1
-       MESSAGE=$2
-       [ $RC -eq 0 ] && echo -ne "$PASS" || echo -ne "$FAIL"
-       echo " $MESSAGE"
-}
-
 printf "\n==== Dist SHA512 Checksum ====\n"
 test_files <(find "$DIST_DIR" -type f ! -name '*.sha512' ! -name '*.asc') 
<<-'CMD'
        cd "$(dirname '{}')"

Reply via email to