improve error handling in new scripts

This commit is contained in:
ebbit1q 2026-01-03 14:47:01 +01:00
parent b635ca367d
commit 52dc9a9fdf
2 changed files with 28 additions and 14 deletions

View file

@ -1,27 +1,40 @@
#!/bin/bash #!/bin/bash
# We cache thinned versions of universal ("fat") Qt binaries to reduce the size of the packages and caches. # This script is used to resolve the latest patch version of Qt using aqtinstall.
# The universal binaries are install via aqtinstall. We use wildcards to get the latest patch version. E.g. "6.6.*" -> "6.6.3". # It interprets 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 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. # It uses the runner's GITHUB_OUTPUT env variable.
# Usage example: .ci/resolve_latest_aqt_qt_version.sh "6.6.*" # 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 version is already specific (no wildcard), use it as-is
if [[ "$QT_SPEC" != *"*" ]]; then if [[ $qt_spec != *"*" ]]; then
echo "version=$QT_SPEC" >> "$GITHUB_OUTPUT" echo "version $qt_spec is already resolved"
exit 0 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 fi
# Resolve latest patch # Resolve latest patch
QT_RESOLVED=$(aqt list-qt mac desktop --spec "$QT_SPEC" --latest-version) if ! qt_resolved=$(aqt list-qt mac desktop --spec "$qt_spec" --latest-version); then
echo "QT_RESOLVED=$QT_RESOLVED" exit 1
if [ -z "$QT_RESOLVED" ]; then
echo "Error: Could not resolve Qt version for $QT_SPEC"
exit 1
fi 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"

View file

@ -18,6 +18,7 @@ function thin() {
} }
export -f thin # export to allow use in xargs export -f thin # export to allow use in xargs
export arch export arch
set -eo pipefail
echo "::group::Thinning Qt libraries to $arch using $nproc cores" 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 '{}'" find "$GITHUB_WORKSPACE/Qt" -type f -print0 | xargs -0 -n1 -P"$nproc" -I{} bash -c "thin '{}'"