From ee59bcc38844ba26557b01cdac8f0ce31eddef27 Mon Sep 17 00:00:00 2001 From: Toshihiko SHIMOKAWA Date: Mon, 11 May 2026 21:15:21 +0900 Subject: [PATCH 1/2] Fix auto-skip detection: use HEAD^1..HEAD^2 for PR diff (#80) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous diff direction (HEAD^2..HEAD) compared the PR head against the synthetic merge commit, which only returns changes that landed on base since the PR branched off — typically empty or docs-only. As a result, DOCS_ONLY stayed true and every PR got auto-skipped regardless of what it actually changed. Use HEAD^1..HEAD^2 (base..PR head) instead, which is the PR's actual diff. Add a comment explaining why, since the merge-commit parent semantics are easy to get wrong. --- .github/workflows/build-staged.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-staged.yml b/.github/workflows/build-staged.yml index 8d50850..769b4f9 100644 --- a/.github/workflows/build-staged.yml +++ b/.github/workflows/build-staged.yml @@ -73,8 +73,12 @@ jobs: echo "Commit message: $COMMIT_MESSAGE" # Detect changed files for auto-skip detection + # For pull_request events, GitHub Actions checks out a synthetic merge commit + # where HEAD^1 is the base (main) and HEAD^2 is the PR head. The PR's own + # changes are the diff from HEAD^1 to HEAD^2, NOT from HEAD^2 to HEAD + # (the latter only reflects changes that landed on base after the PR branched). if [[ "$EVENT_NAME" == "pull_request" ]]; then - CHANGED_FILES=$(git diff --name-only HEAD^2 HEAD 2>/dev/null || git diff --name-only HEAD^ HEAD 2>/dev/null || echo "") + CHANGED_FILES=$(git diff --name-only HEAD^1 HEAD^2 2>/dev/null || git diff --name-only HEAD^ HEAD 2>/dev/null || echo "") else CHANGED_FILES=$(git diff --name-only HEAD^ HEAD 2>/dev/null || echo "") fi From d060b0eda3dc64d3d400d1046238f628b5431daf Mon Sep 17 00:00:00 2001 From: Toshihiko SHIMOKAWA Date: Tue, 12 May 2026 09:25:51 +0900 Subject: [PATCH 2/2] Compare base to merge commit, not to PR head (#80) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per Copilot review: HEAD^1..HEAD^2 (base..PR head) can include base-side changes since the PR branched, surfacing them as PR-side deletions and misclassifying a docs-only PR as needing a build. Use HEAD^1..HEAD (base..merge) instead — this represents exactly what the PR contributes on top of the current base, and is what the build will actually be testing. Expand the comment to document both failure modes (the original HEAD^2..HEAD bug and the HEAD^1..HEAD^2 edge case) so future maintainers see why we picked this form. --- .github/workflows/build-staged.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-staged.yml b/.github/workflows/build-staged.yml index 769b4f9..49dc515 100644 --- a/.github/workflows/build-staged.yml +++ b/.github/workflows/build-staged.yml @@ -72,13 +72,19 @@ jobs: fi echo "Commit message: $COMMIT_MESSAGE" - # Detect changed files for auto-skip detection - # For pull_request events, GitHub Actions checks out a synthetic merge commit - # where HEAD^1 is the base (main) and HEAD^2 is the PR head. The PR's own - # changes are the diff from HEAD^1 to HEAD^2, NOT from HEAD^2 to HEAD - # (the latter only reflects changes that landed on base after the PR branched). + # Detect changed files for auto-skip detection. + # For pull_request events, GitHub Actions checks out a synthetic merge + # commit where HEAD^1 is the base (main) and HEAD^2 is the PR head. + # Diffing HEAD^1 against HEAD (the merge result) gives exactly what this + # PR would introduce on top of the current base; this avoids two failure + # modes of the previous logic: + # - HEAD^2..HEAD returned base-side changes since the PR branched, + # so non-doc PRs were misclassified as docs-only. + # - HEAD^1..HEAD^2 would, if main has advanced since the PR branched, + # surface those base-only changes as PR-side deletions and + # misclassify a docs-only PR as needing a build. if [[ "$EVENT_NAME" == "pull_request" ]]; then - CHANGED_FILES=$(git diff --name-only HEAD^1 HEAD^2 2>/dev/null || git diff --name-only HEAD^ HEAD 2>/dev/null || echo "") + CHANGED_FILES=$(git diff --name-only HEAD^1 HEAD 2>/dev/null || git diff --name-only HEAD^ HEAD 2>/dev/null || echo "") else CHANGED_FILES=$(git diff --name-only HEAD^ HEAD 2>/dev/null || echo "") fi