Commit graph

38 commits

Author SHA1 Message Date
Silvan Mosberger
55faf59a25 ci: Fix team review requests from the bot
https://github.com/NixOS/nixpkgs/actions/runs/21782693200/job/62849125010
2026-02-07 17:34:25 +01:00
Silvan Mosberger
b0b2c24be9 ci: First-class team package maintainer review requests
Co-Authored-By: Alexander Bantyev <alexander.bantyev@tweag.io>
2026-02-07 13:52:46 +01:00
Michael Daniels
0d74c65927
Revert "ci: First-class team package maintainer review requests"
This reverts commit 193deb8533.
2026-02-05 21:50:27 -05:00
Philip Taron
ba626b8a60
First-class GitHub team reviews (#456481) 2026-02-06 01:44:31 +00:00
Silvan Mosberger
193deb8533 ci: First-class team package maintainer review requests
Co-Authored-By: Alexander Bantyev <alexander.bantyev@tweag.io>
2026-02-05 14:52:47 +01:00
Michael Daniels
31876b4580
ci/github-script/bot: refine regexes 2026-01-25 20:19:18 -05:00
Michael Daniels
c717c98bc8
ci/github-script/bot: only look at commit subject when deciding if a package is new/updated 2026-01-25 16:11:24 -05:00
Aliaksandr
bf5645a0ed
ci(bot): auto-label package updates with '8.has: package (update)'
Checks all PR commit messages for version update pattern
like 'packagename: X.Y.Z -> A.B.C'.

Matches: 1.2.3, 0-unstable-2024-01-15, 1.3rc1, alpha, unstable
2026-01-24 01:15:36 +02:00
Aliaksandr
bb0ec76b44
ci(bot): auto-label new package PRs with '8.has: package (new)'
Checks all PR commit messages for ': init at' pattern and
requires eval to report added packages (attrdiff.added).
2026-01-24 01:15:35 +02:00
Aliaksandr
033eccc028
ci(bot): add fork compatibility for team lookups
Forks don't have NixOS teams, return empty list to avoid 404.
2026-01-24 01:15:35 +02:00
Aliaksandr
0557411308
ci(bot): add fork compatibility for maintainer map
In forks without merge-group history, return empty maintainer
map instead of throwing an error.
2026-01-24 01:15:35 +02:00
Matt Sturgeon
5c558b976c
ci/github-script/bot: handle deleted maintainer accounts gracefully (#481949) 2026-01-20 22:11:58 +00:00
Emily
742b1081c5 Revert "ci/github-script/bot: skip mergeability checks temporarily"
Apparently any effects from this change haven’t shown up noticeably
in GitHub’s metrics, to the point where they’re not sure if it
was taking effect on the backend. Our contact is going to look at
getting something into the API response to help debug whether it’s
actually working or not, but agreed that we should just revert for
now. Since they have apparently reduced replica sync issues further
through other changes on their end, there shouldn’t be any urgent
need to make any changes here anyway.

This reverts commit 18b30c8ce1.
2026-01-20 16:19:16 +00:00
Philip Taron
e6e6c544ae
ci/github-script/bot: handle deleted maintainer accounts gracefully
When a maintainer deletes their GitHub account, the bot would crash with a 404 error when trying to fetch their user info via `/user/{id}`.

This caused the scheduled bot workflow to fail repeatedly until manual intervention (e.g., closing/reopening the affected PR to clear the requested reviewer).

Fix by returning null from getUser() for 404 responses and filtering out null users when building the reviewers list.
2026-01-20 06:27:34 -08:00
Emily
18b30c8ce1 ci/github-script/bot: skip mergeability checks temporarily
This is an experiment and can be reverted a few days from now; if
the results are positive on GitHub’s end, then we may want to make
the merge conflict checks run less frequently than the rest of the
labelling tasks.
2025-12-15 17:40:03 +00:00
Michael Daniels
74c008760e
ci/github-script/bot: don't attempt to fetch pagination cursor if it's expired
I fixed this for the maintainer maps, but the artifact that was causing the
particular issue that prompted me to try to fix it was actually the
pagination cursor. So fix that too.

Related: #464046.
2025-11-22 15:36:38 -05:00
Michael Daniels
040aeda1e7
ci/github-script/bot: log author of pull request
Should help debug "Review cannot be requested from pull request author."
in https://github.com/NixOS/nixpkgs/actions/runs/19591357890/job/56110301046#step:6:4726.
2025-11-22 11:54:25 -05:00
Michael Daniels
ce3d550556
ci/github-script/bot: skip expired artifacts
Should prevent "Unhandled error: HttpError: Artifact has expired", as was
present in e.g. https://github.com/NixOS/nixpkgs/actions/runs/19594659032.
2025-11-22 11:39:10 -05:00
Wolfgang Walther
28a32416fb
Revert "ci/github-script/labels: close empty PRs"
This reverts commit 402b41c125.

GitHub' API repeatedly returns wrong data which causes closed PRs when
the changes had not been merged, yet.

We have closed a bit more than 100 PRs overall, most of them initially -
the feature is not really that important overall.
2025-11-18 09:20:08 +01:00
Wolfgang Walther
d767570291
ci/github-script/bot: skip PR checks when stale
It makes not much sense to run all the checks for PRs when we can
already tell they are stale beforehand. In particular this should avoid
creating ~3.3k temporary merge commits every day, for PRs that surely
won't have had any change.

The number of merge commits *could* play a role in the growing size of
the fork network. We'll have GitHub look into the metrics before and
after this change to see whether that is any improvement.
2025-11-17 20:48:02 +01:00
Diogo Correia
eb8cfea79d
ci: fix "needs: reviewer" label being removed after self review 2025-11-09 13:30:50 +00:00
Wolfgang Walther
a146035a2b
ci/github-script/bot: fix concurrency limit
This was introduced as part of the hotfix PR to avoid hitting API rate
limits - but the condition was wrong. It was supposed to trigger in all
PR contexts, not only for the Test workflow.
2025-11-06 17:46:56 +01:00
Wolfgang Walther
cd7f83638e
ci/github-script/bot: limit concurrency in PR runs
This lead to reaching secondary API limits in a treewide recently, so we
better limit it to where we actually need it.
2025-11-06 16:17:22 +01:00
Wolfgang Walther
c4548e58fb
ci/github-script/bot: fix scheduled bot with older artifacts
We only recently introduced the owners.txt file to the comparison
artifact, so once the bot runs on a schedule it will it older artifacts
very quickly - and then can't find the owners file.

We can fallback to an empty owners list in this case, because an older
artifact also means an older workflow run previously, so this will have
pinged owners already.
2025-11-06 09:53:29 +01:00
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
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
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
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
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
Renamed from ci/github-script/labels.js (Browse further)