Skip to content

workflows/labels: fix merge conflict label#419836

Merged
wolfgangwalther merged 1 commit intoNixOS:masterfrom
wolfgangwalther:ci-label-fix-merge-conflict
Jun 25, 2025
Merged

workflows/labels: fix merge conflict label#419836
wolfgangwalther merged 1 commit intoNixOS:masterfrom
wolfgangwalther:ci-label-fix-merge-conflict

Conversation

@wolfgangwalther
Copy link
Contributor

The previous implementation had two problems:

  • When switching from /search to /pulls, we disabled the additional GET on each single pull request - which causes no test merge commit creation for all PRs. This means, merge conflicts will not actually be detected.
  • By using item in the pull-request triggered case, this goes back to context.payload.pull_request, which is the state at the beginning of the workflow run. But this renders our "let's wait 3 minutes before checking merge_commit_sha" logic void. While we wait for 3 minutes, we still use the old value afterwards...

Just making the extra request every time simplifies the logic and solves both problems.

Fixes #419654 (comment)

Things done


Add a 👍 reaction to pull requests you find important.

The previous implementation had two problems:
- When switching from /search to /pulls, we disabled the additional GET
on each single pull request - which causes no test merge commit creation
for all PRs. This means, merge conflicts will not actually be detected.
- By using `item` in the pull-request triggered case, this goes back to
`context.payload.pull_request`, which is the state *at the beginning* of
the workflow run. But this renders our "let's wait 3 minutes before
checking merge_commit_sha" logic void. While we wait for 3 minutes, we
still use the *old* value afterwards...

Just making the extra request every time simplifies the logic and solves
both problems.
@nix-owners nix-owners bot requested review from Mic92, philiptaron and zowoq June 25, 2025 10:32
@nixpkgs-ci nixpkgs-ci bot added 2.status: merge conflict This PR has merge conflicts with the target branch 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. 6.topic: continuous integration Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions 6.topic: policy discussion Discuss policies to work in and around Nixpkgs backport release-24.11 and removed 2.status: merge conflict This PR has merge conflicts with the target branch labels Jun 25, 2025
Copy link
Contributor

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix! Thanks

Comment on lines -144 to +141
const pull_request = item.head ? item : (await github.rest.pulls.get({
const pull_request = (await github.rest.pulls.get({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also fires off an extra request while iterating through the allPulls items.

  1. Does the github.rest.pulls.list request trigger creation of the merge commit, or do we still need a github.rest.pulls.get to do that?
  2. Is there a way to distinguish allPulls items from a pull_request context item?

If the answer to 1 is "listing PRs doesn't trigger a merge commit" then this is perfect.

If the answer is "listing PRs does trigger a merge commit, but there's no way to distinguish between allPulls items and an pull_request context item", then we should consider how we can refactor in a follow up PR.

Either way, this fixes the issue, so whether or not it is perfect in the allPulls case shouldn't block merging, assuming we have the headroom in our ratelimit (which we do).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the github.rest.pulls.list request trigger creation of the merge commit, or do we still need a github.rest.pulls.get to do that?

No, pulls.list does not create it. We need the extra get here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assuming we have the headroom in our ratelimit (which we do).

Yes, we do. I just checked, and we currently use ~ 6k/hour for labeling. So still another 6k available. Works out nicely with a lot of room for more.

@wolfgangwalther wolfgangwalther merged commit fb2c741 into NixOS:master Jun 25, 2025
49 of 52 checks passed
@wolfgangwalther wolfgangwalther deleted the ci-label-fix-merge-conflict branch June 25, 2025 11:01
@nixpkgs-ci

This comment was marked as resolved.

@nixpkgs-ci

This comment was marked as resolved.

@wolfgangwalther wolfgangwalther added the 8.has: port to stable This PR already has a backport to the stable release. label Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: continuous integration Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions 6.topic: policy discussion Discuss policies to work in and around Nixpkgs 8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants