From 52dc9a9fdf527185839aa226e37c9cd5f6743efa Mon Sep 17 00:00:00 2001 From: ebbit1q Date: Sat, 3 Jan 2026 14:47:01 +0100 Subject: [PATCH] improve error handling in new scripts --- .ci/resolve_latest_aqt_qt_version.sh | 41 ++++++++++++++++++---------- .ci/thin_macos_qtlib.sh | 1 + 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/.ci/resolve_latest_aqt_qt_version.sh b/.ci/resolve_latest_aqt_qt_version.sh index 124c0720d..154c15321 100755 --- a/.ci/resolve_latest_aqt_qt_version.sh +++ b/.ci/resolve_latest_aqt_qt_version.sh @@ -1,27 +1,40 @@ #!/bin/bash -# We cache thinned versions of universal ("fat") Qt binaries to reduce the size of the packages and caches. -# The universal binaries are install via aqtinstall. We use wildcards to get the latest patch version. E.g. "6.6.*" -> "6.6.3". -# This script is used to resolve the latest patch version of Qt. +# This script is used to resolve the latest patch version of Qt using aqtinstall. +# It interprets wildcards to get the latest patch version. E.g. "6.6.*" -> "6.6.3". -# This script is meant to be used by the ci enironment on macos runners only. +# This script is meant to be used by the ci enironment. # It uses the runner's GITHUB_OUTPUT env variable. # Usage example: .ci/resolve_latest_aqt_qt_version.sh "6.6.*" -QT_SPEC=$1 + +qt_spec=$1 +if [[ ! $qt_spec ]]; then + echo "usage: $0 [version]" + exit 2 +fi # If version is already specific (no wildcard), use it as-is -if [[ "$QT_SPEC" != *"*" ]]; then - echo "version=$QT_SPEC" >> "$GITHUB_OUTPUT" - exit 0 +if [[ $qt_spec != *"*" ]]; then + echo "version $qt_spec is already resolved" + echo "version=$qt_spec" >> "$GITHUB_OUTPUT" + exit 0 +fi + +if ! hash aqt; then + echo "aqt could not be found, has aqtinstall been installed?" + exit 2 fi # Resolve latest patch -QT_RESOLVED=$(aqt list-qt mac desktop --spec "$QT_SPEC" --latest-version) -echo "QT_RESOLVED=$QT_RESOLVED" -if [ -z "$QT_RESOLVED" ]; then - echo "Error: Could not resolve Qt version for $QT_SPEC" - exit 1 +if ! qt_resolved=$(aqt list-qt mac desktop --spec "$qt_spec" --latest-version); then + exit 1 fi -echo "version=$QT_RESOLVED" >> "$GITHUB_OUTPUT" +echo "resolved $qt_spec to $qt_resolved" +if [[ ! $qt_resolved ]]; then + echo "Error: Could not resolve Qt version for $qt_spec" + exit 1 +fi + +echo "version=$qt_resolved" >> "$GITHUB_OUTPUT" diff --git a/.ci/thin_macos_qtlib.sh b/.ci/thin_macos_qtlib.sh index 4ca8f03f5..6c3cc6720 100755 --- a/.ci/thin_macos_qtlib.sh +++ b/.ci/thin_macos_qtlib.sh @@ -18,6 +18,7 @@ function thin() { } export -f thin # export to allow use in xargs export arch +set -eo pipefail echo "::group::Thinning Qt libraries to $arch using $nproc cores" find "$GITHUB_WORKSPACE/Qt" -type f -print0 | xargs -0 -n1 -P"$nproc" -I{} bash -c "thin '{}'"