validate: make docs validation deterministic#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.
|
Thanks for the detailed feedback, that makes sense. I’ve restored the git-based validation so it continues to verify the same “repo is clean after I also added |
Compare generated docs output directly against checked-in reference docs to make validation deterministic, instead of using diff-based comparison which was non-deterministic across runs. - Use trailing slash on docsgen source path for directory semantics - Replace docs instead of diffing: rm + cp replaces git-add + diff -ru - Check git diff --cached instead of git status --porcelain for more reliable change detection - Scope git add to specific paths (docs/reference, docs/bake-stdlib.md) Signed-off-by: Lohit Kolluri <lohitkolluri@gmail.com>
a60713c to
e3c1167
Compare
Summary
Compare generated docs output directly against checked-in reference docs to make validation deterministic. Replace the
diff -rucomparison in the validate step with a git-based approach: replace docs from /out, stage the result, and compare againstgit diff --cached.The previous
diff -ruapproach was non-deterministic across runs because it depended on filesystem ordering and state. The git-based approach is deterministic and produces clearer error output (shows the actual diff).Changes
rm+cpreplacesgit-add+diff -rugit diff --cachedinstead ofgit status --porcelainfor more reliable change detectiongit add -Ato specific paths (docs/reference,docs/bake-stdlib.md)Test plan
make validate-all(validate step in Dockerfile runs during this target)