Commit graph

19 commits

Author SHA1 Message Date
Wolfgang Walther f1b05962a0 ci/github-script/merge: switch order of merge operations
We previously used auto-merge first and then enqueued explicitly on the
assumption that auto-merge would fail if the PR was actually in
mergeable state already. This turned out to be false.

Instead, we currently face the problem of auto-merge sometimes getting
stuck. This seems to happen when, at the time of enabling auto-merge,
the required status checks already passed and the PR would be ready to
go - but sometimes GitHub doesn't do it. This *can* be unblocked by
approving the PR again, which seems to run the internal "let's check
whether we can merge this" procedures on the GitHub side again.

However, we can probably also solve this by just explicitly trying to
enqueue the PR first - and only if that fails, fall back to auto-merge.
I previously argued against that, based on a potential race condition,
in which a PR could become ready to merge between these two requests -
at which point the auto-merge operation would fail, if the original
assumption was true. But since we don't observe this, we might as well
switch.

(cherry picked from commit 747d9e2d34)
2025-11-04 19:58:24 +00:00
Wolfgang Walther bd7ba4ab6d
[Backport release-25.05] ci/github-script/merge: fix with deleted users (#458079) 2025-11-03 11:24:43 +00:00
Wolfgang Walther f995d2fe93 ci/github-script/merge: fix with deleted users
When a deleted user had approved a PR, this will cause the merge-bot to
fail.

(cherry picked from commit 43f3fcc555)
2025-11-03 11:20:15 +00:00
Wolfgang Walther 71e57d36a2 ci/github-script/merge: unify terms for authoring and creating PRs
I didn't like r-ryantm "authoring"; so I changed that to "created"
earlier. Arguably, using "opened" is more consistent with what is
actually checked and can consistently be used for both.

(cherry picked from commit 5407abeb7d)
2025-11-03 11:17:56 +00:00
Wolfgang Walther 3a33ae69b5 ci/github-script/merge: improve feedback for by-name check
The by-name check would previously be green when the
`pkgs/by-name/README.md` file was changed. This would still not mean the
maintainer was able to merge the PR, because there'd be no maintainer
for that file, but the feedback was not 100% accurate.

(cherry picked from commit e0c0b2c54c)
2025-11-03 11:17:56 +00:00
Wolfgang Walther 67ddeb175d workflows/bot: allow maintainer merges after committer approval
This allows committers to approve PRs with additional, optional nits
that the author-maintainer can either address or merge immediately
without these changes.

It also allows committers to approve a PR for merge, while still waiting
for other maintainers to give their feedback - they can then merge the
PR directly instead of passing it back to the committer.

(cherry picked from commit ffdc8205e5)
2025-11-02 19:08:04 +00:00
Wolfgang Walther f820412911 ci/github-script/merge: restructure head SHA check
While it was already the case that only merge comments *after* the
latest push were acted on, the logic wasn't easy to understand. This
change should make it more obvious, specially in combination with the
next commit, that all steps (comments, approvals, merge) must happen on
the same SHA - the current head SHA of the PR.

(cherry picked from commit 9a637aa7a4)
2025-11-02 19:08:03 +00:00
Wolfgang Walther 389507e2a4 workflows/bot: allow maintainers to merge backports
All other conditions equal, there is no reason to prevent maintainers
from backporting changes to their packages. Maintainers are probably in
the *best* position to tell whether a certain change is backportable or
not - because they know the package well.

(cherry picked from commit 91c4d9236b)
2025-11-02 18:15:49 +00:00
Wolfgang Walther c94fecbc7f ci/github-script/merge: support OR conditions
This supports AND on the first and OR on the second level, which is
needed for some follow up work like backports, approval based merges or
trusted maintainers.

(cherry picked from commit 84d6678f3b)
2025-11-02 15:46:03 +00:00
Wolfgang Walther 0adba5f539 ci/github-script/merge: add TODO about second merge method
We have not observed this merge method being used in practice, yet. Not
in the new bot, not in the old bot. It seems like auto-merge works for
all cases.

(cherry picked from commit 6848f93842)
2025-11-02 15:46:03 +00:00
Wolfgang Walther 9021c3eb99 ci/github-script/merge: improve wording
(cherry picked from commit db8f50b4de)
2025-11-02 15:46:03 +00:00
Wolfgang Walther 12ffae8a50 ci/github-script/merge: improve maintainer check
(cherry picked from commit 2d0a8791fe)
2025-11-02 15:46:03 +00:00
Wolfgang Walther 8c5df843a0 ci/github-script/merge: move all conditions into runChecklist
No special casing anymore, all conditions are in the same place. This
also has the benefit of hiding the "has maintainers eligible for merge"
condition from comments, because it is only really relevant for
labeling.

(cherry picked from commit 6a3c294f6f)
2025-11-02 15:46:03 +00:00
Wolfgang Walther 9f4078e539 ci/github-script/merge: move API requests out of runChecklist
This makes runChecklist mostly a pure function (except for logging) to
allow calling it repeatedly later.

(cherry picked from commit 7ea127c83a)
2025-11-02 15:46:02 +00:00
Wolfgang Walther ecb87ba66a ci/github-script/merge: improve caching of team members
This removes the need to `await` committers further down in the function
and allows re-using the cache for other teams later.

(cherry picked from commit c7766c637f)
2025-11-02 15:46:02 +00:00
Wolfgang Walther fec18fbbb5
workflows/bot: avoid access teams endpoints in Test workflow
We have no chance of getting a token that can request the team endpoints
in the pull_request context. This makes sense, because non-members of
the org are also not allowed to view the teams' memberships.

Thus, just fake an empty team - that's fine for the Test workflow.

(cherry picked from commit 421974863f)
2025-11-01 19:01:21 +01:00
Wolfgang Walther 2afe2597c2
workflows/bot: set "merge-bot eligible" label
This makes it more visible which PRs are merge-bot eligible, by setting
a label respectively.

(cherry picked from commit 00e7b934fb)
2025-11-01 18:50:12 +01:00
Wolfgang Walther 0e855ef962 workflows/bot: retry failed merges
By not keeping the node_id in the comments resulting from a failed
merge, these merges will be automatically retried.

(cherry picked from commit 89ace76ff1)
2025-11-01 15:02:00 +00:00
Wolfgang Walther 1479a94896 workflows/bot: migrate nixpkgs-merge-bot to GHA
Running the nixpkgs-merge-bot in GitHub Actions instead of a separate
workflow has multiple advantages:
- A much better development workflow, with improved testability.
- The ability to label PRs with a "merge-bot eligible" label from the
same codebase.
- Using more data for merge strategy decisions, for example the number
of rebuilds.

This commits re-implements most of the features from the current
nxipkgs-merge-bot directly in the bot workflow. Instead of reacting to
webhook events, this now runs on the regular 10 minute schedule. Some
merges might be delayed a few minutes, but that should not be a problem
in practice.

To give the user early feedback, there are additional workflows running
when a comment or review is posted. These react with "eyes" to make the
user aware that the comment has been recognized.

The only feature not taken over was the size check for files in the PR.
This kind of check is not really relevant for maintainer merges only -
if we want to prevent bigger files from making it into the tree, then we
need a generic CI check, which is out of scope for the merge-bot.

Other than that, everything should be implemented - any omissions are by
accident.

(cherry picked from commit eea09eb9d3)
2025-11-01 15:02:00 +00:00