Skip to content

[ci] Skip doc example tests by default; add a docs-example-test opt-in that runs only the changed files' tests - #66806

Merged
elliot-barn merged 4 commits into
masterfrom
doc-1704-docs-example-test-optin
Oct 13, 2026
Merged

elliot-barn merged 4 commits into
masterfrom
doc-1704-docs-example-test-optin

Conversation

@dstrodtman

@dstrodtman dstrodtman commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Description

Doc-side edits no longer start a library's docs example tests. A new docs-example-test label opts a PR back in, and it runs only the tests that name a changed doc file directly. It never falls back to a library's whole docs example suite and never runs GPU tests. This replaces the docs-go label, which skipped the same steps by request and needed a scope guard to stay safe.

What changes by default

Doc assets under doc/source/ (.py, .ipynb, .yaml) and doc/external/ stop emitting <lib>_doc. They now emit a new doc_example tag, and only the label-gated opt-in step listens for it. Coverage for everything else is unchanged:

Change Before After, no label
Library code, such as python/ray/data/ The library's suites, including its docs example steps Unchanged
doc/BUILD.bazel, example BUILD.bazel files The owning library's docs example steps Unchanged, because they define test targets
doc/test_myst_doc.py (shared notebook runner) core: docs example tests Unchanged
Data doc_code/*.py All three Data docs example steps, including GPU No tests
LLM notebook under doc/source/llm/ Four llm suites, llm: wheel-aarch64 tests, both API checks No tests
Prose and images No tests No tests

Postmerge still runs every docs example suite in each library's own image.

doc/source/llm/ and doc/source/data/doc_code/working-with-llms/ move off the raw llm tag. Every LLM doc example test is tagged gpu, so these paths route to nothing rather than starting the llm library suites.

The opt-in

With the docs-example-test label, the new doc: docs example tests (opt-in) step in others.rayci.yml does the following:

  1. Runs //ci/ray_ci/doc:cmd_doc_example_targets, which diffs the PR against its base branch and maps each changed file under doc/source/ or doc/external/ to the Bazel test targets that reference it directly. A target matches when it names the file in srcs or data, or, for a notebook test, as the file in its --path argument. A file that a test reaches only through a filegroup doesn't count.
  2. Reports in the step log, instead of running, any GPU target and any library-wide doctest() target that takes every prose file of a library. Only Ray Data has per-file prose targets today (doctest_each), so Data prose is the only prose the opt-in can test file by file. Data .md and .rst therefore route to doc_example too.
  3. Runs the selected targets once per team, all in the existing doctestbuild image. That's a single Python 3.10 environment whose dependency set covers core, data, train, tune, rllib, and Serve. It doesn't use each library's own per-version images.

The opt-in runs on premerge only, by design. Apply both docs-example-test and go. Microcheck selects steps from an allow-list of step IDs: the steps where its high-impact and changed tests last ran, according to the test database. The pipeline settings set that list through RAYCI_SELECT, and a new step with no test history never appears on it. A smoke test confirmed this in microcheck build #55791. With the label on and five doc files changed, rayci selected doc_example, but microcheck ran lint only. That's the intended outcome: microcheck on a docs PR stays light, and the focused tests run when the PR goes to premerge.

tester.py gains --exact-targets, which stops microcheck-style narrowing of an explicit target list to high-impact and srcs-changed tests. Premerge doesn't narrow, so the flag matters only if microcheck ever runs this step. Without it, microcheck would silently drop notebook and prose targets, because they aren't srcs.

To preview what the label would run:

bazel run //ci/ray_ci/doc:cmd_doc_example_targets -- doc/source/data/doc_code/key_concepts.py

Retiring docs-go

This PR removes the label's if: guards from 12 steps, the lint: validate docs-go scope step, and ci/lint/validate_docs_go_scope.sh. Open PRs that carry the label keep working, since skipping is now the default. The contributor docs (ci.md, writing-code-snippets.md, doc/AGENTS.md) are updated in this PR. That includes correcting the ci.md claim that prose can't change tested code. Prose can carry doctests.

Known cost

rayci evaluates tags, not labels. A gated step that tags select still pulls its depends_on image builds into the build, even when Buildkite then drops the step. So an unlabeled PR that edits a doc asset or Data prose emits five cached Python 3.10 image jobs (oss-ci-base_test, oss-ci-base_build, doctestbuild, ray-core-build, ray-dashboard-build) and runs no tests. For a Data doc_code edit that's 10 jobs in total, down from 24. A follow-up rayci change, which drops label-gated steps before dependency marking, would make the unlabeled cost zero.

Related issues

Related to #64553, which introduced docs-go.

Additional information

Not a duplicate. I searched open PRs for docs-go, docs-example-test, and doc example test routing, and found none that change this behavior.

Tests run, all passing:

  • bazel test //ci/ray_ci/doc:test_doc_example_targets //ci/ray_ci:test_tester //ci/pipeline/...
  • rayci test-rules, built from rayci v0.48.0, the version .rayciversion pins. It covers all 182 expectations in .buildkite/test.rules.test.txt, which this PR updates. I confirmed it fails on a planted wrong expectation.
  • The selector against the real bazel query 'tests(//doc/...)' output (281 targets), one file per kind:
    • A Data doc_code file and data/working-with-tensors.md each map to their own target.
    • A notebook maps by --path.
    • A Serve page reports its library-wide doctest[serve] target.
    • An LLM notebook reports as GPU-only.
    • The shared notebook runner is ignored.
  • ci/ray_ci/doc/run_doc_example_tests.sh with a stubbed bazel, to check the per-team grouping and that a failure exit code propagates. Also run with no changed files, to check it exits 0 without starting a container.
  • rayci pipeline generation for simulated PR builds, old base against this branch, for the cases in the table above.

Not yet run: the opt-in step itself on Buildkite. Whether every library's selected doc tests pass in doctestbuild gets proven on the first labeled PR.

AI assistance: I wrote this PR with Claude Code (Claude Opus 5.5) and reviewed the changes myself.

🤖 Generated with Claude Code

@dstrodtman
dstrodtman requested review from a team as code owners October 7, 2026 13:42

@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 replaces the 'docs-go' label mechanism with a new 'docs-example-test' opt-in label. Instead of skipping tests, the new workflow runs only the specific doc example tests that directly consume the changed doc files, utilizing a single environment. The changes include removing the old scope-validation script, adding target selection logic in Python, introducing a new Buildkite opt-in step, and updating the relevant documentation. The review feedback highlights two important improvements: fetching the base branch in the test runner script to prevent git diff failures in shallow clones, and refining the build file exclusion check in the target selector to avoid matching files that merely end with 'BUILD'.

Comment thread ci/ray_ci/doc/run_doc_example_tests.sh Resolved
Comment thread ci/ray_ci/doc/doc_example_targets.py Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f7ae3d8. Configure here.

Comment thread ci/ray_ci/doc/doc_example_targets.py Resolved
Comment thread .buildkite/test.rules.txt Resolved
@dstrodtman

Copy link
Copy Markdown
Contributor Author

Smoke test on Buildkite. A throwaway draft, #66817 (now closed), stacked on this branch. It edited five doc files and carried both docs-example-test and go.

  • Premerge 74534: doc: docs example tests (opt-in) ran exactly the three expected targets in doctestbuild, and all three passed: //doc:source/data/doc_code/key_concepts, //doc:source/data/working-with-tensors, and, as team ml, //doc:source/tune/doc_code/key_concepts. The step log reported the Serve page as covered only by doctest[serve] and the LLM notebook as GPU-only. No library docs example suite ran. The build took 21.1 minutes of wall time, 11.7 of them in the opt-in step, most of that container setup.
  • Microcheck 55791: ran lint only, in 19.0 minutes. That's the expected premerge-only behavior.

dstrodtman and others added 4 commits October 13, 2026 09:09
A doc-side edit no longer starts a library's docs example tests. Doc
assets emit a new doc_example tag that only one label-gated opt-in step
listens for. With the docs-example-test label, that step runs only the
Bazel targets that name a changed doc file directly, never a library's
whole docs example suite and never GPU tests. It runs every team's
targets once, in the existing single-Python doctestbuild image, instead
of each library's per-version images.

- ci/ray_ci/doc/doc_example_targets.py maps changed files to targets.
- tester.py gains --exact-targets so microcheck doesn't narrow them.
- llm doc assets run nothing: every llm doc example test is GPU-only.
- Retire the docs-go label and its scope guard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
Update ci.md, writing-code-snippets.md, and doc/AGENTS.md for the new
default: doc asset edits run no docs example tests, and the
docs-example-test label runs only the tests that name a changed file.
Also corrects the ci.md claim that prose can't change tested code.

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

- run_doc_example_tests.sh fetches the PR's base branch and passes
  --base FETCH_HEAD, so the selector no longer depends on a local
  origin/<base> that a restricted-refspec clone may not have. A failed
  fetch fails the step instead of selecting nothing.
- The selector takes the step's --except-tags and reports matching
  targets as not run, so the log no longer says a post_wheel_build
  target is running when test_in_docker drops it.
- BUILD files match by exact basename, not suffix.
- ci.md says the label has no effect on a prose-only PR outside Ray
  Data, and lists the excluded-tag case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
Microcheck selects steps from a test-history allow-list that a new step never appears on, so the opt-in step needs the go label as well.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman force-pushed the doc-1704-docs-example-test-optin branch from 29386bf to 091d8bb Compare October 13, 2026 13:10
@elliot-barn
elliot-barn merged commit 2dba03d into master Oct 13, 2026
5 of 6 checks passed
@elliot-barn
elliot-barn deleted the doc-1704-docs-example-test-optin branch October 13, 2026 18:03
dstrodtman added a commit that referenced this pull request Oct 14, 2026
…66808)

## Why are these changes needed?

`doc/external/` held a vendored copy of the PyTorch [Hyperparameter
tuning with Ray
Tune](https://docs.pytorch.org/tutorials/beginner/hyperparameter_tuning_tutorial.html)
tutorial, plus `test_external_hashes`. That test only asserted the
copy's sha256 so that edits would flag drift from the PyTorch page. The
canonical tutorial lives in
[pytorch/tutorials](https://github.com/pytorch/tutorials/blob/main/beginner_source/hyperparameter_tuning_tutorial.py)
and has since been rewritten there, so the copy here no longer matches
it. Sphinx never rendered the copy because it sits outside
`doc/source/`, so it has no docs.ray.io URL and needs no redirect. It's
the last item in the tree with its own one-off CI routing.

This PR removes the following:

- The `doc/external/` directory.
- The `test_external_hashes` target in `doc/BUILD.bazel`, along with the
`ci_require` load that only that target used. Buildifier drops the load.
- The `doc/external/` routing in `.buildkite/test.rules.txt` and its
expectations in `.buildkite/test.rules.test.txt`.
- The two `doc/external/` pre-commit excludes.
- The `doc/external/` entry in `DOC_EXAMPLE_PREFIXES` in
`ci/ray_ci/doc/doc_example_targets.py`.

**Stacked on #66806**, which rewrites the same `doc/external/` routing
lines. Merge that first. This PR's base is its branch.

## Related issue number

None.

## Duplicate check

`gh pr list --state open --search "doc/external"` returns only #66806,
which this PR stacks on. No other open PR removes this directory.

## Tests run

- `rayci -buildkite-dir .buildkite test-rules`: all 180 expectations
pass. As a negative control, an appended wrong expectation fails, so the
check is live.
- `pytest ci/ray_ci/doc/test_doc_example_targets.py`: 8 passed.
- `pre-commit run` on the changed files: passes, including buildifier
and buildifier-lint.
- `git grep -n "doc/external\|test_external_hashes"` returns nothing.

AI assistance (Claude Code) was used to prepare this change. I reviewed
every changed line.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
dstrodtman added a commit that referenced this pull request Oct 14, 2026
…ocstring examples, piloted on Ray Data (#66814)

> [!NOTE]
> **Draft proposal.** This PR is for agreeing on the direction before
the label extends past Ray Data. It's rebased on `master` now that
#66806 has merged.

## Why are these changes needed?

A docstring edit in `python/ray/<lib>/` routes like a code change, so it
runs every test suite that library's tag selects, and the `go` premerge
runs all of them before merge. Converting docstring examples from
Sphinx-only `.. testcode::` to stock `>>>` doctests produces a steady
stream of these PRs. On master, 398 `testcode` blocks in 147 files
remain.

Measured on seven recent docstring-only PRs, one premerge build each:

| PR | Library | Premerge runner-hours |
|---|---|---|
| #65901 | core | 39.6 |
| #66745 | core | 43.7 |
| #66749 | rllib | 15.3 |
| #66747 | train | 10.6 |
| #66746 | data | 10.3 |
| #66748 | tune | 8.6 |
| #66604 | data | 8.2 |

Runner-hours are summed job durations from the Buildkite API, so
queueing doesn't count.

None of those suites can fail on a docstring-only change, except through
a test that asserts on `__doc__` text. What a docstring edit can break
is the example code in the docstrings it touched.

## What this PR does

It adds a `docstring-only` PR label, piloted on Ray Data only. Under the
label, a Data PR runs the `>>>` examples in the docstrings of only the
modules it changed, plus the API checks and lint, instead of every Data
test suite.

- **The guard.** `lint: validate docstring-only scope` runs whenever the
label is present, is tagged `always`, and can't be turned off.
`ci/ray_ci/doc/check_docstring_only.py` parses each changed file at the
merge-base and at `HEAD` with Python's `ast`, removes the docstring from
the module and from every class and function, and compares `ast.dump` of
the two trees. It fails on any difference, on any file that isn't `.py`,
on any added, deleted, renamed, copied, or type-changed file, and on any
parse error. Comments aren't in the AST, so comment edits pass. A string
later in a body and a `__doc__` assignment both count as code.
- **What the label skips.** The 10 Data test steps in `data.rayci.yml`
that run on premerge get `if: '!(build.pull_request.labels includes
"docstring-only")'`, the same pattern `docs-go` used. `pyrefly type
check` isn't gated.
- **What it runs instead.** A new `data: docstring examples` step, gated
on the label, runs `ci/ray_ci/doc/run_docstring_examples.sh`:
1. It lists the `.py` files the PR modified under `python/ray/data/`,
excluding `tests/` and `examples/`, and exits if there are none.
1. It builds the Data CI image with the PR's Ray, using `test_in_docker
--build-only`, the same Ray install every Data test step uses.
1. In that image, it runs `ci/ray_ci/doc/run_docstring_examples.py` on
only those files.

The runner imports each module and extracts the `>>>` examples from
every docstring in the file. It runs each docstring's examples in order,
in a copy of the module's globals, as an interactive session would. An
example that shows output must print it, so those examples are unit
tests rather than smoke tests. Matching follows Ray's doctest targets:
`...` matches any text (pytest's default ELLIPSIS flag), and per-example
directives apply. An example that shows no output only has to run
without raising, and one that shows a traceback must raise a matching
exception. The standard library's doctest module supplies the parser and
the output comparison, with no doctest runner, pytest collection, or
Bazel doctest target. Examples still written as `.. testcode::` aren't
run.
- **Docs.** `doc/source/ray-contribute/ci.md` gets a "Docstring-only
changes" section.

### Design choices for review

- **Changed files only.** The unit is the changed module, not the
library. A PR that edits `aggregate.py` runs only `aggregate.py`'s
examples.
- **Output is checked where it's shown.** A stale result in an example
fails the step, the same as in Ray's doctest targets. Examples that show
nothing are smoke tests.
- **Data only.** Extending the label means an `if:` on most library test
steps in every per-library `*.rayci.yml`, which each library team owns.
This draft shows the shape on one library first. `ml: data integration
tests` also carries the `data` tag but lives in `ml.rayci.yml`, so it
still runs under the label.
- **Some image builds still run.** The label gates test steps, not the
`wanda` image builds they depend on. rayci selects steps by tag and
pulls in every image a selected step depends on, and it doesn't evaluate
`if:`. `wanda` steps can't take an `if:` either. Under the label, a Data
docstring PR still emits 5 image jobs that feed only the gated steps:
`datamongobuild-py3.10`, `datatfdsbuild-py3.12`, `docgpubuild-py3.10`,
`docgpubuild-py3.12`, and `oss-ci-base_gpu-py3.12`. On premerge builds
[74154](https://buildkite.com/ray-project/premerge/builds/74154) and
[74459](https://buildkite.com/ray-project/premerge/builds/74459), those
5 jobs took 4.1 and 10.1 minutes. Each takes about 50 seconds as a cache
hit, and `docgpubuild-py3.10` took 401 seconds on a miss. That's small
next to the 6.9 runner-hours the gated steps took. Dropping them needs a
rayci change that evaluates label gates before it marks dependencies.
The other 20 image jobs in the build feed a step the label keeps, or
rayci selects them on their own.
- **Known residual risk.** A test that asserts on `__doc__` text, or on
line numbers a docstring edit shifts, isn't visible to the guard. The
postmerge build is the backstop.

## Related issue number

None. Duplicate check: I searched open PRs for `docstring-only` and
`docstring only label`, and found no PR that adds a label or guard for
docstring-only changes.

## Tests run

- `pytest ci/ray_ci/doc/test_check_docstring_only.py
ci/ray_ci/doc/test_run_docstring_examples.py`: 29 passed. The runner's
tests cover examples that use module globals, a raising example that
fails with its file, line, and docstring name, wrong output that fails
with a diff, matching output with ELLIPSIS and a directive, expected and
mismatched exceptions, `+SKIP` and `+SKIP_EXAMPLE`, and no names leaking
between docstrings.
- The guard against real branches: it passes the three open docstring
PRs, #66745 (2 files), #66746 (1 file), and #66812 (5 files). It fails
#66806's branch and names the two `.py` files with code changes and the
three Markdown files.
- The runner against a Ray nightly (`43b706d`) on real branches. On
#66812's five files, 7 docstrings ran and passed in 24 seconds. On
#66746's `aggregate.py`, 18 docstrings ran and passed in 12 seconds.
With output checking, on six `master` Data modules that already use
`>>>` (`dataset.py`, `expressions.py`, `iterator.py`, `datatype.py`, and
two preprocessors), 113 of 118 docstrings passed in 36 seconds. The 5
failures are packages missing from the local environment (`torch`,
`tensorflow`, `crc32c`), not output mismatches.
- `--list-changed` in a scratch clone whose only change is a docstring
edit to `python/ray/data/aggregate.py` lists exactly that file.
- Pipeline generation with `rayci` built at `.rayciversion` (0.48.0),
for that simulated PR, on the premerge and microcheck pipeline IDs. Both
generate, with selected tags `always data lint`. Evaluating the
generated `if:` conditions shows the following:
- **Without the label:** the Data test steps match the real premerge
build of #66746
([74459](https://buildkite.com/ray-project/premerge/builds/74459)).
- **With `docstring-only`:** the 10 gated steps drop out, and `data:
docstring examples` and `lint: validate docstring-only scope` are added.
The API checks, `pyrefly`, `test-rules`, and `ml: data integration
tests` still run.
- The image jobs the label leaves running: I reran the same simulation
with the 10 gated steps removed from the YAML, which is what a rayci
change that evaluates label gates before marking dependencies would
emit. The build goes from 25 image jobs to 20. The 5 removed are listed
under "Some image builds still run." If the two `continuous-build` Data
steps are also dropped, `datalbuild-py3.12` goes too, for 6.
- Estimated saving on build 74459: the 10 gated steps took 6.9 of its
10.3 runner-hours. The new step adds one Data image build and a run of
seconds per changed file.
- `pre-commit` passes on the changed files.

Not yet run: the label on a real Buildkite build, including the
`--build-only` and `docker run` part of the new step. Nothing in the
repo evaluates Buildkite `if:` conditions, so the first labeled Data
docstring PR is the confirming check.

**AI assistance.** This change was drafted with Claude Code. I reviewed
every line and ran the tests above.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
edoakes pushed a commit that referenced this pull request Oct 15, 2026
…xample-test opt-in can run them (#66809)

## Why are these changes needed?

With #66806, the `docs-example-test` label runs only per-file doc test
targets. Prose outside Ray Data sits in one `doctest()` target per
library, so the label can't run a changed Core, RLlib, Serve, or Train
page. This PR splits those targets into per-file targets. Pages with
nothing runnable drop out instead of becoming targets that pass without
testing anything, because `bazel/pytest_wrapper.py` turns an empty
collection into a pass.

### Decision for CI reviewers: what the routing costs

Splitting the targets also means deciding how prose reaches the opt-in
step. This PR routes all prose under `doc/source/` to `doc_example`. The
alternative is a rule that names each page with a per-file target. That
costs no compute, but it moves every page rename, move, or page gaining
or losing a runnable block into `test.rules.txt`, which only
`@ray-project/ray-ci` can approve. With #67003 that list grows to about
70 pages, during a docs rename campaign. Routing all prose keeps those
edits in `doc/BUILD.bazel`, under the `/doc/` CODEOWNERS rule.

**The cost.** rayci marks a selected step's `depends_on` chain before
Buildkite evaluates the step's `if:` label guard, and wanda image steps
can't take `if:`. So every build of a PR that touches prose under
`doc/source/` schedules the opt-in step's 5 Python 3.10 image jobs,
`oss-ci-base_test`, `oss-ci-base_build`, `doctestbuild`,
`ray-core-build`, and `ray-dashboard-build`, even though the step itself
is dropped. They're expected to be cache hits. The count comes from
simulating PR builds with rayci v0.48.0. Master already pays this today
for Ray Data prose, which this rule replaces.

**How often.** Of the 403 PRs merged from 2026-09-16 to 2026-10-13, 111
touched prose under `doc/source/`, about 28 a week. For most of them the
images already build for other reasons. 34, about 8 a week, changed
nothing but `doc/` prose and images, so the 5 jobs are pure added cost
on every build of those PRs.

Any of these answers leaves something worth merging:

| If CI reviewers prefer | What merges | After that |
|---|---|---|
| Accepting the 5 cached image jobs | This PR as written | Nothing.
Routing doesn't change again. |
| Fixing it in rayci, so that a label-gated step that's dropped doesn't
pull in its dependencies | This PR as written | After the rayci release,
the opt-in step gets the `always` tag and the `doc_example` prose rule
is deleted. |
| Neither | The per-page list instead, from the
`doc-1708-per-file-doctests-literal` branch | Page renames and moves
keep editing `test.rules.txt`. |

The `doc-1708-per-file-doctests-literal` branch is this PR's previous
head, so switching back is a reset, not a rewrite.

### Which pages get a target

I ran real pytest collection for every prose page under the five library
directories, with the pinned `pytest==7.4.4` and the
`ray-project/pytest-sphinx` fork, as the `doctest` macro does:

| Library | Prose files | Collect a test | Per-file targets after
existing excludes |
|---|---|---|---|
| Core | 102 | 18 | 16 |
| RLlib | 47 | 19 | 19 |
| Serve | 96 | 2 | 1 |
| Train | 61 | 10 | 7, plus the 2 existing GPU pages |
| Tune | 60 | 0 | 0 |

A page whose only blocks are `:skipif: True` collects nothing. That's
why Train has 10 pages with `testcode` blocks that never run. An rST `..
testcode::` directive inside a MyST `.md` page isn't collected either;
`core/internals/streaming-generator.md` and one block in
`train/user-guides/experiment-tracking.md` hit this.

### Changes

- `doc/BUILD.bazel`: `doctest[core]`, `[rllib]`, `[serve]`, and
`[train]` become `doctest_each()` over an explicit page list. Existing
excludes, `env` settings, RLlib's `cartpole-v1_large` data dependency,
and the GPU targets are unchanged. `doctest[tune]` collected nothing and
is removed.
- `.buildkite/test.rules.txt`: the Ray Data prose rule,
`doc/source/data/*.md` and `*.rst`, becomes `doc/source/*.md` and
`*.rst`, still after the API reference rules and ahead of the prose skip
rule. Prose that Sphinx never renders as a page, under `doc/source/_*`
and `doc/source/templates/`, gets a skip rule ahead of it. API reference
pages match the `doc_api` directory rule first and emit only `doc_api`,
so the label doesn't run doctests on RLlib's two `api/` pages. The
post-merge build still does. The rules file names no individual page, so
renaming or removing a page never needs a `.buildkite/` edit.
- New lint `doc_prose_doctest_targets`
(`doc/test_prose_doctest_targets.py`), in the `lint-small-prose` matrix
so prose-only PRs run it. With explicit lists, a runnable block added to
an unlisted page would otherwise run nowhere, not even post-merge. The
check fails when a library page has a runnable example but no target, or
when a listed page has nothing runnable. It's stdlib-only because the
forge image has no pytest. On the current tree its rule matches real
pytest-sphinx collection exactly, 49 of 49 pages.
- `doc/source/ray-contribute/ci.md` and `doc/AGENTS.md`: the label now
runs Core, RLlib, Serve, and Train pages, not only Ray Data, and `ci.md`
states the image-job cost of a prose change.
- `doc/source/ray-contribute/ci.md` also lists the lint steps that run
on a prose-only change. The page named three, and two of them, the
README check and the Vale style check, no longer run on prose. It now
lists the four that do, including the new check.

### Target renames

The four library-wide targets become per-file targets named after their
pages, for example `//doc:source/core/actors/named-actors`. The
postmerge `//doc/...` doctest pass picks them up automatically.
Flaky-test history and release-blocker auto-open are keyed by target
name, so the old names' history doesn't carry over. Nothing in this repo
refers to the old names except synthetic fixtures in
`ci/ray_ci/doc/test_doc_example_targets.py`.

## Duplicate check

No open PR covers this. Searches for `doctest_each`, "per-file doctest",
"doctest targets doc/BUILD.bazel", and `doctest[tune]` return only
#66806, which this PR builds on.

## Testing

- `rayci test-rules` (rayci v0.48.0, the version in `.rayciversion`,
built from source): all 198 cases in `test.rules.test.txt` and
`always.rules.test.txt` pass. A deliberately wrong expectation fails, so
the check is real. New cases cover a library page without a per-file
target, the root index, a non-library page, a KubeRay page, and the
three skipped internal prose paths.
- The in-repo reference evaluator
(`ci/pipeline/determine_tests_to_run.py`) gives the expected tags for a
sample of library and KubeRay prose, API pages, internal prose, package
and repo-root READMEs, images, a `doc_code` script, and `conf.py`. Only
the prose emits `doc_example`. API pages emit only `doc_api`. `pytest
ci/pipeline/test_doc_api_rules_sync.py` and `pytest
ci/ray_ci/doc/test_doc_example_targets.py` pass.
- `bazel query 'attr(tags, "doctest", tests(//doc:all))'` lists all 43
new per-file targets.
- `bazel run //ci/ray_ci/doc:cmd_doc_example_targets -- <pages>` selects
the matching per-file target for a Core, Train, RLlib `api/`, and Serve
page, and reports "No test names this file" for an excluded page.
- `./ci/lint/lint.sh doc_prose_doctest_targets` passes. Each failure
mode fires when the tree is edited to trigger it: an unlisted runnable
page, a page dropped from BUILD, and a listed page with nothing
runnable.
- I ran each Core page locally on Python 3.10 with the nightly wheel
(macOS arm64). 11 of 16 pass. The other 5 fail for local reasons:
missing `torch`, missing `CUDA_VISIBLE_DEVICES` on macOS, and the
nightly wheel's usage-stats banner showing up in `testoutput`. The
banner pages fail the same way when run in one shared session, so the
split doesn't cause them.
- Not run locally: the RLlib, Serve, and Train pages, and anything in
the `doctestbuild` image. A `docs-example-test` labeled run on this PR
is the check for those.

AI assistance (Claude Code) was used to write this change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
dstrodtman added a commit that referenced this pull request Oct 29, 2026
…per-page doctest targets (#67204)

## Why are these changes needed?

Several contributor-facing CI docs fell behind the docs CI changes that
merged this month.

- **`ci.md`, "Docstring-only changes."** The section still described
`data: docstring examples` and said the examples step covers Ray Data
only. Since #67083, `doc: docstring examples` in `others.rayci.yml` runs
the changed modules' `>>>` examples for every library that a CPU
`doctest()` target covers. It runs in the light `docstringbuild` image,
which has no torch or TensorFlow, and reports examples that need those
libraries as skipped, by name. Since #67341, the label also skips every
library's test suites through `.buildkite/docs.labels.yaml`, so the
section now says that, and recommends an `@rtd-build` commit line
alongside the label so Read the Docs builds the API reference the
docstrings render into.
- **`ci.md`, broken steps and post-merge builds.** A new "Why some steps
show as broken" section says that on a PR the label rules remove the
steps a label skips, so they don't appear at all, that the scope guard
is the one label-gated step still shown as `broken` on an unlabeled PR,
and that scheduled post-merge builds don't apply label rules, so all
three label-gated steps show as `broken` there. The page also
distinguishes the two kinds of post-merge build on `master`. The build
each merge starts doesn't run the docs example tests, and the scheduled
builds that the release automation triggers run the full suite, so the
page now says "scheduled post-merge builds" wherever it means those.
- **`writing-code-snippets.md`, "How to test examples with GPUs."** It
told readers to open `doc/BUILD` and exclude their page from a
`glob(["source/**/*.rst"])` catch-all target. Neither exists: #66809 and
#67003 replaced library-wide prose targets with per-page
`doctest_each()` lists. The steps now show both cases: a doc page moves
from its library's `doctest_each` list to the GPU `doctest` rule, and a
docstring module moves from the CPU glob's `exclude` to the GPU rule. A
new short section says how a page with its first runnable example joins
CI, which the `doc_prose_doctest_targets` lint enforces.
- **`docs.md` and `writing-style.md`.** Both said CI enforces Vale. The
`documentation_style` check is out of the `lint.rayci.yml` matrix for
now, so they say the check is temporarily off.
- **`ci/ray_ci/doc/README.md`.** It described only the doc build and the
API guard. It now covers the scripts behind the `docs-example-test` and
`docstring-only` labels and `linkcheck_report.py`.
- **`doc/README.md`.** It said CI doesn't run linkcheck. The postmerge
`doc: linkcheck` step does, as a soft-fail step that never blocks.

Docs-only. No CI or behavior changes.

## Related issue number

None. Follows #66806, #66809, #66814, #67003, and #67083.

## Duplicate check

Not a duplicate. `gh pr list --repo ray-project/ray --state open`
searches for `"ci.md docstring"`, `"writing-code-snippets"`, and
`"ci/ray_ci/doc README"` return two other open PRs that touch these
files, both mine, neither covering these sections:

- #65868 adds a "How to test a Ray Serve deployment" section to
`writing-code-snippets.md` at the same insertion point as this PR's new
section, so whichever merges second needs a trivial rebase.
- #66884 updates the LLM doc paths in `ci.md`, not the docstring-only
section.

## Testing

- Every changed claim was checked against `master` at 3ae1b8b:
`.buildkite/others.rayci.yml`, `.buildkite/data.rayci.yml`,
`.buildkite/lint.rayci.yml`, `.buildkite/doc.rayci.yml`,
`doc/BUILD.bazel`, `python/ray/train/BUILD.bazel` (the GPU rule examples
are copied from the real `doctest[train-gpu]` and
`py_doctest[train-gpu]` rules), `doc/test_prose_doctest_targets.py`, and
the scripts under `ci/ray_ci/doc/`.
- `pre-commit run` on the changed files passes, including the
master-link check.
- Not run: a Sphinx build. The Read the Docs preview on this PR is the
check.

AI assistance (Claude Code) was used to find the stale text and draft
the changes. I reviewed every changed line.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Issues that should be addressed in Ray Core devprod docs An issue or change related to documentation go add ONLY when ready to merge, run all tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants