Commit Graph

1344 Commits

Author SHA1 Message Date
Wolfgang Walther
295a031e24 Reapply "workflows/labels: manage stale & merge conflict labels"
This reverts commit c366efa6e2.

(cherry picked from commit 0edbbfc8bb)
2025-06-25 07:07:19 +00:00
Wolfgang Walther
a46e9b4393 workflows: nix: 2.29.0 -> 2.29.1
(cherry picked from commit ea10312659)
2025-06-24 16:46:17 +00:00
Wolfgang Walther
1e6f27590c workflows/labels: dynamically adjust reservoir to remaining rate limit
Instead of approximating how many requests we can still make and hoping
the best that concurrent jobs won't break the bank, we can just work
with the actual limits. By updating regularly, we make sure that
concurrent jobs are taken into account. We always keep a reserve of 1000
requests to make sure *any* non-labeling jobs using this app will always
succeed.

This will allow us to easily backfill labels across multiple days,
especially taking the increased rate limit for the app into account.
With this, we should get up to 11.5k requests per hour in.

(cherry picked from commit 24e7e47c91)
2025-06-24 07:03:15 +00:00
Wolfgang Walther
c37036b248 workflows/labels: run with app token
This gives us a much higher rate limit of 12.5k requests per hour. If
the app is not available, we fallback to the regular `github.token`.
This can happen when testing in forks without setting up an app.

(cherry picked from commit acc1c0ae59)
2025-06-24 07:03:15 +00:00
Wolfgang Walther
e9f22139fa workflows/{check,reviewers}: don't run on PRs from secondary development branches
It makes no sense to check cherry picks or request reviewers on PRs from
staging-next to master, the same on backbranches or for haskell-updates
into staging.

(cherry picked from commit a3ce5970e0)
2025-06-23 10:54:39 +00:00
Wolfgang Walther
9a42b59630 workflows/pr: refactor base/head branch decision making
Some jobs purposefully only run on certain base or head branches. By
centralizing the logic, parts of it can easily be re-used later. Also,
this gives them an explicit name and thus makes them easier to
understand.

(cherry picked from commit 7763be5a80)
2025-06-23 10:54:39 +00:00
Wolfgang Walther
5db160cb07 workflows: log rate limits consistently
This will give us a better idea about:
- Which jobs use the most API calls and can possibly be made more
efficient.
- Which rate limits apply exactly to which tokens.

(cherry picked from commit 356bf98a32)
2025-06-23 06:41:07 +00:00
Wolfgang Walther
29cc462120 workflows/labels: manage "first-time contribution" label
This is currently managed with yet another bot, but we don't need to -
this fits into our workflow nicely.

(cherry picked from commit 28f3b92403)
2025-06-22 16:37:36 +00:00
Wolfgang Walther
6346ef5210 workflows/labels: manage labels with a single API call
Instead of deleting each label separately and then making another call
to add new labels, this replaces all labels at once, thus saving API
calls in some cases. Also, the labels are now managed in object-style
compared to the array-style before. This allows putting all the
knowledge about each label into a single place instead of in multiple
places. For example, the rebuild labels had to be special cased in the
workflow before - and the nix code to compare had to match that. Also,
the approval labels had to be considered in the `before` and `after`
phases.

The next commit shows how easy it is to add a new label now.

(cherry picked from commit 5b5b18c875)
2025-06-22 16:37:36 +00:00
Wolfgang Walther
2c845463a4 workflows/eval: don't fail without artifact from target branch
This can only happen if the target branch's eval run failed and we're
trying to fix it. In this case, Eval should not fail, even though it
might not be able to do a comparison and add the correct rebuild labels.
But if we failed here, we wouldn't be able to merge the fix once we have
required status checks.

(cherry picked from commit 83ce9e7b44)
2025-06-21 19:34:46 +00:00
Wolfgang Walther
8e0587dd8f workflows/labels: fix on older PRs
When we made the switch from eval.yml to pr.yml we adjusted the labels
job as well - but didn't take into account that we also need to deal
with old PRs at the same time.

Here, we fallback to another API request to get a run for eval.yml when
we can't find one for pr.yml.

(cherry picked from commit d00d3190d6)
2025-06-21 11:39:31 +00:00
Wolfgang Walther
c67dc2d76d workflows/pr: run in pull_request context on changed labels.yml
When labels.yml is changed the new code is not tested in the PR
directly, yet, because we forgot to add labels.yml to the list of
pull_request files in pr.yml. This lead to one syntax error merged
already.

(cherry picked from commit 155ea15a38)
2025-06-21 11:39:31 +00:00
Wolfgang Walther
78399a24b4 workflows/labels: lower API calls reservoir to 500
First data shows, that we're unlikely to need more than 250 within an
hour of regular activity. Once this is empty, we'll need to wait until
the next hourly refill - thus, we'll rather set this a bit higher to be
on the safe side.

The hourly limit is at 5000 and we peaked around 3500, so far. We'll
certainly have to look into reducing API calls, but this should still
work out for now.

(cherry picked from commit 8e1f869261)
2025-06-21 11:39:30 +00:00
Wolfgang Walther
21584659f5 workflows/labels: fix race condition with throttling
When we switched to a scheduled workflow, we also changed these lines to
take the labels directly from the pull request list we iterate over. At
the time it saved us an API request. Meanwhile, we have introduced
throttling to the workflow and this causes a potential race condition:

When the scheduled or manually triggered workflow is kicked off and
empties its reservoir of API requests it might be blocked to wait up
to.. an hour! If this happens, the labels taken from the pull request
list might already be outdated at the time the workflow continues. This
would cause some labels to be reset to their original state, which could
be wrong if, for example, another push has happened in the meantime.

This will have a much bigger impact after the next commit, where *all*
labels are set every time, thus the `before` part must be accurate.

Fetching the current labels right before managing them reduces this risk
significantly.

(cherry picked from commit 9581b0c55b)
2025-06-21 11:39:30 +00:00
Wolfgang Walther
f03ee0db7b workflows/pr: add required job
This job serves as a target for the "Required Status Checks" branch
protection rule.

(cherry picked from commit caf4ced100)
2025-06-20 11:02:07 +00:00
Wolfgang Walther
ef60f61068 workflows/{labels,reviewers}: move from Eval to PR context
This allows *not* depending on those two jobs with the required status
checks in the next commit, which wouldn't really make sense. If labeling
or pinging maintainers fails for obscure reasons or because the GitHub
API is down, a PR might still pass all other tests and be
merge-eligible.

(cherry picked from commit 9927d758e7)
2025-06-20 11:02:07 +00:00
Wolfgang Walther
5d1d71680c workflows: sync merge commits
This fixes a problem where each workflow would get their own merge
commit. This happens frequently when the target branch is merged into a
the same time, different workflows in the same run will run
get-merge-commit at different times and thus have different merge
commits.

Since the jobs don't really depend on each other, this doesn't cause
practical problems, yet. But it has already led to strange CI failures
in a still unmerged PR, which can be prevented from happening with this
clean approach.

And yes, this saves a few API calls on every run.

(cherry picked from commit 09ddb1a8a0)
2025-06-20 11:02:07 +00:00
Wolfgang Walther
c517d38192 workflows/{pr,push}: move prepare job from eval workflow
This is only a refactor at this stage, but split into a separate commit
for better review. It's the base for the next two commits.

(cherry picked from commit 9422f30e47)
2025-06-20 11:02:06 +00:00
Wolfgang Walther
50fbaf8d2b workflows/eval: small improvements
Some naming improvements after we introduced the PR / Push workflows and
small refactors.

(cherry picked from commit 69ab2f4347)
2025-06-20 11:02:06 +00:00
Wolfgang Walther
b42a5dc87e workflows/labels: fix pull_request event trigger
When the job is run with the pull_request trigger for validation of
changes to the workflow itself, we need to run everything that can be
run without privileges - but not more.

We tried to do so for the three actions/labeler steps, but failed to set
up the condition correctly. We also need to exit early for our
JavaScript based labeler, just before making the mutation requests.

(cherry picked from commit 8ab44fec37)
2025-06-19 16:57:19 +00:00
Wolfgang Walther
e87d0742be workflows/eval: use consistent naming with the other 3 PR workflows
The overall idea is to use names short enough to fit into the status
checks list without shortening. This change mostly happened in the
commits before, here we just follow the same pattern for the remaining
workflows.

(cherry picked from commit c08b86e962)
2025-06-18 12:17:58 +00:00
Wolfgang Walther
1c1a5f9b8d workflows/eval: move eval-aliases back into eval
We previously moved this out of the main eval workflow to avoid running
it on push and/or undrafting the PR. The latter has been removed in the
meantime and the former can be checked with a simple condition. Thus we
move it back in, to make it part of the 4 main workflows, which will be
required before merge eventually.

(cherry picked from commit 008527d7cd)
2025-06-18 12:17:58 +00:00
Wolfgang Walther
9eb06853d9 workflows/{pr,push}: init
Those two workflows bundle all the main jobs in two event-specific
wrapper workflows. This enables us to do two things later on:
- Synchronize the merge commits between most of the jobs run in a PR.
- Create a single "required" job to be targeted by GitHub's "required
status checks to pass" feature.

(cherry picked from commit 959eed1f2a)
2025-06-18 12:17:58 +00:00
Matt Sturgeon
e3f742f97c workflows/labels: handle null reviewer
Review user can be null when the user has deleted their account since
posting the review.

Fixes #417627

(cherry picked from commit 2116e927da)
2025-06-17 20:27:04 +00:00
Wolfgang Walther
ed6c5a21b6 workflows/labels: add simple stats
To ease debugging rate-limiting issues.

(cherry picked from commit 4fe9129b78)
2025-06-17 13:57:21 +00:00
Wolfgang Walther
7d50d6a984 workflows/labels: improve logging for skipped PRs
Conditions that cause a PR to be skipped are now marked clearly in the
log output.

(cherry picked from commit f3b67f4eb5)
2025-06-17 13:57:21 +00:00
Wolfgang Walther
3f9e119795 workflows/labels: add bottleneck for throttling
This should prevent us from hitting API rate limits, even when we run
huge manual jobs. It just takes a bit longer.

(cherry picked from commit 114b4fcf48)
2025-06-17 13:57:21 +00:00
Wolfgang Walther
92359b8348 workflows/labels: log current API rate_limits
This will give us a little bit better insight into how close we're
running to the limits.

(cherry picked from commit 0e88d8a24d)
2025-06-17 13:57:20 +00:00
Wolfgang Walther
1f7f64b47b workflows/labels: run every 10 minutes
This will give us much quicker approval labeling, but still need much
less resources than before, when we ran on every PR comment.

(cherry picked from commit 656b53b0dd)
2025-06-17 08:56:38 +00:00
Wolfgang Walther
f7518d076e workflows/labels: disable scheduled runs in forks
This can still be manually dispatched for testing in forks, but it's
entirely useless to keep running it on schedule.

Also removing the "skip treewide" condition, which was a left-over and
removed everywhere else already. We don't want to skip any jobs,
especially not when considering required status checks.

(cherry picked from commit 075dc097a3)
2025-06-17 08:56:38 +00:00
Wolfgang Walther
bc401b0a78 workflows/labels: fix approved-by-maintainer label
Due to a type mismatch, maintainer approvals were never counted as such.
The API returns integers for the user IDs, but the JSON file has strings
as object keys.

(cherry picked from commit 25a0ee0817)
2025-06-17 08:56:38 +00:00
Wolfgang Walther
6fa32c3bdc workflows/labels: skip old PRs without the right artifacts
We don't need to handle the differently named artifacts in a special
way, because they have been expired anyway. But, we must handle the case
to not cause the job to fail.

(cherry picked from commit 5343c50acd)
2025-06-17 08:56:38 +00:00
Wolfgang Walther
53139a242f workflows/labels: improve logging
Printing the URL to the PR in the logs allows clicking on it directly in
the GitHub runner logs for easy reference.

(cherry picked from commit 022bbfd663)
2025-06-17 08:56:38 +00:00
Wolfgang Walther
5cdc540002 workflows/labels: add more error context
The original error is kept, but the PR number is printed as well. Makes
debugging much easier.

(cherry picked from commit 97130d08e1)
2025-06-16 17:08:27 +02:00
Wolfgang Walther
af2c8fa08f workflows/labels: save artifacts per PR
Previously, the artifacts of different PRs would overwrite each other,
thus leading to odd JSON parsing errors.

(cherry picked from commit 7efbed4cd7)
2025-06-16 17:08:27 +02:00
Wolfgang Walther
688246e553 workflows/labels: run to completion on error
This runs all PRs in scope to completion, before reporting errors.

(cherry picked from commit c12c91f465)
2025-06-16 17:08:21 +02:00
Wolfgang Walther
f8d1970c8e workflows/labels: fix first scheduled run
This would fail, because no previous workflow can be found.

(cherry picked from commit 4425979533)
2025-06-16 17:08:17 +02:00
Wolfgang Walther
3ec7829b84 workflows/labels: fix syntax error
(cherry picked from commit 2f3970c5d8)
2025-06-16 17:08:14 +02:00
Wolfgang Walther
aefa2d1d8b workflow/labels: save an API request
With the previous commit we now have the `before` labels available
already, which allows some simplification.

(cherry picked from commit 4d537009c6)
2025-06-16 12:25:06 +00:00
Wolfgang Walther
b17cc5ba4a workflow/labels: switch to a scheduled trigger
Instead of relying on workflow_run events, we now trigger the labeling
workflow by schedule. This avoids all permission/secrets problems of
running in the pull_request_review context - and also gets rid of the
"waiting for approval to run workflows" button for new contributors that
sometimes comes up right now.

Also, it's more efficient. Previously, the labeling workflow would run
on *any* pull_request_review event, which happens for all comments, too.
So quite a few runs.

This will cause a delay of up to 1 hour with the current settings until
approval labels are set. Depending on how long the job normally runs we
can adjust the frequency. The workflow is written in a way that will
work no matter what the frequency ends up being, even when it's
interrupted by transient GHA failures: It will always look at all PRs
which were updated since the last time the workflow ran successfully.

We also add the ability to run it manually via UI. This is useful:
- When fixing bugs in the labeler workflow to run it all the way back to
where the bug was introduced.
- When introducing new labels, to get a head start for a reasonable
amount of PRs immediately.

Of course, the workflow is also still run directly after Eval itself.
This is also the only case that the actions/labeler steps will run,
since they depend on the `pull_request` context.

(cherry picked from commit 6f12f662ae)
2025-06-16 12:25:06 +00:00
dependabot[bot]
14ff4bb5db build(deps): bump cachix/install-nix-action from 31.3.0 to 31.4.0
Bumps [cachix/install-nix-action](https://github.com/cachix/install-nix-action) from 31.3.0 to 31.4.0.
- [Release notes](https://github.com/cachix/install-nix-action/releases)
- [Changelog](https://github.com/cachix/install-nix-action/blob/master/RELEASE.md)
- [Commits](https://github.com/cachix/install-nix-action/compare/31.3.0...17fe5fb4a23ad6cbbe47d6b3f359611ad276644c)

---
updated-dependencies:
- dependency-name: cachix/install-nix-action
  dependency-version: 31.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
(cherry picked from commit 3b2e355ae3)
2025-06-15 10:44:13 +00:00
Wolfgang Walther
a37a28a4c7 ci/treefmt: add yamlfmt
Most workflow files are already well formatted, but to make it easier to
keep it that way, we can add yamlfmt.

I personally have a preference for non-indented arrays for YAML, but
wanted to avoid bigger diffs here - the status-quo clearly are indented
arrays.

Some changes are made manually to the get-merge-commit action and the
issue templates. Those would otherwise make yamlfmt misbehave on those.

(cherry picked from commit 8ec23df6f6)
2025-06-15 12:27:21 +02:00
Wolfgang Walther
23be6b9693 treewide: run yamlfmt
This applies changes from running yamlfmt with the `retain_line_breaks`
formatting option enabled.

(cherry picked from commit 66981875e8)
2025-06-15 12:27:17 +02:00
Wolfgang Walther
4f90e240fe workflows/labels: fix approval label with maintainers
This currently fails with:

```
Method Set.prototype.has called on incompatible receiver undefined
```

Seems like my syntax test previously only hit the case without
maintainers, in which case it doesn't throw :/.

(cherry picked from commit 4b9fb45060)
2025-06-14 19:19:20 +02:00
Wolfgang Walther
c6336fdae2 workflows/labels: count approving reviewers, not reviews
A single reviewer approving a Pull Request multiple times should only
count once.

(cherry picked from commit 2e03351248)
2025-06-14 16:35:46 +02:00
Wolfgang Walther
4aa51a994c workflows/{labels,reviewers}: fix concurrency groups for nested workflows
This didn't work as intended. When a workflow is run with
`workflow_call`, it will have `github.workflow` set to the *parent*
workflow. So the `caller` input that we passed, resulted in this
concurrency key:

```
Eval-Eval-...
```

But that's bad, because the labels and reviewers workflows will cancel
each other!

What we actually want is this:
- Label and Reviewers workflow should have different groups.
- Reviewers called via Eval and called directly via undraft should have
*different* groups.

We can't use the default condition we use everywhere else, because
`github.workflow` is the same for Label and Reviewers. Thus, we hardcode
the workflow's name as well. This essentially means we have this as a
key:

```
<name-of-running-workflow>-<name-of-triggering-workflow>-<name-of-event>-<name-of-head-branch>
```

This should do what we want.

Since workflows can be made reusable workflows later on, we add those
hardcoded names to *all* concurrency groups. This avoids copy&paste
errors later on.

(cherry picked from commit 6793e238fa)
2025-06-14 14:27:37 +02:00
Wolfgang Walther
93ecbedbae workflows: prevent accidental cancelling of other PRs
This can happen when two PRs run at the same time, which come from
different forks, but have the same head branch name.

github.head_ref is suggested by GitHub's docs, but.. that's not really
useful for cases with forks.

(cherry picked from commit 7ba7720b28)
2025-06-14 14:27:32 +02:00
Wolfgang Walther
cf25ce07e8 workflows/labels: manage approval labels
The category 12 labels for number of approvals and approved by package
maintainer are now automatically managed by the labels workflow. The
logic is slightly different from the "by: package-maintainer" label. For
approval, it's enough if *any one* maintainer approves the PR to have
the label added, even if the PR touches multiple packages.

The workflow only counts approved reviews, no matter whether there had
been a push in the meantime or not. To achieve the currently used logic
of "expiring approvals after push", we will have to set up a branch
protection rule, which actually dismissed those reviews automatically.

(cherry picked from commit 5f09e16f00)
2025-06-14 14:27:26 +02:00
Wolfgang Walther
1a19fa1454 workflows/labels: move labels logic from eval workflow
This moves the actual labeling from the eval workflow to the labels
workflow. At this stage, this only has a disadvantage: Adding the
topic-labels to the pull request will now only happen after eval has
finished, instead of instantly.

We will only benefit from this later, when we manage approval related
events. With this change, we will have the comparison results and thus
the package maintainer info available.

(cherry picked from commit 2d0bcd7165)
2025-06-14 14:27:25 +02:00
Wolfgang Walther
b7759aafd2 workflows/review-{dismissed,minimize}: init
This brings back the "minimize CI reviews after dismissal" job that was
previously removed. The first time around, we had a single job triggered
by the `pull_request_review` event. This lacks permission to do
meaningful stuff, though.

This time, we trigger an empty no-op job on `pull_request_review` and
then run a second workflow on `workflow_run`. This can run with the
proper permissions.

(cherry picked from commit a34a22d8b9)
2025-06-14 14:27:22 +02:00