Skip to content

Commit 800cf65

Browse files
authored
Use bazel CI to repeat tests and identify flakes (#820)
This adds workflows that can run tests repeatedly in bazel to gain information about flaky tests. Since bazel targets can be annotated as flaky, distinct workflows are created to execute flaky and non-flaky tests separately. Any failures of tests annotated as non-flaky are a signal that the offending test should be annotated as flaky. The results from repeated executions of flaky tests will generate flakiness statistics and may aid in diagnosing the root cause of flakiness. The repeated test workflows are scheduled to run twice a week. Signed-off-by: Steve Peters <scpeters@intrinsic.ai>
1 parent 4ed1c4c commit 800cf65

3 files changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Bazel repeat flaky tests
2+
on:
3+
schedule:
4+
# GitHub caches are purged after 7 days of inactivity, so
5+
# running twice a week helps protect the bazel cache
6+
# Run at 16:00 UTC, Monday and Friday
7+
- cron: '0 16 * * 1,5'
8+
9+
jobs:
10+
repeat-flaky-tests:
11+
uses: ./.github/workflows/bazel_repeat_tests.yml
12+
with:
13+
flaky: 1
14+
runs_per_test: 10
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Bazel repeat non-flaky tests
2+
on:
3+
schedule:
4+
# GitHub caches are purged after 7 days of inactivity, so
5+
# running twice a week helps protect the bazel cache
6+
# Run at 17:00 UTC, Monday and Friday
7+
- cron: '0 17 * * 1,5'
8+
9+
jobs:
10+
repeat-non-flaky-tests:
11+
uses: ./.github/workflows/bazel_repeat_tests.yml
12+
with:
13+
flaky: 0
14+
runs_per_test: 10
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Bazel repeat tests
2+
on:
3+
workflow_call:
4+
inputs: &shared_inputs
5+
flaky:
6+
description: "0 to execute non-flaky tests, 1 to execute flaky tests"
7+
default: 0
8+
required: false
9+
type: string
10+
runs_per_test:
11+
description: "Number of times to repeat each test"
12+
default: 10
13+
required: false
14+
type: string
15+
workflow_dispatch:
16+
inputs: *shared_inputs
17+
18+
jobs:
19+
repeat-tests:
20+
uses: bazel-contrib/.github/.github/workflows/bazel.yaml@v7.7.0
21+
with:
22+
folders: |
23+
[
24+
"."
25+
]
26+
exclude: |
27+
[
28+
{"folder": ".", "bzlmodEnabled": false}
29+
]
30+
exclude_windows: true
31+
bazel_test_command: |
32+
# Exit with success code 0 if no targets match the query
33+
# `grep -q '^' fails if the query output is empty
34+
bazel query "attr(flaky, ${{ inputs.flaky }}, tests(//...))" \
35+
| grep -q '^' || exit 0
36+
bazel test --runs_per_test=${{ inputs.runs_per_test }} \
37+
--test_output=errors \
38+
$(bazel query "attr(flaky, ${{ inputs.flaky }}, tests(//...))")

0 commit comments

Comments
 (0)