Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/scripts/github-actions/rerun-failures.sh
3992 views
1
#!/usr/bin/env bash
2
# Parse Bazel console log for failures and optionally rerun with debug.
3
4
set -euo pipefail
5
6
RUN_CMD="${1:-}"
7
RERUN_WITH_DEBUG="${2:-false}"
8
9
mkdir -p build/failures
10
awk '$1 ~ /^\/\// && $2 ~ /(FAILED|TIMEOUT|INCOMPLETE)/ && $3 == "in" { print $1 }' build/bazel-console.log > build/failures/_run1.txt
11
12
if [ "$RERUN_WITH_DEBUG" != "true" ]; then
13
exit 0
14
fi
15
16
if [ ! -s build/failures/_run1.txt ]; then
17
echo "No failed tests to rerun."
18
exit 0
19
fi
20
21
if [[ "$RUN_CMD" == *"/ci-build.sh"* ]]; then
22
base_cmd="bazel test --config=rbe-ci --build_tests_only --keep_going"
23
else
24
base_cmd=$(echo "$RUN_CMD" | sed 's| //[^ ]*||g')
25
fi
26
targets=$(tr '\n' ' ' < build/failures/_run1.txt)
27
echo "Rerunning tests: $base_cmd --test_env=SE_DEBUG=true --flaky_test_attempts=1 $targets"
28
set +e
29
{
30
$base_cmd --test_env=SE_DEBUG=true --flaky_test_attempts=1 $targets
31
} 2>&1 | tee build/bazel-console2.log
32
status=$?
33
set -e
34
awk '$1 ~ /^\/\// && $2 ~ /FAILED/ && $3 == "in" { print $1 }' build/bazel-console2.log > build/failures/_run2.txt
35
exit $status
36
37