backstage / community-plugins

Community plugins for Backstage
Apache License 2.0
157 stars 196 forks source link

šŸ”§ Repository: Error: Command 'git diff --name-only origin/main...' failed with code 128 #732

Open awanlin opened 3 months ago

awanlin commented 3 months ago

šŸ“œ Description

We are currently seeing the following error when the CI starts for PR:

fatal: origin/main...HEAD: no merge base
Error: Command 'git diff --name-only origin/main...' failed with code 128
    at runPlain (file:///home/runner/work/community-plugins/community-plugins/scripts/ci/list-workspaces-with-changes.js:26:[11](https://github.com/backstage/community-plugins/actions/runs/10095240140/job/27914902436?pr=730#step:6:12))
    at async main (file:///home/runner/work/community-plugins/community-plugins/scripts/ci/list-workspaces-with-changes.js:42:7)

The current workaround is to close the PR, wait 10 seconds, and then open it again.

šŸ‘ Expected behavior

There should be no error and the CI moves forward as expected

šŸ‘Ž Current Behavior

The CI doesn't start and fails with this error:

fatal: origin/main...HEAD: no merge base
Error: Command 'git diff --name-only origin/main...' failed with code 128
    at runPlain (file:///home/runner/work/community-plugins/community-plugins/scripts/ci/list-workspaces-with-changes.js:26:[11](https://github.com/backstage/community-plugins/actions/runs/10095240140/job/27914902436?pr=730#step:6:12))
    at async main (file:///home/runner/work/community-plugins/community-plugins/scripts/ci/list-workspaces-with-changes.js:42:7)

šŸ‘Ÿ Reproduction steps

Not really sure hot to reproduce right now, it's a bit random but seem more frequent recently.

šŸ“ƒ Provide the context for the Bug.

This blocks PR and is confusion for Contributors as it's not related to their changes

šŸ‘€ Have you spent some time to check if this bug has been raised before?

šŸ¢ Have you read the Code of Conduct?

Are you willing to submit PR?

No, but I'm happy to collaborate on a PR with someone else

awanlin commented 3 months ago

We think this might be related to the sha being passed in has changed, there might be other options for this.

nickboldt commented 3 months ago

To be clear on the code that's causing the problem... is it this?

https://github.com/backstage/community-plugins/blob/main/.github/workflows/pr.yml#L26 -> https://github.com/backstage/actions/tree/main/pr-sync

Or this?

https://github.com/backstage/community-plugins/blob/main/scripts/ci/list-workspaces-with-changes.js ?

Pike commented 3 months ago

I suspect the problem here is the fetch-depth in https://github.com/backstage/community-plugins/blob/3e04330a2aee795e6286fa19266bfbf7e09cd466/.github/workflows/ci.yml#L31, paired with the fetch-depth of 1 on the main branch.

Which means that commits between main and the merge base are missing, I guess.

Setting the fetch-depth to something reasonable might make this happen less often, or just get the full commit history of main to be safe?

awanlin commented 2 months ago

Will try some of these ideas this Friday! Many thanks šŸš€

awanlin commented 2 months ago

My brain wasn't working on Friday, but I really wanted to get something in place for this. I took @pike's suggestion and ran with that in #875.

awanlin commented 2 months ago

I've merged the temporary fix for this but we should still revisit with a proper long term solution. There might be a solution in what was suggested here: https://github.com/backstage/community-plugins/pull/875#issuecomment-2296941087

Pike commented 3 weeks ago

Taking a stab at this in #1522 . Given each iterations takes approvals, maybe that's not the best first-pr?