Repository navigation
[doc][ci] Skip RTD builds for PRs that don't touch doc sources - #63431
elliot-barn merged 2 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a build optimization for ReadTheDocs by adding a post_checkout job that skips Sphinx builds if no documentation-related files are modified. Feedback was provided to include python/setup.py in the list of monitored files, as it is required to correctly determine the project version during the documentation build process.
| if git merge-base origin/master HEAD >/dev/null 2>&1; then | ||
| CHANGED=$(git diff --name-only origin/master...HEAD) | ||
| if [ -n "$CHANGED" ] && ! echo "$CHANGED" \ | ||
| | grep -qE '^(doc/|python/ray/|rllib/|\.readthedocs\.yaml$)'; then |
There was a problem hiding this comment.
The current filter excludes python/setup.py, but this file is imported by doc/source/conf.py (line 347) to determine the project version via find_version. Changes to setup.py (such as version bumps or dependency updates) should trigger a documentation build to ensure the version is correctly reflected in the docs and that the build logic remains functional. Please add python/setup.py to the allow-list.
| grep -qE '^(doc/|python/ray/|python/setup\.py$|rllib/|\.readthedocs\.yaml$)'; thenThere was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Reviewed by Cursor Bugbot for commit c2f81863e563546066b5e85fdf8886072b5542b3. Configure here.
Adds a build.jobs.post_checkout job to .readthedocs.yaml that exits 183 (RTD's "cancel build" sentinel) on PR builds when the diff doesn't touch any files that affect documentation output. Tag and branch builds (master, stable, etc.) always run. Today every PR triggers a full Sphinx build regardless of what it touches. When several PRs are open at once this overflows the project's concurrent build slots and older queued builds get marked "terminated due to inactivity" before a worker picks them up. The doc-affecting allowlist is intentionally broad — any change under doc/, python/ray/, rllib/, or .readthedocs.yaml itself triggers a full build. Anything else (C++/Cython under src/cpp, Java, Bazel, CI infrastructure, release tooling, Docker) skips. A mixed PR with even one doc-affecting file still builds. The `python/ray/**` and `rllib/**` paths are included because Sphinx autodoc pulls docstrings from them; narrowing further would be brittle as new modules are added. Auto-cancellation of older builds on the same PR/branch has been on by default in RTD since Oct 2022. This change complements that by reducing the load from cross-PR concurrency. Verified end-to-end on RTD with breadcrumb echos before they were stripped for this version: CHANGED is populated correctly from `git diff --name-only origin/master...HEAD` in the shallow-clone environment, each grep evaluates as expected, and DOC_CHANGED gates the exit-183 branch. Locally validated across /bin/sh, /bin/dash, and /bin/bash with a representative diff matrix. A few shell-construct choices in this script work around non-obvious processing quirks observed in RTD's job runner: `echo "$VAR"` instead of `printf '%s\n' "$VAR"` (backslash escapes in single-quoted strings are eaten before reaching the shell), `[.]` character classes instead of `\.` (same reason), no shell comments inside the `|` block (a comment containing backticks or `$()` causes the script to be dropped silently), and no grouped regex inside a `$()` capture. The YAML-level comments above the block document this so the constraints aren't lost in a future cleanup. See https://docs.readthedocs.com/platform/stable/guides/build/skip-build.html Signed-off-by: Douglas Strodtman <[email protected]>
6e2e763 to
8f9d2d2
Compare
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
| # for literal dots in regexes (not \.), and keep shell comments out | ||
| # of this block so that backticks/$() inside comments don't confuse | ||
| # the preprocessor. | ||
| post_checkout: |
There was a problem hiding this comment.
can you use git diff here instead
post_checkout:
- |
if [ "${READTHEDOCS_VERSION_TYPE:-}" != "external" ]; then
echo "Not a PR build (version type: '${READTHEDOCS_VERSION_TYPE:-unset}'); building docs."
exit 0
fi
git fetch --depth=500 origin master 2>/dev/null || true
if ! git merge-base origin/master HEAD >/dev/null 2>&1; then
echo "Could not determine merge-base with origin/master; building docs to be safe."
exit 0
fi
if git diff --quiet origin/master...HEAD -- doc/ python/ray/ rllib/ .readthedocs.yaml; then
echo "No doc-affecting files changed in this PR; skipping Sphinx build."
echo "Files changed in PR:"
git diff --name-only origin/master...HEAD
exit 183
fi
echo "Doc-affecting files changed; building docs. Changed doc-relevant paths:"
git diff --name-only origin/master...HEAD -- doc/ python/ray/ rllib/ .readthedocs.yaml
There was a problem hiding this comment.
🤷♂️
Will apply your change. LMK if there's additional testing I need to do.
Replace the echo|grep chain with a single pathspec-limited git diff --quiet, per review feedback. Same skip/build decisions for all prefix and boundary cases, with one behavior fix: a file renamed out of a doc-affecting path now triggers a build. Rename detection made the unfiltered --name-only output report only the destination path, so the grep filter missed the removal; the pathspec-limited diff sees the deletion side. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: Douglas Strodtman <[email protected]>
|
@elliot-barn Seems to be working per RtD logs, but hasn't been tested on a changed that safely can skip RtD build. Also: because the rules are so broad (include anything that touches Python source code because of API ref generation), not really sure how valuable this is, regardless. Might at least reduce noise on some infra/dependency only changes |
…roject#63431) ## Description Adds a `build.jobs.post_checkout` block to `.readthedocs.yaml` that exits with code 183 on PR ("external") builds when the diff doesn't touch any files that affect documentation output. Tag and branch builds (master, stable, etc.) always run. ## Why Today, every PR to `ray-project/ray` triggers a full Sphinx build on Read the Docs, regardless of what the PR touches. A PR that only changes C++, Java, Bazel, release tooling, or CI config produces the same docs build as a PR that rewrites `doc/`. When several PRs land in quick succession, this overflows the project's concurrent build slots on RTD. RTD's `finish_inactive_builds` periodic task then marks the older queued builds as `FAILED` with the message *"This build was terminated due to inactivity"* (see [readthedocs.org#4386](readthedocs/readthedocs.org#4386) — the name is misleading; the build isn't inactive, it just couldn't get a worker within ~1080 seconds). Contributors then see red checks on their PRs that have nothing to do with their changes. [Auto-cancellation of older builds for the same PR](https://blog.readthedocs.com/cancel-old-builds/) has been on by default in RTD since October 2022, but that only helps when you push twice to one PR — not across multiple open PRs. This change complements that by reducing the load from cross-PR concurrency. ## What the filter does On every PR build, it computes the diff against `origin/master` and exits 183 — RTD's [skip-build sentinel](https://docs.readthedocs.com/platform/stable/guides/build/skip-build.html) — only when **none** of the changed files match: - `doc/` — Sphinx sources, BUILD files, doc-only requirements. - `python/ray/` — anything `autodoc` could pull (kept intentionally broad). - `rllib/` — same. - `.readthedocs.yaml` — this config itself, so changes to it always test. If even one file falls in the allow-list, the build runs as before. If the diff can't be computed (shallow clone, fetch failure), the build runs. ## What this skips in practice PRs that don't touch any of the four paths above. Concrete examples: - C++ / Cython changes under `src/`, `cpp/`. - Java changes under `java/`. - Bazel changes under `bazel/`, top-level `BUILD.bazel`, `WORKSPACE`. - CI changes under `ci/`, `.buildkite/` (except `.buildkite/doc.rayci.yml` which isn't read by Sphinx but is excluded from the allow-list since it doesn't change RTD output). - Release tooling under `release/`. - Docker changes under `docker/`. - Top-level scripts and configs. ## What still triggers a build - All content under `doc/`. - Any `python/ray/**` change, because `autodoc` could pick it up. - Any `rllib/**` change, same reason. - The RTD config itself. The filter is deliberately conservative — broad inclusion, narrow exclusion. Better to do an unnecessary build than to miss a doc change. ## Test plan - Manual trace of the bash logic against representative paths: ✅ passes (Ray serve, RLlib, doc content, `.readthedocs.yaml`, mixed PRs all trigger BUILD; Java+C++, Docker, release, `python/setup.py`, empty diff all SKIP). - YAML syntax validated locally with `yaml.safe_load`. - This PR itself touches `.readthedocs.yaml`, so it will exercise the BUILD path on the RTD preview. ## Future work If queue pressure persists after this lands, two further levers: 1. Narrow the `python/ray/**` allow-list to exclude paths that don't appear in any `autodoc` directive (`python/ray/tests/`, `python/ray/_private/` candidates). Higher maintenance cost. 2. File an RTD support request to ask about the project's concurrent-build limit on the current plan. ## Related issues None linked. --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
…roject#63431) ## Description Adds a `build.jobs.post_checkout` block to `.readthedocs.yaml` that exits with code 183 on PR ("external") builds when the diff doesn't touch any files that affect documentation output. Tag and branch builds (master, stable, etc.) always run. ## Why Today, every PR to `ray-project/ray` triggers a full Sphinx build on Read the Docs, regardless of what the PR touches. A PR that only changes C++, Java, Bazel, release tooling, or CI config produces the same docs build as a PR that rewrites `doc/`. When several PRs land in quick succession, this overflows the project's concurrent build slots on RTD. RTD's `finish_inactive_builds` periodic task then marks the older queued builds as `FAILED` with the message *"This build was terminated due to inactivity"* (see [readthedocs.org#4386](readthedocs/readthedocs.org#4386) — the name is misleading; the build isn't inactive, it just couldn't get a worker within ~1080 seconds). Contributors then see red checks on their PRs that have nothing to do with their changes. [Auto-cancellation of older builds for the same PR](https://blog.readthedocs.com/cancel-old-builds/) has been on by default in RTD since October 2022, but that only helps when you push twice to one PR — not across multiple open PRs. This change complements that by reducing the load from cross-PR concurrency. ## What the filter does On every PR build, it computes the diff against `origin/master` and exits 183 — RTD's [skip-build sentinel](https://docs.readthedocs.com/platform/stable/guides/build/skip-build.html) — only when **none** of the changed files match: - `doc/` — Sphinx sources, BUILD files, doc-only requirements. - `python/ray/` — anything `autodoc` could pull (kept intentionally broad). - `rllib/` — same. - `.readthedocs.yaml` — this config itself, so changes to it always test. If even one file falls in the allow-list, the build runs as before. If the diff can't be computed (shallow clone, fetch failure), the build runs. ## What this skips in practice PRs that don't touch any of the four paths above. Concrete examples: - C++ / Cython changes under `src/`, `cpp/`. - Java changes under `java/`. - Bazel changes under `bazel/`, top-level `BUILD.bazel`, `WORKSPACE`. - CI changes under `ci/`, `.buildkite/` (except `.buildkite/doc.rayci.yml` which isn't read by Sphinx but is excluded from the allow-list since it doesn't change RTD output). - Release tooling under `release/`. - Docker changes under `docker/`. - Top-level scripts and configs. ## What still triggers a build - All content under `doc/`. - Any `python/ray/**` change, because `autodoc` could pick it up. - Any `rllib/**` change, same reason. - The RTD config itself. The filter is deliberately conservative — broad inclusion, narrow exclusion. Better to do an unnecessary build than to miss a doc change. ## Test plan - Manual trace of the bash logic against representative paths: ✅ passes (Ray serve, RLlib, doc content, `.readthedocs.yaml`, mixed PRs all trigger BUILD; Java+C++, Docker, release, `python/setup.py`, empty diff all SKIP). - YAML syntax validated locally with `yaml.safe_load`. - This PR itself touches `.readthedocs.yaml`, so it will exercise the BUILD path on the RTD preview. ## Future work If queue pressure persists after this lands, two further levers: 1. Narrow the `python/ray/**` allow-list to exclude paths that don't appear in any `autodoc` directive (`python/ray/tests/`, `python/ray/_private/` candidates). Higher maintenance cost. 2. File an RTD support request to ask about the project's concurrent-build limit on the current plan. ## Related issues None linked. --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
…roject#63431) ## Description Adds a `build.jobs.post_checkout` block to `.readthedocs.yaml` that exits with code 183 on PR ("external") builds when the diff doesn't touch any files that affect documentation output. Tag and branch builds (master, stable, etc.) always run. ## Why Today, every PR to `ray-project/ray` triggers a full Sphinx build on Read the Docs, regardless of what the PR touches. A PR that only changes C++, Java, Bazel, release tooling, or CI config produces the same docs build as a PR that rewrites `doc/`. When several PRs land in quick succession, this overflows the project's concurrent build slots on RTD. RTD's `finish_inactive_builds` periodic task then marks the older queued builds as `FAILED` with the message *"This build was terminated due to inactivity"* (see [readthedocs.org#4386](readthedocs/readthedocs.org#4386) — the name is misleading; the build isn't inactive, it just couldn't get a worker within ~1080 seconds). Contributors then see red checks on their PRs that have nothing to do with their changes. [Auto-cancellation of older builds for the same PR](https://blog.readthedocs.com/cancel-old-builds/) has been on by default in RTD since October 2022, but that only helps when you push twice to one PR — not across multiple open PRs. This change complements that by reducing the load from cross-PR concurrency. ## What the filter does On every PR build, it computes the diff against `origin/master` and exits 183 — RTD's [skip-build sentinel](https://docs.readthedocs.com/platform/stable/guides/build/skip-build.html) — only when **none** of the changed files match: - `doc/` — Sphinx sources, BUILD files, doc-only requirements. - `python/ray/` — anything `autodoc` could pull (kept intentionally broad). - `rllib/` — same. - `.readthedocs.yaml` — this config itself, so changes to it always test. If even one file falls in the allow-list, the build runs as before. If the diff can't be computed (shallow clone, fetch failure), the build runs. ## What this skips in practice PRs that don't touch any of the four paths above. Concrete examples: - C++ / Cython changes under `src/`, `cpp/`. - Java changes under `java/`. - Bazel changes under `bazel/`, top-level `BUILD.bazel`, `WORKSPACE`. - CI changes under `ci/`, `.buildkite/` (except `.buildkite/doc.rayci.yml` which isn't read by Sphinx but is excluded from the allow-list since it doesn't change RTD output). - Release tooling under `release/`. - Docker changes under `docker/`. - Top-level scripts and configs. ## What still triggers a build - All content under `doc/`. - Any `python/ray/**` change, because `autodoc` could pick it up. - Any `rllib/**` change, same reason. - The RTD config itself. The filter is deliberately conservative — broad inclusion, narrow exclusion. Better to do an unnecessary build than to miss a doc change. ## Test plan - Manual trace of the bash logic against representative paths: ✅ passes (Ray serve, RLlib, doc content, `.readthedocs.yaml`, mixed PRs all trigger BUILD; Java+C++, Docker, release, `python/setup.py`, empty diff all SKIP). - YAML syntax validated locally with `yaml.safe_load`. - This PR itself touches `.readthedocs.yaml`, so it will exercise the BUILD path on the RTD preview. ## Future work If queue pressure persists after this lands, two further levers: 1. Narrow the `python/ray/**` allow-list to exclude paths that don't appear in any `autodoc` directive (`python/ray/tests/`, `python/ray/_private/` candidates). Higher maintenance cost. 2. File an RTD support request to ask about the project's concurrent-build limit on the current plan. ## Related issues None linked. --------- Signed-off-by: Douglas Strodtman <[email protected]> Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: 400Ping <[email protected]>

Description
Adds a
build.jobs.post_checkoutblock to.readthedocs.yamlthat exits with code 183 on PR ("external") builds when the diff doesn't touch any files that affect documentation output. Tag and branch builds (master, stable, etc.) always run.Why
Today, every PR to
ray-project/raytriggers a full Sphinx build on Read the Docs, regardless of what the PR touches. A PR that only changes C++, Java, Bazel, release tooling, or CI config produces the same docs build as a PR that rewritesdoc/.When several PRs land in quick succession, this overflows the project's concurrent build slots on RTD. RTD's
finish_inactive_buildsperiodic task then marks the older queued builds asFAILEDwith the message "This build was terminated due to inactivity" (see readthedocs.org#4386 — the name is misleading; the build isn't inactive, it just couldn't get a worker within ~1080 seconds). Contributors then see red checks on their PRs that have nothing to do with their changes.Auto-cancellation of older builds for the same PR has been on by default in RTD since October 2022, but that only helps when you push twice to one PR — not across multiple open PRs. This change complements that by reducing the load from cross-PR concurrency.
What the filter does
On every PR build, it computes the diff against
origin/masterand exits 183 — RTD's skip-build sentinel — only when none of the changed files match:doc/— Sphinx sources, BUILD files, doc-only requirements.python/ray/— anythingautodoccould pull (kept intentionally broad).rllib/— same..readthedocs.yaml— this config itself, so changes to it always test.If even one file falls in the allow-list, the build runs as before. If the diff can't be computed (shallow clone, fetch failure), the build runs.
What this skips in practice
PRs that don't touch any of the four paths above. Concrete examples:
src/,cpp/.java/.bazel/, top-levelBUILD.bazel,WORKSPACE.ci/,.buildkite/(except.buildkite/doc.rayci.ymlwhich isn't read by Sphinx but is excluded from the allow-list since it doesn't change RTD output).release/.docker/.What still triggers a build
doc/.python/ray/**change, becauseautodoccould pick it up.rllib/**change, same reason.The filter is deliberately conservative — broad inclusion, narrow exclusion. Better to do an unnecessary build than to miss a doc change.
Test plan
.readthedocs.yaml, mixed PRs all trigger BUILD; Java+C++, Docker, release,python/setup.py, empty diff all SKIP).yaml.safe_load..readthedocs.yaml, so it will exercise the BUILD path on the RTD preview.Future work
If queue pressure persists after this lands, two further levers:
python/ray/**allow-list to exclude paths that don't appear in anyautodocdirective (python/ray/tests/,python/ray/_private/candidates). Higher maintenance cost.Related issues
None linked.