Skip to content

fix(ci): scope markdown-link-check to the PR's merge base - #3620

Open
liamcrumm wants to merge 1 commit into
mainfrom
fix/link-check-merge-base
Open

fix(ci): scope markdown-link-check to the PR's merge base#3620
liamcrumm wants to merge 1 commit into
mainfrom
fix/link-check-merge-base

Conversation

@liamcrumm

Copy link
Copy Markdown
Contributor

Summary

Scope markdown-link-check to the files a PR actually changed, instead of every file that changed on main since the branch point.

Problem

The job sets check-modified-files-only: 'yes' with base-branch: main. That action runs git diff --name-only main, a two-dot diff against the base tip, so on a branch that has fallen behind, every commit that landed on main since the branch point is reported as modified.

The job then checks those files as they exist on the stale branch, and fails on links that were already fixed upstream.

Measured on #3450, which is 55 commits behind and changes exactly one markdown file:

files checked by the job : 255
markdown files in the PR : 1

It failed on four links, all of which #3352 had already fixed on main before that run executed.

Every PR currently failing this check is behind main:

PR commits behind
#3612 269
#3342 65
#3523 61
#3254 59
#3450 55
#3574, #3508, #3251 37
#3255 23
#3409 14

The job's own comment states the intent ("Only check links in files changed by the PR/push to avoid pre-existing broken links blocking unrelated work"), which the two-dot diff defeats.

ci-complete lists markdown-link-check in its needs, so each of these also fails ci-complete.

Changes

File What changed
.github/workflows/ci.yml Resolve base-branch to git merge-base origin/$BASE_REF HEAD before invoking the action

Non-pull-request events (schedule, push) keep the previous behaviour. If merge-base cannot be resolved, the step warns and falls back to the base tip, which is exactly today's behaviour.

Testing

python3 scripts/ci/generate_workflows.py --check passes, and the YAML parses with yaml.safe_load. This PR's own markdown-link-check run exercises the change.

`check-modified-files-only` runs `git diff --name-only <base-branch>`, a
two-dot diff against the base tip. On a branch that has fallen behind main,
every commit that landed on main since the branch point is reported as
modified, so the job checks files the PR never touched and fails on links
that were already fixed upstream.

Measured on #3450 (55 commits behind, one changed .md file): the job checked
255 markdown files and failed on four links that #3352 had already fixed on
main. All ten PRs currently failing this check are behind main, by 14 to 269
commits.

Resolve the base to its merge base with HEAD so the diff covers only what the
branch actually changed. Non-pull-request events keep the previous behaviour.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: liamcrumm <14815298+liamcrumm@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 4, 2026 23:14
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

PR Review Summary

Check Status Details
🔍 Code Review ⚠️ Missing No current-run comment
🛡️ Security Scan ⚠️ Missing No current-run comment
🔄 Breaking Changes ⚠️ Missing No current-run comment
📝 Docs Sync ⚠️ Missing No current-run comment
🧪 Test Coverage ⚠️ Missing No current-run comment

Verdict: ⚠️ AI review incomplete; ready for human review

AI review comments are untrusted advisory output. The summary reports workflow-generated completion status only, not model-authored pass/fail claims.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions github-actions Bot added the size/S Small PR (< 50 lines) label Aug 4, 2026

Copilot AI 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.

Pull request overview

TL;DR: 0 blockers, 0 warnings. No issues found. Clean change.

This PR fixes CI behavior for docs-only PRs by scoping markdown-link-check to the PR’s merge base rather than the base branch tip, avoiding false failures when a PR branch is behind main.

Changes:

  • Adds a step to compute git merge-base origin/$BASE_REF HEAD for pull requests and feeds that SHA into base-branch.
  • Preserves existing behavior for non-PR events (schedule/push), with a warning + fallback when merge-base cannot be resolved.

@liamcrumm

Copy link
Copy Markdown
Contributor Author

Validated the scoping change locally against #3450 (55 commits behind, one changed markdown file):

two-dot     (current):  254 md files
merge-base  (fixed)  :    1 md file  -> agent-governance-rust/agentmesh/README.md

Note this PR cannot exercise the change itself: markdown-link-check only runs when needs.changes.outputs['docs-only'] == 'true', and this is a workflow-only change, so the job skips here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is right, and it has been sitting for eight days blocked on a single word.

The diagnosis matches what #3530 fixed for the spell-check job. check-modified-files-only runs git diff --name-only <base-branch>, a two-dot diff against the base tip, so a branch behind main reports every commit that landed since the branch point as modified. The job then evaluates those files as they exist on the stale branch and fails on links that were fixed upstream, which is a failure attributed to a contributor for something they did not touch and cannot fix. #3450 at 55 commits behind is a fair illustration.

Resolving to the merge base is the correct scope. Two details I would call out as done right rather than incidental: falling back to the base tip with a ::warning:: annotation rather than failing, so an unresolvable merge base degrades to the old over-reporting behaviour instead of blocking; and keeping the previous behaviour when github.base_ref is empty, so schedule and push triggers are unaffected.

The only thing blocking this is a dictionary entry, and it is in someone else's PR.

Spell-check changed files fails twice on linkbase, the step id this PR introduces. That word is not in .cspell-repo-terms.txt on main. It is in my #3640, added with the comment "Step id in ci.yml's markdown-link-check merge-base scoping (#3620)". So the two PRs are interlocked: this one cannot go green until that word lands, and nothing about that is visible from either PR's checks. Whoever picks either up should take both, or move the entry across.

One correction I owe this PR. #3640's description claimed this one inherits a stale-ref flaw, on the theory that actions/checkout narrows remote.origin.fetch so git fetch origin <branch> leaves origin/<base> stale. MohammadHaroonAbuomar showed that does not hold on current main, and I confirmed it. That criticism is withdrawn: git fetch --no-tags origin "$BASE_REF" followed by git merge-base is fine as written here, and I have rewritten #3640 to stop saying otherwise.

No approve bit on this repo, so a comment, but I would merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scripts/ci/cd size/S Small PR (< 50 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants