From ad38aefddf45b79b4c9fb4fd883ddff30082e346 Mon Sep 17 00:00:00 2001 From: MK Date: Thu, 9 Jul 2026 20:29:34 +0800 Subject: [PATCH 1/2] fix(ci): compare native binary size against PR merge base The size gate diffed the PR head against the live tip of the base branch, so a branch merely behind on native-input changes already merged into the base branch would rebuild and post a size report it does not own (for example a docs-only PR forked before a dependency upgrade). Resolve the merge base and both compare and build against it, so the gate decision and the reported delta reflect only the PR's own changes. --- .github/workflows/vp-binary-size.yml | 45 +++++++++++++++++++--------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/.github/workflows/vp-binary-size.yml b/.github/workflows/vp-binary-size.yml index e0cc2dbaee..fed22885d3 100644 --- a/.github/workflows/vp-binary-size.yml +++ b/.github/workflows/vp-binary-size.yml @@ -23,39 +23,56 @@ jobs: contents: read outputs: changed: ${{ steps.compare.outputs.changed }} + base_sha: ${{ steps.merge_base.outputs.sha }} steps: - - name: Check out base + - name: Check out PR uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: - ref: ${{ github.event.pull_request.base.sha }} + ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 persist-credentials: false - - name: Compute base native input hash - id: base + # Compare against the PR's fork point (merge base), not the live tip of the + # base branch. Otherwise a branch that is merely behind on native-input + # changes already merged into the base branch would rebuild and report a + # delta it does not own (e.g. a docs-only PR forked before a deps upgrade). + - name: Resolve merge base + id: merge_base + env: + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + run: | + git fetch --no-tags --no-recurse-submodules origin "$BASE_SHA" + MERGE_BASE=$(git merge-base "$BASE_SHA" "$HEAD_SHA") + echo "sha=$MERGE_BASE" >> "$GITHUB_OUTPUT" + if git diff --quiet "$MERGE_BASE" "$HEAD_SHA" -- .github/workflows/vp-binary-size.yml; then + echo "workflow_changed=false" >> "$GITHUB_OUTPUT" + else + echo "workflow_changed=true" >> "$GITHUB_OUTPUT" + fi + + - name: Compute PR native input hash + id: head uses: ./.github/actions/compute-native-cache-input-hash - - name: Check out PR + - name: Check out merge base uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 + ref: ${{ steps.merge_base.outputs.sha }} persist-credentials: false - - name: Compute PR native input hash - id: head + - name: Compute merge-base native input hash + id: base uses: ./.github/actions/compute-native-cache-input-hash - name: Compare native inputs id: compare env: BASE_HASH: ${{ steps.base.outputs.hash }} - BASE_SHA: ${{ github.event.pull_request.base.sha }} HEAD_HASH: ${{ steps.head.outputs.hash }} - HEAD_SHA: ${{ github.event.pull_request.head.sha }} + WORKFLOW_CHANGED: ${{ steps.merge_base.outputs.workflow_changed }} run: | - if [[ "$BASE_HASH" != "$HEAD_HASH" ]] || - ! git diff --quiet "$BASE_SHA" "$HEAD_SHA" -- .github/workflows/vp-binary-size.yml; then + if [[ "$BASE_HASH" != "$HEAD_HASH" || "$WORKFLOW_CHANGED" == "true" ]]; then echo "changed=true" >> "$GITHUB_OUTPUT" else echo "changed=false" >> "$GITHUB_OUTPUT" @@ -95,7 +112,7 @@ jobs: steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: - ref: ${{ matrix.source == 'base' && github.event.pull_request.base.sha || github.event.pull_request.head.sha }} + ref: ${{ matrix.source == 'base' && needs.inputs.outputs.base_sha || github.event.pull_request.head.sha }} persist-credentials: false - uses: ./.github/actions/clone From 8854385da06c5cc90856d6aea6a1c6693b8c3960 Mon Sep 17 00:00:00 2001 From: MK Date: Fri, 10 Jul 2026 10:27:05 +0800 Subject: [PATCH 2/2] ci(binary-size): trim the merge-base gate Drop the explicit fetch of base.sha: checkout with fetch-depth 0 fetches every branch, so the extra fetch was a no-op round trip on each PR push. Fetch with filter blob:none: merge-base resolution needs commit ancestry, not historical blobs, cutting the gate checkout from ~28 MiB to ~10 MiB. Rename the base_sha output to merge_base_sha to distinguish it from pull_request.base.sha. --- .github/workflows/vp-binary-size.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/vp-binary-size.yml b/.github/workflows/vp-binary-size.yml index fed22885d3..bcf387e0dc 100644 --- a/.github/workflows/vp-binary-size.yml +++ b/.github/workflows/vp-binary-size.yml @@ -23,26 +23,29 @@ jobs: contents: read outputs: changed: ${{ steps.compare.outputs.changed }} - base_sha: ${{ steps.merge_base.outputs.sha }} + merge_base_sha: ${{ steps.merge_base.outputs.sha }} steps: - name: Check out PR uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: ref: ${{ github.event.pull_request.head.sha }} + # Full commit graph for merge-base resolution, but no historical + # blobs: the job only materializes the head and merge-base trees. fetch-depth: 0 + filter: blob:none persist-credentials: false - # Compare against the PR's fork point (merge base), not the live tip of the - # base branch. Otherwise a branch that is merely behind on native-input - # changes already merged into the base branch would rebuild and report a - # delta it does not own (e.g. a docs-only PR forked before a deps upgrade). + # Compare against the PR's fork point (merge base) rather than the live + # tip of the base branch: a branch that forked before a native-input + # change landed on the base branch would otherwise rebuild and report + # deltas from commits already on the base branch (e.g. a docs-only PR + # forked before a deps upgrade). - name: Resolve merge base id: merge_base env: BASE_SHA: ${{ github.event.pull_request.base.sha }} HEAD_SHA: ${{ github.event.pull_request.head.sha }} run: | - git fetch --no-tags --no-recurse-submodules origin "$BASE_SHA" MERGE_BASE=$(git merge-base "$BASE_SHA" "$HEAD_SHA") echo "sha=$MERGE_BASE" >> "$GITHUB_OUTPUT" if git diff --quiet "$MERGE_BASE" "$HEAD_SHA" -- .github/workflows/vp-binary-size.yml; then @@ -112,7 +115,7 @@ jobs: steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: - ref: ${{ matrix.source == 'base' && needs.inputs.outputs.base_sha || github.event.pull_request.head.sha }} + ref: ${{ matrix.source == 'base' && needs.inputs.outputs.merge_base_sha || github.event.pull_request.head.sha }} persist-credentials: false - uses: ./.github/actions/clone