Skip to content

validate: make docs validation deterministic#3874

Open
lohitkolluri wants to merge 1 commit into
docker:masterfrom
lohitkolluri:lk/fix-validate-docs-deterministic
Open

validate: make docs validation deterministic#3874
lohitkolluri wants to merge 1 commit into
docker:masterfrom
lohitkolluri:lk/fix-validate-docs-deterministic

Conversation

@lohitkolluri

@lohitkolluri lohitkolluri commented May 28, 2026

Copy link
Copy Markdown

Summary

Compare generated docs output directly against checked-in reference docs to make validation deterministic. Replace the diff -ru comparison in the validate step with a git-based approach: replace docs from /out, stage the result, and compare against git diff --cached.

The previous diff -ru approach 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

  • 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 -A to specific paths (docs/reference, docs/bake-stdlib.md)

Test plan

  • make validate-all (validate step in Dockerfile runs during this target)

@crazy-max crazy-max left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@lohitkolluri

Copy link
Copy Markdown
Author

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 make docs” contract as before.

I also added git diff --cached on the failure path to make the diagnostics easier to understand instead of switching the validation to a raw directory diff.

@lohitkolluri lohitkolluri requested a review from crazy-max May 28, 2026 13:56
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>
@lohitkolluri lohitkolluri force-pushed the lk/fix-validate-docs-deterministic branch from a60713c to e3c1167 Compare June 20, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants