Skip to content

Commit b3c8719

Browse files
committed
[build] implement jobs to retry rbe failures with extra debugging
1 parent 4bec4e0 commit b3c8719

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

.github/workflows/bazel.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ on:
6161
required: false
6262
type: string
6363
default: ''
64+
download-name:
65+
description: name of artifact to download
66+
required: false
67+
type: string
68+
default: ''
69+
download-path:
70+
description: path of artifact to download
71+
required: false
72+
type: string
73+
default: ''
6474
upload-name:
6575
description: Name of artifact to upload
6676
required: false
@@ -161,6 +171,12 @@ jobs:
161171
- name: Setup curl for Ubuntu
162172
if: inputs.os == 'ubuntu'
163173
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
174+
- name: "Download artifact"
175+
if: ${{ inputs.download-name != '' && inputs.download-path != '' }}
176+
uses: actions/download-artifact@v4
177+
with:
178+
name: ${{ inputs.download-name }}
179+
path: ${{ inputs.download-path }}
164180
- name: Run Bazel
165181
run: ${{ inputs.run }}
166182
- name: Start SSH session

.github/workflows/ci-rbe.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,35 @@ jobs:
2929
upload-name: bazel-logs
3030
upload-path: bazel-logs
3131
run: ./scripts/github-actions/ci-build.sh
32+
retry-remote:
33+
name: Retry Failures on RBE
34+
needs: test
35+
if: always() && needs.test.result == 'failure' && github.repository_owner == 'seleniumhq' && startsWith(github.head_ref, 'renovate/') != true
36+
uses: ./.github/workflows/bazel.yml
37+
with:
38+
name: RBE Retries
39+
caching: false
40+
ruby-version: jruby-9.4.12.0
41+
download-name: bazel-logs
42+
download-path: bazel-logs
43+
upload-name: retry-remote-logs
44+
upload-path: bazel-logs
45+
run: |
46+
./go retry_failed_tests "${BAZEL_LOG_FILE}" true
47+
retry-local:
48+
name: Retry Failures on GHA
49+
needs: test
50+
if: always() && needs.test.result == 'failure' && github.repository_owner == 'seleniumhq' && startsWith(github.head_ref, 'renovate/') != true
51+
uses: ./.github/workflows/bazel.yml
52+
with:
53+
name: GHA Retries
54+
caching: false
55+
ruby-version: jruby-9.4.12.0
56+
browser: needs-xvfb
57+
java-version: 17
58+
download-name: bazel-logs
59+
download-path: bazel-logs
60+
upload-name: retry-local-logs
61+
upload-path: bazel-logs
62+
run: |
63+
./go retry_failed_tests "${BAZEL_LOG_FILE}" false

Rakefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,45 @@ end
274274
task test_py: [:py_prep_for_install_release, 'py:marionette_test']
275275
task build: %i[all firefox remote selenium tests]
276276

277+
desc 'Retry failed tests from a log file'
278+
task :retry_failed_tests, [:log_file, :rbe] do |_task, arguments|
279+
log_file = arguments[:log_file]
280+
281+
raise 'Error: Please provide a bazel log file containing test results.' if log_file.nil?
282+
raise "Error: Log file '#{log_file}' does not exist." unless File.exist?(log_file)
283+
284+
rbe = arguments[:rbe]
285+
failing_tests = []
286+
287+
File.readlines(log_file).reverse_each do |line|
288+
if line.match?(%r{//.+:.*FAILED})
289+
failing_tests << line.strip.split[0]
290+
elsif !failing_tests.empty? && line.match?(%r{//.+:.*PASSED})
291+
break
292+
end
293+
end
294+
295+
puts "Found #{failing_tests.size} failing tests; Retrying"
296+
297+
retry_args = arguments.extras + %w[--test_output=streamed --test_env DEBUG=true]
298+
retry_args << (rbe == 'true' ? '--config=remote' : '--pin_browsers')
299+
300+
retry_failures = false
301+
failing_tests.each do |failed_target|
302+
target_name = failed_target.split('/').last.tr(':', '_')
303+
target_name += rbe ? '_rbe' : '_gha'
304+
retry_logs = log_file.sub('.log', "_#{target_name}_retry.log")
305+
begin
306+
Bazel.execute('test', retry_args, failed_target, verbose: true, log_file: retry_logs)
307+
rescue StandardError => e
308+
retry_failures = true
309+
puts "Failed retry of #{failed_target}: #{e.message}"
310+
end
311+
end
312+
313+
raise 'Some tests failed during retry' if retry_failures
314+
end
315+
277316
desc 'Clean build artifacts.'
278317
task :clean do
279318
rm_rf 'build/'

0 commit comments

Comments
 (0)