Path: blob/trunk/scripts/github-actions/rerun-failures.sh
3992 views
#!/usr/bin/env bash1# Parse Bazel console log for failures and optionally rerun with debug.23set -euo pipefail45RUN_CMD="${1:-}"6RERUN_WITH_DEBUG="${2:-false}"78mkdir -p build/failures9awk '$1 ~ /^\/\// && $2 ~ /(FAILED|TIMEOUT|INCOMPLETE)/ && $3 == "in" { print $1 }' build/bazel-console.log > build/failures/_run1.txt1011if [ "$RERUN_WITH_DEBUG" != "true" ]; then12exit 013fi1415if [ ! -s build/failures/_run1.txt ]; then16echo "No failed tests to rerun."17exit 018fi1920if [[ "$RUN_CMD" == *"/ci-build.sh"* ]]; then21base_cmd="bazel test --config=rbe-ci --build_tests_only --keep_going"22else23base_cmd=$(echo "$RUN_CMD" | sed 's| //[^ ]*||g')24fi25targets=$(tr '\n' ' ' < build/failures/_run1.txt)26echo "Rerunning tests: $base_cmd --test_env=SE_DEBUG=true --flaky_test_attempts=1 $targets"27set +e28{29$base_cmd --test_env=SE_DEBUG=true --flaky_test_attempts=1 $targets30} 2>&1 | tee build/bazel-console2.log31status=$?32set -e33awk '$1 ~ /^\/\// && $2 ~ /FAILED/ && $3 == "in" { print $1 }' build/bazel-console2.log > build/failures/_run2.txt34exit $status353637