[CI] Resolve the coverage source root before the build dir cd

The previous commit computed SRC_ROOT after `cd "$BUILD_DIR"`, under a comment
claiming it ran before. `$0` is relative to the directory the script was invoked
from, so from inside the build dir `dirname "$0"` no longer resolves and the
subshell's `cd` fails. Under `set -e` that is fatal rather than an empty variable,
which took down every leg in the matrix, coverage or not, including the ones this
change does not otherwise touch.

Move it above the cd and guard it on MAKE_COVERAGE, since the coverage report is
the only consumer. Resolving it unconditionally meant a coverage-only detail was
paid for by every build in the fleet, and gave every one of them a way to fail.
This commit is contained in:
Lukas Brübach 2026-10-05 14:25:47 +02:00
parent 2c249438d5
commit 2425c868a3

View file

@ -142,11 +142,16 @@ if [[ ! $BUILD_DIR ]]; then
BUILD_DIR="build" BUILD_DIR="build"
fi fi
mkdir -p "$BUILD_DIR" mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
# Captured before the cd because $0 is relative to the directory the script was invoked from, if [[ $MAKE_COVERAGE ]]; then
# and after the cd it no longer resolves to anything. The coverage report needs the source root. # Resolved while the working directory is still the source root. $0 is relative to the
SRC_ROOT="$(cd "$(dirname "$0")/.." && pwd)" # directory the script was invoked from, so after the cd below it no longer resolves, and
# under `set -e` the failed subshell would abort the build rather than just yielding an empty
# variable. Only the coverage report needs this, so only coverage pays for it.
SRC_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
fi
cd "$BUILD_DIR"
# Set minimum CMake Version # Set minimum CMake Version
export CMAKE_POLICY_VERSION_MINIMUM=3.10 export CMAKE_POLICY_VERSION_MINIMUM=3.10