codecov / codecov-javascript-bundler-plugins

Set of bundler plugins that allow users to upload bundle stats to Codecov.
MIT License
4 stars 1 forks source link

fix: update github merge commit matcher #131

Closed Zxilly closed 1 month ago

Zxilly commented 1 month ago

Description

GitHub updates their merge commit format, so we have to update the matcher.

Some examples:

https://app.codecov.io/gh/Zxilly/go-size-analyzer/pull/42/commits https://github.com/Zxilly/go-size-analyzer/commit/484cc3ea411dcc1da9e9b68a1c6485a83a99689c

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Zxilly commented 1 month ago

@nicholas-codecov plz review as it will make any coverage comparison in the pull request failed to find the base.

Zxilly commented 1 month ago

I'm sure I've mixed up a few things and I'll do further investigation into this bug.

nicholas-codecov commented 1 month ago

Hey @Zxilly, thanks for taking a peak at this, yea we've ran into some interesting issues with this. The current logic matches that of our CLI and we're checking the same thing. It seems to be working alright for us at Codecov, but for others it's not as happy, and I haven't figured out why. LMK if you find anything out, I'm happy to help out!

Zxilly commented 1 month ago

I can describe the current workaround i use.

First, checkout with

- uses: actions/checkout@v4
  with:
    fetch-depth: 0
    ref: ${{ github.head_ref }}

then, get the commit sha with git rev-parse HEAD then override the upload.

In face, this value can be viewed as github.event.head.sha in the github actions context of a pull request. But it can not be read directly from js code.

Zxilly commented 1 month ago

For me https://github.com/Zxilly/go-size-analyzer/blob/master/.github/workflows/build-ui.yml the codecov always try to upload the sha of the ghost merge commit in the pull request without the workaround described above.

nicholas-codecov commented 1 month ago

Interesting ... I'm currently working on some debug logging so we can better check the sha's we have access to and go from there

nicholas-codecov commented 1 month ago

Hey @Zxilly,

I've done some more digging and found that the issue seems to be around the fetch depth of the checkout step not being set to 0 or > 1. We played around with this and it resolved the issue, another alternative is to grab it from GH context and pass through as an env var, and then set it as an upload override value like so:

// GHA workflow yaml
env:
  GH_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}

Bundle analysis config:

uploadOverrides: {
  sha: process.env.GH_COMMIT_SHA,
},