Commit Graph

588 Commits

Author SHA1 Message Date
Wolfgang Walther
e68b0aef13 ci/github-script/reviewers: improve "needs: reviewers" label
This should fix the bug where the "needs: reviewer" label was set too
early, just to be removed immediately, because reviewers were then
requested.
2025-11-05 21:59:02 +01:00
Wolfgang Walther
a23d0ab24c ci/github-script/bot: request reviewers
This migrates the bash code to request reviewers to github-script. This
will allow multiple nice improvements later on, but at this stage it's
mostly a reduction in code and complexity.
2025-11-05 21:58:56 +01:00
Wolfgang Walther
df6a9a739d ci/github-script/bot: disregard bot and ghost approvals
We technically counted bot approvals and approvals by deleted users for
the approval labels as well. The former don't exist, yet, but if they
were, I don't think we'd count them. The latter should arguably *not* be
counted, because we can't tell anymore *who* approved, so we can't put
any weight on it as reviewers.

This simplifies the logic, too.
2025-11-05 21:42:28 +01:00
Matt Sturgeon
ef3dca70a6 ci/treefmt: disable biome settings validation
The treefmt-nix `biome.settings` validation uses inputs that are liable
to hash mismatch.

See https://github.com/numtide/treefmt-nix/pull/430
2025-11-05 19:41:21 +01:00
Matt Sturgeon
7f7f879f92 Revert "ci/treefmt: disable biome for now"
This reverts commit 66260cc8c4.
2025-11-05 19:41:20 +01:00
Wolfgang Walther
2b819576cb ci/pinned: update
This gives us a bugfix in treefmt-nix for biome.

From the nixpkgs-unstable channel:
https://hydra.nixos.org/build/312625570#tabs-buildinputs

Changes for treefmt-nix:
f56b1934f5...4ef3dfdbb5
2025-11-05 19:41:18 +01:00
Matt Sturgeon
66260cc8c4 ci/treefmt: disable biome for now
Disable biome due to a hash mismatch with validation for the
`settings.formatter.biome.options` option.

See https://github.com/numtide/treefmt-nix/pull/430
2025-11-05 00:22:15 +00:00
Matt Sturgeon
ae90bb6238 Revert "wprkflows/bot: increase frequency to every 5 minutes" (#458570) 2025-11-04 20:16:42 +00:00
Wolfgang Walther
12c1f0253a ci/github-script/merge: improve merge operation and error messages (#458412) 2025-11-04 19:54:02 +00:00
Wolfgang Walther
1e6124a504 ci/github-script/merge: list eligible users in comment
When a user tries to merge a PR, but is not allowed to, it is helpful to
explicitly list the users who *are* allowed. This helps explaining *why*
the merge-eligible label was set.

I objected to this proposal before, because it would incur too many API
requests. But after we have restructured the checklist, this is not
actually true anymore - we can now sensibly run this only when a comment
is posted and not whenever we check a PR for eligibility.
2025-11-04 20:50:41 +01:00
Wolfgang Walther
74d6ba3ab4 Revert "wprkflows/bot: increase frequency to every 5 minutes"
This partially reverts commit 1197fe48da.

GitHub just doesn't schedule these narrow intervals. 10 minutes is
alright in practice.
2025-11-04 19:49:07 +01:00
Wolfgang Walther
58a1fe4761 ci/github-script/bot: move getTeamMembers cache into main file
This allows re-using this elsewhere with a shared cache.
2025-11-04 16:33:16 +01:00
Wolfgang Walther
1197fe48da wprkflows/bot: increase frequency to every 5 minutes
This makes reactions to merge comments and all the labeling a bit
quicker. Lower the number of backlog items to process per run
accordingly, so that we don't really need more API requests for it.
2025-11-04 16:13:41 +01:00
Wolfgang Walther
810b9ba51d ci/github-script/bot: improve parallelism
We used to employ the worst strategy for parallelism possibly: The rate
limiter capped us at one concurrent request per second, while 100+ items
were handled in parallel. This lead to every item taking the full
duration of the job to proceed, making the data fetched at the beginning
of the job stale at the end. This leads to smaller hiccups when
labeling, or to the merge-bot posting comments after the PR has already
been closed.

GitHub allows 100 concurrent requests, but considers it a best practice
to serialize them. Since serializing all of them causes problems for us,
we should try to go higher.

Since other jobs are running in parallel, we use a conservative value of
20 concurrent requests here. We also introduce the same number of
workers going through the list of items, to make sure that each item is
handled in the shortest time possible from start to finish, before
proceeding to the next. This gives us roughly 2.5 seconds per individual
item - but speeds up the overall execution of the scheduled job to 20-30
seconds from 3-4 minutes before.
2025-11-04 16:13:40 +01:00
Wolfgang Walther
2d6602908b ci/github-script/merge: improve testability
By only ignoring already-handled comments when running non-dry, it's
much easier to look at existing PRs, for which the merge bot already
commented, and iterate on them locally.

It's dry mode anyway, so it won't hurt to get a few more merge comments
in the console output.
2025-11-04 15:41:50 +01:00
Wolfgang Walther
747d9e2d34 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.
2025-11-04 10:06:36 +01:00
Wolfgang Walther
c768b4243e ci/github-script/bot: fix infinite labeling cycle
When we recently refactored the code to use the maintainer map for
related labels, we made a mistake: When a PR has no packages with
maintainers returned from eval, the label would internally be set to `0`
instead of `false`.

The code would then go on compare the before and after labels with
strict equality - and assume a difference, because `0 !== false`. Thus,
it seemed like new labels needed to be set, so the PUT request was
actually sent. Of course, the labels were actually the same - when
filtering the labels to be set, the `0` would also be treated as falsy,
so the label would not be set. This would result in no visible change in
the PR, but internall GitHub would replace the `updated_at` timestamp
for that PR - after all we replaced all labels.

Repeatedly updating *all* PRs we're looking at quickly causes problems,
because we are going to look at the same PRs *again* in the next cycle -
essentially causing infinite recursion. The bot became slower and slower
over time, because it had to process more and more PRs each run.

Simply casting this to a proper Boolean, should get us out of the mess
soon.
2025-11-03 19:28:43 +01:00
Wolfgang Walther
6ad16e0620 ci/github-script/merge: fix with deleted users (#458074) 2025-11-03 11:19:29 +00:00
Wolfgang Walther
43f3fcc555 ci/github-script/merge: fix with deleted users
When a deleted user had approved a PR, this will cause the merge-bot to
fail.
2025-11-03 12:17:19 +01:00
Wolfgang Walther
5407abeb7d 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.
2025-11-03 11:59:13 +01:00
Wolfgang Walther
e0c0b2c54c 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.
2025-11-03 11:59:08 +01:00
Michael Daniels
41a3c23cdc treewide: drop figsoda as maintainer (part 4)
These were done manually by me, either due to not matching the regexes in the previous ones, or because of nixf-diagnose, which I have as a pre-commit hook.
2025-11-02 20:16:11 -05:00
Wolfgang Walther
ffdc8205e5 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.
2025-11-02 19:35:33 +01:00
Wolfgang Walther
9a637aa7a4 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.
2025-11-02 19:35:32 +01:00
Wolfgang Walther
37b7773907 workflows/bot: allow maintainers to merge backports (#451324) 2025-11-02 18:11:52 +00:00
Wolfgang Walther
c0b6cc9387 ci/eval/compare: fix without owners
Even without relevant owners, the owners.txt file must be created,
otherwise the next job will fail.
2025-11-02 17:30:46 +01:00
Wolfgang Walther
91c4d9236b 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.
2025-11-02 17:26:01 +01:00
Wolfgang Walther
008ea3df2c ci/request-reviews: fix request-reviewers.sh
We recently moved some code around and forgot to adjust the log line
here.
2025-11-02 17:10:07 +01:00
Wolfgang Walther
99750f21e0 ci/github-script/merge: various improvements (#457652) 2025-11-02 15:42:18 +00:00
Wolfgang Walther
1774ef870d ci/request-reviews: untangle owner-related bash code (#457503) 2025-11-02 15:41:16 +00:00
Wolfgang Walther
84d6678f3b 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.
2025-11-02 16:36:14 +01:00
Wolfgang Walther
6848f93842 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.
2025-11-02 16:36:06 +01:00
Wolfgang Walther
db8f50b4de ci/github-script/merge: improve wording 2025-11-02 16:36:01 +01:00
Wolfgang Walther
2d0a8791fe ci/github-script/merge: improve maintainer check 2025-11-02 16:35:56 +01:00
Wolfgang Walther
6a3c294f6f 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.
2025-11-02 16:35:51 +01:00
Wolfgang Walther
7ea127c83a 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.
2025-11-02 16:35:48 +01:00
Wolfgang Walther
c7766c637f 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.
2025-11-02 16:35:16 +01:00
Matt Sturgeon
830653ddac ci/README: document nixpkgs-merge-bot
Based on the README on the old nixpkgs-merge-bot repo[1], but updated to
reflect the current reality.

[1]: https://github.com/NixOS/nixpkgs-merge-bot
2025-11-01 23:12:03 +00:00
Wolfgang Walther
1aa72502fb workflows/bot: fix permission in test workflow (#457575) 2025-11-01 17:57:59 +00:00
Wolfgang Walther
421974863f 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.
2025-11-01 18:49:22 +01:00
Wolfgang Walther
00e7b934fb workflows/bot: set "merge-bot eligible" label
This makes it more visible which PRs are merge-bot eligible, by setting
a label respectively.
2025-11-01 17:18:19 +01:00
Wolfgang Walther
89ace76ff1 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.
2025-11-01 15:54:53 +01:00
Wolfgang Walther
eea09eb9d3 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.
2025-11-01 15:54:51 +01:00
Wolfgang Walther
d78de15627 workflows/bot: rename from labels
This workflow / script is already doing more than must labeling: it's
already auto-closing package request issues.

Since we're going to migrate the nixpkgs-merge-bot into this workflow,
we'll rename things to a more generic name.
2025-11-01 15:24:09 +01:00
Wolfgang Walther
3bef0dcf65 ci/request-reviews: move get-code-owners to eval/compare
This moves the parsing of ci/OWNERS into the Nix sandbox. We also get
rid of checking out the nixpkgs repo another time in the reviewers
workflow - we already have everything we need in the eval/compare job.

The creation of owners.txt in this way is only temporary, it should
eventually be moved further, similar to how maintainers.json is
currently migrating to a maintainer map for the whole repo stored on the
target branch as artifact.
2025-11-01 15:02:23 +01:00
Wolfgang Walther
18ab6b721e ci/request-reviews: move gh api calls out of get-code-owners
All the github related logic is now bundled in `request-reviewers.sh`.
This allows moving the `get-code-owners.sh` file into the eval/compare
step in the next commit.
2025-11-01 14:13:57 +01:00
Wolfgang Walther
d177d6057d ci/request-reviews: move git calls out of get-code-owners
This is just a refactor, no functional change. It is a preparation for a
future change, where `get-code-owners.sh` can be moved entirely into
eval/compare. This can only happen once we removed the remaining `gh
api` calls from it.
2025-11-01 13:44:26 +01:00
Wolfgang Walther
b2d1946eb2 workflows/reviewers: request owners and maintainers at once
Instead of requesting owners and maintainer separately, each with their
own limit of 10 review requests, we now run this together. This unties
the logic and allows easier refactoring. Also, it gives us a consistent
threshold of when not to request reviews anymore, which I set to 15.
Before, this could have been anything between 10 and 20, depending on
how the reviewers distributed over owners and maintainers.
2025-11-01 13:44:23 +01:00
Wolfgang Walther
cb6d78b076 ci/OWNERS: Add adisbladis as owner for stdenv/check-meta & stdenv/meta-types (#457525) 2025-11-01 12:25:20 +00:00
Wolfgang Walther
f66a380ea3 workflows/pr: rename to pull-request-target
To be able to disable the pr.yml workflow on GitHub, we need to rename
it to a different name. Let's use the long name for consistency with
merge-group.yml. This only affects the GitHub-internal name, not the
visible name in the PR checklist, which is still "PR". This visible name
is also used by nixpkgs-review, so that won't break.
2025-11-01 12:59:21 +01:00