Repository navigation
Build docs in strict mode in CI - #1489
Merged
Merged
Conversation
Add a Docs workflow that runs `mkdocs build --strict` on every pull request and push to main, using the Python version from runtime.txt (the one Netlify deploys with). It runs for all paths because module docs include snippets from packages/**/*.test.ts. Strict mode alone passes on main, so also: - enable MkDocs link validation (unrecognized links, anchors, absolute links, files missing from nav) at warn level so strict mode fails on it - set codeinclude `block_throw: true`; without it a missing `inside_block` marker silently includes the whole test file - fix the three relative links in features/containers.md that MkDocs could not validate
✅ Deploy Preview for testcontainers-node ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
No workflow builds the docs, and
Checksignoresdocs/**andmkdocs.yml. Netlify deploy previews run a plainmkdocs build, which only fails when a file is missing outright. Broken links, broken anchors andinside_blockmarkers that no longer match all get through.This PR:
Docsworkflow (.github/workflows/docs.yml) that runsmkdocs build --stricton every pull request and push tomain.docs/**. Module docs pull snippets frompackages/**/*.test.tswith codeinclude, so renaming a test block can break the docs. The job installs Python and pip packages only, so it takes well under a minute.runtime.txtviasetup-python'spython-version-file. Netlify reads the same file when it deploys the docs (the site is served from Netlify Edge).permissions: contents: read, and the same concurrency group asChecks.warnlevel so--strictfails on unrecognized links, missing anchors, absolute links and doc files left out ofnav. MkDocs 1.6 reports most of these atinfoby default, which--strictignores.block_throw: true(see the experiment below).docs/features/containers.md./site/(MkDocs output) to.gitignore, a line inCONTRIBUTING.mdabout running the strict build locally, and anAGENTS.mdnote on howinside_blockmatching works.Findings on
mainmkdocs build --strictonmainpasses (exit 0). The only problems are reported atINFOlevel:With the validation settings from this PR, the same tree fails (red):
These links work on the live site only because of directory URLs. MkDocs leaves them unchecked, so a typo in the target page or anchor would not be caught. They now use
.mdlinks, which MkDocs resolves and checks.No other problems were found. Every page is in
nav, there are no absolute links, and every codeinclude file andinside_blockmarker resolves.Broken-include experiment
Results of breaking things on purpose, using
main'smkdocs.ymland then this PR's:mainconfig,--strict--strict// kafkaLatestConnect {marker inkafka-container-latest.test.tsdescribe(...), everything)ValueError: Block kafkaLatestConnect not found to inject from ../../packages/modules/kafka/src/kafka-container-latest.test.tsFileNotFoundErrorFileNotFoundError../networking#network-alias(mainstyle) ornetworking.md#network-alias(this PR)INFOline)... does not contain an anchor '#network-alias'So strict mode alone does not catch a stale
inside_blockmarker, because codeinclude falls back to the whole file when a block is missing.block_throw: trueis the plugin's built-in switch for this, so no extra script is needed.One gap remains:
inside_block:<name>matches the first line containing<name>as a substring. My first try renamed the marker tokafkaLatestConnectRenamed, which still matched, and the build passed. I added a note toAGENTS.mdfor this. I also checked every current marker, and none of them picks up an earlier, unrelated line.After the fixes (green)
Verification
docs, Markdown, YAML), sonpm run formatandnpm run lintdon't apply.Not breaking
Patch. No package source or public API changes. The diff touches CI, MkDocs config, three doc links,
.gitignore,CONTRIBUTING.mdandAGENTS.md. The rendered site is the same apart from the three linkhrefs, which now point at the canonical page URLs.