hack: scope docs validation and show diff on failure#3874
Conversation
crazy-max
left a comment
There was a problem hiding this comment.
I think we should keep the git-based validation here.
This target is already sandboxed. The validate stage copies the source context into a tmpfs, then checks whether applying the generated /out docs would leave docs/reference or docs/bake-stdlib.md dirty. The git add -A snapshots the docs as received by the sandbox, and git status validates the same contract as make docs: after replacing docs with generated output, there should be no repository changes under those paths.
A raw diff -ru /out/reference docs/reference changes that from a repository-state validation into a byte-for-byte directory comparison. That does not make generation more deterministic, it mostly changes diagnostics and bypasses Git's normalization/index behavior. If the issue is that the current error is not useful enough, we can add a diff on the failure path while keeping the git validation.
The bake/entitlements_test.go change also looks unrelated to docs validation. I can see the theory, since evaluateToExistingPath resolves symlinked path components and macOS may expose /var through /private/var, but the PR doesn't show an actual failing case, and the current tests already pass on macOS runners. If there is a real local macOS failure, please include the failing output and split that fix into a separate PR. Otherwise I think that change should be dropped.
a60713c to
e3c1167
Compare
963cd80 to
d3261cf
Compare
Tighten the validate stage of the docs Dockerfile: - Drop the unscoped `git add -A`; the validation is a working-tree-vs-HEAD check, which `git status --porcelain` answers directly without mutating the index. - Path-scope detection (`git status --porcelain`) and diagnostics (`git diff`) to `docs/reference` and `docs/bake-stdlib.md`, so unrelated working-tree state cannot cause a false positive. - Mirror the freshly generated docs with `rsync -a --delete` so any stale files left behind are also reset. - On failure, print the changed paths and a (truncated) diff alongside the error message, giving contributors an actionable signal. - `git add -N` before diffing so untracked files (e.g. a new command's docs) appear in the diff instead of only in the path list. Signed-off-by: Lohit Kolluri <lohitkolluri@gmail.com>
d3261cf to
e1a5f03
Compare
|
Updated to scope the docs validation and make the failure output actionable:
All four test cases from the updated test plan pass against the final state. @crazy-max PTAL |
Summary
Tighten the validate stage of
hack/dockerfiles/docs.Dockerfile:git add -A; the validation is a working-tree-vs-HEAD check, whichgit status --porcelainanswers directly without mutating the index.git status --porcelain) and diagnostics (git diff) todocs/referenceanddocs/bake-stdlib.md, so unrelated working-tree state cannot false-positive.rsync -a --deleteso any stale files are also reset (no separaterm -rfneeded).git add -Nbefore diffing so untracked files (e.g. a new command's docs) appear in the diff instead of only in the path list.Approach
Detection and diagnostics are both path-scoped:
git status --porcelainfor the binary check,git difffor the failure output.rsync --deletehandles the wholesale replacement, andgit add -Nensures the diff shows content for newly added files.Test plan
make docs && make validate-docssucceeds when docs are in syncdocs/reference/, re-runmake validate-docs, confirm validate fails with the new changed-paths + diff outputdocs/reference/, re-runmake validate-docs, confirm the new file's content is shown in the diffmake validate-docsstill passes (no false positive)AI disclosure
Prepared with AI assistance (Claude Code).