Skip to content

Compose flaky attribute with --flaky_test_attempts#13

Open
alexeagle wants to merge 1 commit into
8.7.0-figmafrom
aeagle/flaky-retries-attribute
Open

Compose flaky attribute with --flaky_test_attempts#13
alexeagle wants to merge 1 commit into
8.7.0-figmafrom
aeagle/flaky-retries-attribute

Conversation

@alexeagle

@alexeagle alexeagle commented Jul 1, 2026

Copy link
Copy Markdown

Summary

Bazel's flaky BUILD attribute and --flaky_test_attempts flag are disconnected: a global numeric flag applies the same retry count to every target (ignoring flaky=1), while the attribute only affects behavior when the flag is left at default and cannot express degrees of flakiness. This makes it hard to declare per-target retry policy in BUILD files at scale.

Upstream tracking issue: bazelbuild#30108

This change makes flaky an integer (additional retry count when the flag is default) and clarifies how it composes with --flaky_test_attempts.

Semantic changes

--flaky_test_attempts flaky Before After
default (unset) 0 / False 1 attempt 1 attempt
default 1 / True 3 attempts 2 attempts (1 + 1)
default 2 invalid (analysis error) 3 attempts (1 + 2)
default N invalid 1 + N attempts
numeric (e.g. 3) 0 3 attempts 3 attempts
numeric (e.g. 3) 1 3 attempts 3 attempts (attribute ignored)
numeric (e.g. 3) 2 3 attempts 3 attempts (attribute ignored)

flaky=True / flaky=False continue to work (True → 1, False → 0).

Breaking changes / migration

Use case Impact Migration
Targets with flaky=1 relying on 3 attempts under default flag Now get 2 attempts Set flaky=2 to restore 3 attempts
CI using --flaky_test_attempts=N expecting only flaky=1 targets to retry Unchanged
Per-target retry counts scattered across a monorepo Previously required long regex@N lists on the flag Set flaky=N per target when flag is default
flaky=2 or higher in BUILD files Previously failed analysis Now valid

Test plan

  • TestStrategyTest — flag override vs default composition
  • TestActionBuilderTestflaky=True, integer values, negative rejection
  • TypeTestFLAKY_TEST_RETRIES conversion and tagging

…t_attempts.

The flaky BUILD attribute now declares additional attempts when the flag is
default, while a numeric --flaky_test_attempts value overrides total attempts
for all matching targets including deterministic tests.
alexeagle added a commit to alexeagle/buildtools that referenced this pull request Jul 2, 2026
Document timeout, flaky, and shard_count as execution-reflecting attrs;
add shard_count recommender (future), integer flaky semantics from figma/bazel#13,
and attr-policy maxValue for shard_count after figma/bazel#12.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant