From 7abad3786dbc58dad3f3aae3244ac3b8cab0fca9 Mon Sep 17 00:00:00 2001 From: Ryan Hughes Date: Sun, 27 Sep 2026 21:45:40 -0400 Subject: [PATCH] Plan PR builds from the PR's own files, not a diff to master's tip The planner took 'git diff base.sha head.sha', a two-dot diff between the current master tip and the PR head. For a PR that branched before later merges, that counts every package master has changed since, so the PR plans those too and builds its own stale copies of them: wasted builds, and 'already up to date' Pack failures that turn the PR red for packages it never touched. #397 (lazyjournal) planned 22 packages for a one-package change. The checkout is shallow, so ask GitHub for the PR's files, which are listed against the merge base. --- .github/workflows/build-pr.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 42c34aae..8825c829 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -95,8 +95,13 @@ jobs: if [[ -n "${{ github.event.inputs.packages }}" ]]; then names="${{ github.event.inputs.packages }}" else + # The PR's own files, as GitHub lists them against the merge base. + # A two-dot diff against the current base tip also counted every + # package master changed after the PR branched, so a stale PR + # planned dozens of unrelated packages at its old versions. The + # checkout here is shallow, so there is no merge base to diff from. # A package the PR deletes has nothing to build. - names=$(git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" -- pkgbuilds \ + names=$(gh api --paginate "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" --jq '.[].filename' \ | awk -F/ '$1=="pkgbuilds" && NF>2 {print $2}' | sort -u \ | while read -r name; do if git cat-file -e "${{ github.event.pull_request.head.sha }}:pkgbuilds/$name" 2>/dev/null; then echo "$name"; fi