Path: blob/trunk/scripts/github-actions/collect-test-logs.sh
3992 views
#!/usr/bin/env bash1# Collects failed test logs from Bazel testlogs directory2# Reads targets from build/failures/_run2.txt if present, otherwise _run1.txt34set -euxo pipefail56TESTLOGS_ROOT=$(bazel info bazel-testlogs)78LIST_FILE=""9if [ -s build/failures/_run2.txt ]; then10LIST_FILE="build/failures/_run2.txt"11elif [ -s build/failures/_run1.txt ]; then12LIST_FILE="build/failures/_run1.txt"13else14exit 015fi1617echo "Failures to collect from $LIST_FILE:"18cat "$LIST_FILE"1920while IFS= read -r target; do21[ -z "$target" ] && continue2223# Convert //path/to:target to path/to/target24rel_path=$(tr ':' '/' <<< "${target#//}")2526log_source="$TESTLOGS_ROOT/${rel_path}/test.log"2728if [ -f "$log_source" ]; then29# Convert path separators to underscores for safe filename30safe_name="${target#//}"31safe_name="${safe_name//[\/:]/_}"32echo "Copying log for $target..."33cp "$log_source" "build/failures/${safe_name}.log"34else35echo "Warning: No log found for $target at $log_source" >&236fi37done < "$LIST_FILE"383940