Thanks to visit codestin.com
Credit goes to github.com

Skip to content

sphinx_docs creates an implicit build_test target #2645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
255 opened this issue Mar 3, 2025 · 5 comments
Closed

sphinx_docs creates an implicit build_test target #2645

255 opened this issue Mar 3, 2025 · 5 comments

Comments

@255
Copy link
Contributor

255 commented Mar 3, 2025

sphinx_docs creates an implicit build_test target. (Note that this is not currently documented.)

https://github.com/bazelbuild/rules_python/blob/f2941df7562c4183c37d6ceeae23e7d390738d58/sphinxdocs/private/sphinx.bzl#L196-L197

This means that commands like bazel test //... always include sphinx_docs targets. For developers (like me) that repeatedly run tests, this is pretty costly, especially given the lack of incremental builds.

Could the implicit _build_test target be removed from sphinx_docs?

I would prefer if sphinx_docs left the policy of whether to build_test each target to users. Since projects don't typically have many sphinx_docs targets, manually adding build_tests as needed should not be burdensome.

@255
Copy link
Contributor Author

255 commented Mar 3, 2025

@rickeylev

@rickeylev
Copy link
Collaborator

I agree. Send a PR to remove it? Please just add a replacement build_test for these:

  • //docs:docs_build_test
  • //sphinxdocs/tests/sphinx_docs:docs_build_test
  • //sphinxdocs/tests/sphinx_stardoc:docs_build_test

Simply putting a build_test(...) in the same directory in the BUILD file SGTM.

bazel test //...

Running //... is my general flow, too, so a tip I use: --build_tests_only. Helps avoiding building a bunch of stuff that isn't actually run.

Actually, while were in sphinx.bzl, marking the .run and .serve targets with tags=["manual"] is probably a good idea, too. Those are just for interactive development, so no reason they should be build by wildcard stuff. Less to build -> more resources for building/running the tests you're interested in.

given the lack of incremental builds.

By incremental, you mean Sphinx's support for "incremental" building? I seem to recall it has a "check if files have been modified" feature that I disabled in the rules. You could try enabling that

You're from pigweed, right? What sort of build times do you see? Something I'd like is to have sphinx implemented as a worker process, under the assumption it'd be able to leverage sphinx's "only rebuild changed files" feature somehow.

@rickeylev
Copy link
Collaborator

Also, as an interim workaround, setting --test_tag_filters=-@rules_python//sphinxdocs:sphinx_docs should cause the build test to be ignored when Bazel expands out test to run.

@255
Copy link
Contributor Author

255 commented Mar 6, 2025

I will put together a PR with the changes you suggest, thanks!

Yes, I'm from Pigweed. A warmed up Pigweed docs build takes about 1½ minutes on a fast machine. By the lack of incremental builds, I mean that our docs completely rebuild if any files they depend on change. So, a trivial whitespace change in one file takes 1½ minutes currently.

The "check if files have been modified" feature sounds like what we need. Will look into that, thanks!

255 added a commit to 255/rules_python that referenced this issue Mar 6, 2025
No longer add implicit build_tests to sphinx_docs targets. Users can
manually add build_tests as needed. Add build_tests to cover in-tree
sphinx_docs uses, and rename the existing build_test for
//sphinxdocs/tests/sphinx_docs for consistency with the new targets.

Also, tag the sphinx_docs *.run and *.serve targets as "manual" so they
are excluded from `bazel build //...`. These are only needed for
interactive development.
255 added a commit to 255/rules_python that referenced this issue Mar 6, 2025
Remove the implicit build_tests from sphinx_docs targets. Users can
manually add build_tests as needed. Add build_tests to cover in-tree
sphinx_docs uses, and rename the existing build_test for
//sphinxdocs/tests/sphinx_docs to match the new targets.

Also, tag the sphinx_docs *.run and *.serve targets as "manual" so they
are excluded from wildcards. These are only needed for interactive
development.
255 added a commit to 255/rules_python that referenced this issue Mar 6, 2025
Remove implicit build_tests from sphinx_docs targets. Instead, users can
decide whether or not to add build_tests for docs. This also keeps
sphinx_docs builds out of `bazel test //...`, which may not be
desireable.

Add build_tests to cover in-tree sphinx_docs targets. Rename the
existing build_test for //sphinxdocs/tests/sphinx_docs:docs to match the
new targets.

Also, tag the sphinx_docs *.run and *.serve targets as "manual" so they
are excluded from wildcards. These are only needed for interactive
development.
255 added a commit to 255/rules_python that referenced this issue Mar 6, 2025
Remove implicit build_tests from sphinx_docs targets. Instead, users can
decide whether or not to add build_tests for docs. This also keeps
sphinx_docs builds out of `bazel test //...`, which may not be
desirable.

Add build_tests to cover in-tree sphinx_docs targets. Rename the
existing build_test for //sphinxdocs/tests/sphinx_docs:docs to match the
new targets.

Also, tag the sphinx_docs *.run and *.serve targets as "manual" so they
are excluded from wildcards. These are only needed for interactive
development.
@255
Copy link
Contributor Author

255 commented Mar 6, 2025

Opened #2650 with the changes.

github-merge-queue bot pushed a commit that referenced this issue Mar 6, 2025
Remove implicit `build_test`s from `sphinx_docs` targets. Instead, users
can decide whether or not to add `build_tests` for docs. This also keeps
`sphinx_docs` builds out of `bazel test //...`, which may not be
desirable.

Add `build_test`s to cover in-tree `sphinx_docs` targets. Rename the
existing `build_test` for `//sphinxdocs/tests/sphinx_docs:docs` to match
the new targets.

Also, tag the `sphinx_docs` `*.run` and `*.serve` targets as `"manual"`
so they are excluded from wildcards. These are only needed for
interactive development.

---------

Co-authored-by: Richard Levasseur <[email protected]>
@aignas aignas closed this as completed Mar 7, 2025
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

No branches or pull requests

3 participants