Skip to content

ci(site-docs): diff frozen snapshots against the merge commit's first parent - #1123

Merged
BryanFRD merged 1 commit into
mainfrom
ci/site-docs-frozen-diff
Sep 22, 2026
Merged

BryanFRD merged 1 commit into
mainfrom
ci/site-docs-frozen-diff

Conversation

@BryanFRD

Copy link
Copy Markdown
Contributor

The frozen-snapshot check diffed base.sha...HEAD. base.sha can be stale while HEAD is the merge with the current base tip, so changes merged to main after the PR branched were blamed on the PR (#1115 failed on #1117's docs-fr-v5/v6 edits).

Now it diffs HEAD^1 HEAD, the PR's own contribution on top of the current base. Checkout drops to fetch-depth: 2 since only the merge commit and its first parent are needed, and the unused BASE env is gone. Adding a new docs-vN directory is still allowed.

Checked locally on a throwaway repo: with a stale base the old diff reported a frozen file changed on main, the new one reported nothing; a PR that really edits a frozen file is still caught.

Closes #1122

@BryanFRD
BryanFRD enabled auto-merge (squash) September 22, 2026 07:17

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

The diff base is right: for pull_request, checkout lands on refs/pull/N/merge, whose first parent is the current base tip, so HEAD^1 HEAD is the PR's own contribution and the stale-base.sha blame from #1115 goes away. fetch-depth: 2 is the minimum that keeps HEAD^1 resolvable (a shallow fetch at depth 2 includes both parents of the tip), and nothing else in the job reads history: validate-site-docs.mjs only walks the filesystem, and the frozen step is skipped on push.

One nit inline, plus one thing worth knowing rather than changing: HEAD^1 only means "base tip" because checkout has no ref:. If anyone later pins it to pull_request.head.sha, the check silently narrows to the last commit on the branch instead of failing. A comment on the step would be cheaper than the debugging session.

BASE: ${{ github.event.pull_request.base.sha }}
run: |
edited=$(git diff --diff-filter=MD --name-only "$BASE...HEAD" -- 'docs/site/docs-v*' 'docs/site/docs-fr-v*')
edited=$(git diff --diff-filter=MD --name-only HEAD^1 HEAD -- 'docs/site/docs-v*' 'docs/site/docs-fr-v*')

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.

Nit (pre-existing, not introduced here): rename detection is on by default, so a file renamed within a frozen snapshot comes out as R and is filtered away by --diff-filter=MD. git mv docs/site/docs-v5/intro.md docs/site/docs-v5/getting-started.md currently passes the check even though the frozen page is gone from its old URL. --no-renames splits it back into A+D and the D is caught.

Suggested change
edited=$(git diff --diff-filter=MD --name-only HEAD^1 HEAD -- 'docs/site/docs-v*' 'docs/site/docs-fr-v*')
edited=$(git diff --no-renames --diff-filter=MD --name-only HEAD^1 HEAD -- 'docs/site/docs-v*' 'docs/site/docs-fr-v*')

@BryanFRD
BryanFRD merged commit 38e0c30 into main Sep 22, 2026
31 checks passed
@BryanFRD
BryanFRD deleted the ci/site-docs-frozen-diff branch September 22, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Site docs frozen-snapshot check blames PRs for changes already on main

1 participant