Skip to content

fix(sphinxdocs): invalidate cache on branch change#3917

Open
kaycebasques wants to merge 8 commits into
bazel-contrib:mainfrom
kaycebasques:git_test
Open

fix(sphinxdocs): invalidate cache on branch change#3917
kaycebasques wants to merge 8 commits into
bazel-contrib:mainfrom
kaycebasques:git_test

Conversation

@kaycebasques

Copy link
Copy Markdown
Collaborator

We had to disable the sphinxdocs persistent worker in Pigweed (https://pwbug.dev/493749800) because the cache invalidation logic seemed incomplete with regards to Git branches. E.g. in branch feat you create a new doc foo.rst. You switch back to branch main and try to build Sphinx, but Sphinx warns about needing to ignore unreadable document foo.rst. Because Pigweed builds Sphinx with --fail-on-warning this would break our docs build. This PR adds the bug fix and also starts a suite of tests that will be focused on persistent worker correctness.

@kaycebasques kaycebasques added type: bug sphinxdocs Issues relating to the sphinxdocs code labels Jul 10, 2026

@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 improves the Sphinx persistent worker's resilience and correctness during incremental builds and branch switches. It introduces logic to clean up stale source files, clear corrupted doctree caches on failure, and properly invalidate parent documents when referenced files are added or removed. Additionally, a comprehensive integration test suite is added to verify these behaviors across git checkouts. The feedback suggests wrapping the file removal logic in a robust, cross-platform helper to prevent worker crashes, and optimizing the toctree membership check using isdisjoint for better performance.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread sphinxdocs/sphinxdocs/private/sphinx_build.py Outdated
Comment thread sphinxdocs/sphinxdocs/private/sphinx_build.py Outdated
@kaycebasques kaycebasques force-pushed the git_test branch 7 times, most recently from 75d34d0 to 4197ec2 Compare July 10, 2026 23:42
Per repository policy, new files should not include Bazel copyright headers. Removed headers from newly added test files.
@kaycebasques

Copy link
Copy Markdown
Collaborator Author

temporary artifact (build.log) needs to be deleted

Comment thread sphinxdocs/tests/persistent_worker/git_test.py Outdated
Comment thread sphinxdocs/tests/persistent_worker/BUILD.bazel Outdated
Comment thread sphinxdocs/tests/persistent_worker/git_test.py Outdated
kaycebasques and others added 5 commits July 11, 2026 00:27
Delete temporary build.log artifact from PR. Move persistent worker integration test to top-level integration_tests/ directory. Replace Git commands in persistent worker test with direct file modifications and rules_bazel_integration_test (BIT). Update rules_go override and distribution filegroups for robust sandboxed testing.
Refine integration test setup and configuration based on review feedback. Added .bazelignore for bazel-* outputs, upgraded rules_bazel_integration_test to 0.37.1, configured local 'self' bazel testing via bazel_from_env wrapper, replaced strict_action_env override with action_env/test_env flags, and refined index.html check path.
Put deleted_packages on separate lines in .bazelrc.deleted_packages, remove redundant fast-tests tag filters from nested workspace .bazelrc, and add explanatory comments for cache disabling flags.

@rickeylev rickeylev 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.

I've refactor a bunch to address my comments

  • Switched it to rules_bazle_integration_test
  • removed using git
    etc

Replace wildcard pattern in .bazelignore with explicit bazel-* directory paths (bazel-bin, bazel-out, bazel-testlogs, bazel-sphinxdocs) to avoid InvalidPathException across platforms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sphinxdocs Issues relating to the sphinxdocs code type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants