Skip to content

Commit 70f6f14

Browse files
committed
ci(native-pipeline): scope PRs from the base merge-base, not just HEAD~1
The scope job checked out with fetch-depth: 2 and passed github.event.before -- which is empty on pull_request events -- so the script fell back to `git diff HEAD~1`, scoping a multi-commit PR off only its last commit (widgets changed in earlier commits were silently dropped from build + test). Check out full history (fetch-depth: 0) and pass the PR base SHA (github.event.pull_request.base.sha); the script now diffs against the merge-base with the base branch, covering every commit in the PR. Kept the per-widget classifier and the dispatch path unchanged -- no new third-party action needed.
1 parent 43fb87b commit 70f6f14

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

.github/scripts/determine-widget-scope.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,19 @@ to_json_array() {
2828
}
2929

3030
if [ "$event_name" == "pull_request" ]; then
31+
# Diff against the MERGE-BASE with the PR base branch so every commit in the PR is
32+
# considered, not just the latest. `before_commit` is the PR base SHA
33+
# (github.event.pull_request.base.sha); the merge-base is where the PR branched off.
34+
# Requires full history — the scope job checks out with fetch-depth: 0.
35+
diff_base=""
3136
if git cat-file -e "$before_commit" 2>/dev/null; then
32-
changed_files=$(git diff --name-only "$before_commit" "$current_commit")
37+
diff_base=$(git merge-base "$before_commit" "$current_commit" 2>/dev/null || echo "$before_commit")
38+
fi
39+
if [ -n "$diff_base" ]; then
40+
echo "Diffing against PR merge-base: $diff_base"
41+
changed_files=$(git diff --name-only "$diff_base" "$current_commit")
3342
else
34-
echo "Previous commit not found, using HEAD~1 as fallback"
43+
echo "PR base commit unavailable, using HEAD~1 as fallback"
3544
changed_files=$(git diff --name-only HEAD~1 "$current_commit")
3645
fi
3746

.github/workflows/NativePipeline.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,15 @@ jobs:
120120
- name: "Check out code"
121121
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
122122
with:
123-
fetch-depth: 2 # Fetch the latest two commits and its parent commit
123+
# Full history so the scope script can diff against the PR base merge-base
124+
# (covers every commit in the PR, not just the latest).
125+
fetch-depth: 0
124126
- name: "Determine scope"
125127
id: scope
128+
# Pass the PR base SHA (empty on non-PR events → the script's dispatch path handles it).
126129
run: |
127130
chmod +x ./.github/scripts/determine-widget-scope.sh
128-
./.github/scripts/determine-widget-scope.sh "${{ github.event_name }}" "${{ github.event.inputs.workspace }}" "${{ github.event.before }}" "${{ github.sha }}"
131+
./.github/scripts/determine-widget-scope.sh "${{ github.event_name }}" "${{ github.event.inputs.workspace }}" "${{ github.event.pull_request.base.sha || github.event.before }}" "${{ github.sha }}"
129132
- name: "Debug Scope Output"
130133
run: |
131134
echo "Scope is: ${{ steps.scope.outputs.scope }}"

0 commit comments

Comments
 (0)