Skip to content

[raycicmd] add skip-form label rules; reject before marking deps - #511

Merged
elliot-barn merged 3 commits into
reef-209-keep-only-label-rulesfrom
reef-209-skip-label-rules
Oct 27, 2026
Merged

elliot-barn merged 3 commits into
reef-209-keep-only-label-rulesfrom
reef-209-skip-label-rules

Conversation

@dstrodtman

@dstrodtman dstrodtman commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #510. Review that first; this PR's diff is against its branch.

Why

#510 adds keep-only label rules, which narrow selection without rejecting anything. Some steps instead need to be skipped by label: an opt-in step that should run only when a label is present, such as Ray's doc: docs example tests (opt-in) gated on docs-example-test. Today that gate is an if: that Buildkite evaluates after upload, so an unlabeled PR still builds the step's images.

What changes

Two skip forms for label rules:

- label: docs-example-test
  skip_tags_unless_present: [doc_example_optin]
- label: some-label
  skip_tags_when_present: [some_tag]

They add tags to the filter's skip set by the label's state, so they behave exactly like configured skip_tags: a skipped step is rejected, and so is every step that depends on it. Matching skip_tags was deliberate, so a label-skipped step and a config-skipped step behave the same. Buildkite's docs say a step whose if: is false becomes broken, but they don't say what happens to steps that depend on it, so this may differ from today's if: gates when a step depends on a gated one. No step in Ray does today.

Label rules apply only to pull request builds. When BUILDKITE_PULL_REQUEST is false, rayci doesn't apply them and logs not a pull request build: label rules not applied, so non-PR builds select steps as they did before label rules existed. This keeps gates such as Ray's continuous-build, which run when the label is present or on postmerge, expressible as a rule. A label-only gate such as docs-example-test keeps its if: to stay off postmerge.

convertGroups rejects before it marks dependencies. Writing the cascade test exposed a gap that already affects configured skip_tags. When a selected step depends on a skipped step, markDeps ran first and marked the skipped step's own dependencies through the selected one. rejectDeps then rejected both steps but left those dependencies marked, so a skipped step's images still built. Now rejectDeps runs first, rejected hits are dropped, and markDeps runs from the hits that remain. Because a step that depends on a rejected step is itself rejected, the remaining hits can't reach a rejected step, so the only nodes this change unmarks are ones reachable solely through rejected steps.

Testing

  • Unit tests for parsing the skip forms and for convertGroups under each form with the label present and absent. The tests cover the image only the skipped step needs being dropped, a shared image staying, and a dependent of the skipped step being rejected. Without the reorder, the dropped-image case fails.
  • An end-to-end makePipeline test covers a skip_tags_unless_present rule on PR builds with and without the label, and on non-PR builds, where neither skip nor keep-only rules apply. Without the PR-only check, the non-PR cases fail.
  • go test ./..., go fmt, pre-commit, and rayci-lint go-filelength and go-coverage pass. raycicmd coverage is 90.6%.
  • Simulated Ray premerge with a Linux build of this branch against ray-project/ray master at 8fdacd39fd4:
    • Without any label rule in effect, the emitted pipelines for a doc prose PR, a Ray Data PR, and a core PR are identical to rayci v0.50.0, so the reorder changes no current Ray build.
    • With a probe docs-example-test rule as above, and the opt-in step tagged doc_example_optin, an unlabeled doc prose PR emits 5 steps instead of 11. The opt-in step and the 5 image jobs only it needs drop. With the label, all 11 are emitted.

Questions for review

  • Should a skip-form rejection cascade to dependents, as this PR does to match skip_tags?
  • The reorder changes existing skip_tags behavior in the case above. Would you rather land it as its own PR first?

🤖 Generated with Claude Code

Label rules gain skip_tags_unless_present and skip_tags_when_present.
They add tags to the filter's skip set by the label's state, so a
skipped step is rejected and steps that depend on it are rejected too,
the same as configured skip_tags.

convertGroups now runs rejectDeps before markDeps and drops rejected
hits first. Marking first pulled a rejected step's own dependencies,
such as its images, into the pipeline through a selected step that
depends on it, even though both steps were then rejected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces new label rules skip_tags_unless_present and skip_tags_when_present to allow skipping pipeline steps based on the presence or absence of specific labels. It also refactors the step conversion logic in converter.go to reject dependencies first, ensuring that a step depending on a rejected step is also rejected without pulling in its dependencies. Unit tests have been added to verify these new features. There are no review comments, so I have no feedback to provide.

@elliot-barn

Copy link
Copy Markdown
Collaborator

Suggestion for the follow-up that removes Ray's if: gates: could label rules apply only on PR builds? When BUILDKITE_PULL_REQUEST is false, applyLabelRules would do nothing at all.

Why: the continuous-build gates in Ray (8 across core.rayci.yml and data.rayci.yml) are written like this:

if: build.pull_request.labels includes "continuous-build" || pipeline.id == "0189e759-8c96-4302-b6b5-b4274406bf89" || pipeline.id == "018f4f1e-1b73-4906-9802-92422e3badaa"

They run when the label is present or on postmerge. With this PR as written, skip_tags_unless_present sees no labels on postmerge and skips them, so they'd stop running there. If label rules apply only to PR builds, a continuous-build rule gives exactly today's behavior, and labels stay a PR-only feature on non-PR builds.

One thing that changes: docs-example-test is the opposite case. Its gate is label-only (if: build.pull_request.labels includes "docs-example-test"), so today the opt-in step never runs on postmerge. With PR-only rules, postmerge wouldn't skip it, and it would run whenever postmerge selects its tags. Ray could keep that one step's if: or exclude it on postmerge some other way. The step's own comment says the per-library docs example steps already cover postmerge.

