SERVER-105304 Attach build invocation text file to each compile task (#43061)

GitOrigin-RevId: 339e5a44ec88c9c7ada3488e61e6a0449407308f
This commit is contained in:
Zack Winter 2025-10-23 08:13:07 -10:00 committed by MongoDB Bot
parent 0834c302db
commit f69d83c092
8 changed files with 50 additions and 0 deletions

View File

@ -129,6 +129,7 @@ post:
- func: "save unsymbolized stacktraces and local invocation"
- func: "save mongo coredumps"
- func: "generate hang analyzer tasks"
- func: "attach bazel invocation text"
- func: "save failed unittests"
- func: "save hang analyzer debugger files"
- func: "save disk statistics"

View File

@ -2965,6 +2965,37 @@ functions:
display_name: Command To Run Failed Unit Tests on Workstation
optional: true
"upload bazel build invocation": &upload_bazel_build_invocation
command: s3.put
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: src/.bazel_build_invocation
remote_file: ${project}/${build_variant}/${revision}/unittests/${build_id}-${task_name}-${execution}/bazel_build_invocation.txt
bucket: mciuploads
permissions: public-read
content_type: text/plain
display_name: Build Command
optional: true
"upload engflow link": &upload_engflow_link
command: s3.put
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: src/.engflow_link
remote_file: ${project}/${build_variant}/${revision}/unittests/${build_id}-${task_name}-${execution}/engflow_link.txt
bucket: mciuploads
permissions: public-read
content_type: text/plain
display_name: EngFlow Link
optional: true
"attach bazel invocation text":
- *f_expansions_write
- *upload_bazel_build_invocation
- *upload_engflow_link
"save failed unittests":
- *f_expansions_write
- *gather_failed_unittests_resmoke

View File

@ -51,6 +51,7 @@ variables:
- func: "save code coverage data"
- func: "save mongo coredumps"
- func: "generate hang analyzer tasks"
- func: "attach bazel invocation text"
- func: "save failed unittests"
- func: "save bazel headers"
- func: "save bazel jvm dump"

View File

@ -25,6 +25,7 @@ variables:
- func: "save code coverage data"
- func: "save mongo coredumps"
- func: "generate hang analyzer tasks"
- func: "attach bazel invocation text"
- func: "save failed unittests"
- func: "save bazel headers"
- func: "save bazel jvm dump"

View File

@ -144,6 +144,7 @@ variables:
- func: "save code coverage data"
- func: "save mongo coredumps"
- func: "generate hang analyzer tasks"
- func: "attach bazel invocation text"
- func: "save failed unittests"
- func: "save hang analyzer debugger files"
- func: "save disk statistics"

View File

@ -121,12 +121,17 @@ bazel_evergreen_shutils::ensure_server_and_print_pid "$BAZEL_BINARY"
ALL_FLAGS="--verbose_failures ${LOCAL_ARG} ${bazel_args:-} ${bazel_compile_flags:-} ${task_compile_flags:-} --define=MONGO_VERSION=${version} ${patch_compile_flags:-}"
echo "${ALL_FLAGS}" >.bazel_build_flags
# Save the entire bazel build invocation to attach to the task for re-running locally
echo "bazel build ${ALL_FLAGS} ${targets}" >.bazel_build_invocation
set +o errexit
bazel_evergreen_shutils::retry_bazel_cmd 3 "$BAZEL_BINARY" \
build ${ALL_FLAGS} ${targets}
RET=$?
bazel_evergreen_shutils::write_last_engflow_link
set -o errexit
if [[ "$RET" -eq 124 ]]; then

View File

@ -229,6 +229,11 @@ bazel_evergreen_shutils::ensure_server_and_print_pid() {
bazel_evergreen_shutils::print_bazel_server_pid "$BAZEL_BINARY"
}
bazel_evergreen_shutils::write_last_engflow_link() {
engflow_link=$(grep -Eo 'https://[a-zA-Z0-9./?_=-]+' ${last_command_log_path} | grep 'sodalite\.cluster\.engflow\.com' | tail -n 1)
echo ${engflow_link} >.engflow_link
}
# Generic retry wrapper:
# $1: attempts
# $3: bazel binary
@ -245,6 +250,9 @@ bazel_evergreen_shutils::retry_bazel_cmd() {
local timeout_str="$(bazel_evergreen_shutils::timeout_prefix "${evergreen_remote_exec:-}")"
# Get command log path for usage afterwards
last_command_log_path=$(bazel info command_log)
# Everything else is the Bazel subcommand + flags (and possibly redirections/pipes).
# We *intentionally* keep it as raw words and reassemble to a single string for eval.
local raw_rest=("$@")

View File

@ -59,6 +59,8 @@ if [[ "$RET" == "0" ]]; then
fi
fi
bazel_evergreen_shutils::write_last_engflow_link
set -o errexit
# The --config flag needs to stay consistent between invocations to avoid evicting the previous results.