From 76abec73e9b7c9fc73c659a4bb1f55c043bbef0d Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Wed, 22 Jan 2025 18:24:10 -0330 Subject: [PATCH] fix: Fix bundle size diffs Fix bundle size diffs that are included in `metamaskbot` comments and tracked historically in https://github.com/MetaMask/extension_bundlesize_stats The diffs were incorrect because the "merge base" commit was wrong. The merge base commit is the commit we're comparing the branch against. We were calculating this using `git merge-base origin/main HEAD`, which locally does give the correct answer. But in GitHub Actions, HEAD was not set to the tip of the branch. Instead it was a new comment generated during the checkout step, representing the target branch merged into the current branch. This resulted in the "merge base" always being the tip of `main` (at the time of this workflow run). This in turn resulted in the "bundle diff" including changes that were already made on `main` Fixes #29858. --- .github/workflows/publish-prerelease.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-prerelease.yml b/.github/workflows/publish-prerelease.yml index 496a61b88e4f..e307dd4b8b12 100644 --- a/.github/workflows/publish-prerelease.yml +++ b/.github/workflows/publish-prerelease.yml @@ -22,9 +22,10 @@ jobs: - name: Get merge base commit hash id: get-merge-base env: - BASE_REF: ${{ github.event.pull_request.base.ref }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} run: | - merge_base="$(git merge-base "origin/${BASE_REF}" HEAD)" + merge_base="$(git merge-base "${BASE_SHA}" "${HEAD_SHA}")" echo "MERGE_BASE=${merge_base}" >> "$GITHUB_OUTPUT" echo "Merge base is '${merge_base}'"