Happy for this to be a small change here or a follow-up before Ray adopts the rules.

A non-PR build has no labels, so a skip_tags_unless_present rule skipped
its steps on postmerge. That breaks a gate such as Ray's continuous-build,
which runs when the label is present or on postmerge. Label rules now
apply only when BUILDKITE_PULL_REQUEST names a PR, so non-PR builds
select steps as they did before label rules existed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman

dstrodtman commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Done in 7f4fb94: label rules now apply only when BUILDKITE_PULL_REQUEST names a PR, with a log line on non-PR builds. ray-project/ray#67341 already keeps the if: on both label-gated steps, so postmerge stays as it is today and unlabeled PRs still drop the opt-in images. Are you OK keeping skip cascading to dependent steps and the reorder in this PR?

@elliot-barn elliot-barn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, 7f4fb94 looks good. Yes to both: cascading matches skip_tags, which is what I'd expect, and the reorder is a real fix with no change to Ray's current output, so fine to keep it here.

@elliot-barn
elliot-barn merged commit dd3b65f into reef-209-keep-only-label-rules Oct 27, 2026
3 checks passed
@elliot-barn
elliot-barn deleted the reef-209-skip-label-rules branch October 27, 2026 21:02
elliot-barn pushed a commit to ray-project/ray that referenced this pull request Oct 28, 2026
…label rules (#67341)

> [!IMPORTANT]
> Draft until rayci ships label rules
([rayci#510](ray-project/rayci#510),
[rayci#511](ray-project/rayci#511)) and this PR
bumps `.rayciversion` to that release. Don't merge it before then:
today's rayci ignores `*.labels.yaml`, so removing the per-step gates
would stop the `docstring-only` label from skipping Ray Data's suites.

## Why are these changes needed?

The `docstring-only` and `docs-example-test` labels gate steps with
Buildkite `if:` conditions, which Buildkite evaluates after rayci has
selected the steps and marked their dependencies. That causes two
problems:

- **Images build for steps that don't run.** An unlabeled prose PR
builds the 5 images only the opt-in step needs. An unlabeled Python PR
builds `docstringbuild` for `doc: docstring examples`.
- **`docstring-only` covers only Ray Data.** Each skipped step needs its
own negated `if:`. Extending the label means a gate on nearly every
premerge test step, and a new step that forgets one silently runs under
the label.

rayci#510 and #511 let PR labels adjust step selection before dependency
marking, through rules in `.buildkite/*.labels.yaml`. This PR adopts
them.

## What changes

- **Adds `.buildkite/docs.labels.yaml`** with the following rules:
- `docstring-only` keeps only steps tagged `always`, `lint`, `doc_api`,
or `docstring_examples`. That's the same set a labeled Data PR runs
today (`doc/source/ray-contribute/ci.md`): the docstring examples step,
the two API surface checks, lint, and the scope guard, which is tagged
`always`. It now applies to every library, not just Ray Data. Without
the label, it skips `doc: docstring examples`.
  - `docs-example-test` skips the opt-in step without the label.
- **Tags the two steps** in `others.rayci.yml`: `docstring_examples` on
`doc: docstring examples`, and `doc_example_optin` on `doc: docs example
tests (opt-in)`.
- **Removes the 10 negated `docstring-only` gates** from
`data.rayci.yml`.
- **Keeps the positive `if:` gates** on the examples step, the opt-in
step, and the scope guard. They're redundant now, but they show a reader
of the step why it's label-gated.

## Behavior change to review

Under `docstring-only`, examples that need torch or TensorFlow are
reported as skipped by the light examples image, and their library's
`doctest()` target is skipped with the rest of the suites. Today that's
true only for Ray Data. With this PR it's true for every library, so
those examples get no premerge coverage on a labeled PR. `ml: data
integration tests`, which #67237 gates with its own `if:`, is also
covered by the keep-only rule, so that gate becomes redundant.

## Duplicate check

No open PR adopts rayci label rules, which don't exist yet in a release.
Related open PRs: #67237 adds a `docstring-only` gate to `ml: data
integration tests`, and #67204 rewrites the `docstring-only` section of
`ci.md`. The `ci.md` update for this change (the label covering every
library) waits until #67204 lands, to avoid conflicting with it.

## Testing

I generated the premerge pipeline locally with a Linux build of rayci
#510 and #511 against this branch. Each row simulates a PR that changes
one file:

| Simulated PR | rayci v0.50.0 on master | This branch, unlabeled | This
branch, labeled |
|---|---|---|---|
| Doc prose (`doc/source/data/aggregating-data.md`) | 11 steps | 5
steps: the opt-in step and the 5 images only it needs drop | 11 steps
with `docs-example-test` |
| Ray Data docstring (`python/ray/data/dataset.py`) | 51 steps | 49
steps: `doc: docstring examples` and `docstringbuild` drop | 19 steps
with `docstring-only` |
| Core docstring (`python/ray/actor.py`) | 165 steps | 163 steps: the
same 2 drop | 19 steps with `docstring-only` |

The 19 labeled steps are test-rules, the lint steps, the scope guard,
both API surface checks, `doc: docstring examples`, and their images.
Apart from the two dropped steps, unlabeled pipelines are identical to
v0.50.0 on master. `pre-commit run` on the changed files passes. Once a
rayci release exists, the `.rayciversion` bump goes here and premerge
runs with and without each label.

This PR was prepared with AI assistance (Claude Code). It stays in draft
until a human review of every changed line and a premerge run on the
release.

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants