811 Commits

Author SHA1 Message Date
Wolfgang Walther
155ea15a38 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.
2025-06-21 13:08:46 +02:00
Wolfgang Walther
8e1f869261 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.
2025-06-21 13:08:41 +02:00
Wolfgang Walther
9581b0c55b 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.
2025-06-21 13:08:38 +02:00
Wolfgang Walther
83ce9e7b44 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.
2025-06-20 21:19:44 +02:00
Wolfgang Walther
caf4ced100 workflows/pr: add required job
This job serves as a target for the "Required Status Checks" branch
protection rule.
2025-06-20 09:22:58 +02:00
Wolfgang Walther
9927d758e7 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.
2025-06-20 09:22:53 +02:00
Wolfgang Walther
09ddb1a8a0 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.
2025-06-20 09:22:48 +02:00
Wolfgang Walther
9422f30e47 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.
2025-06-20 09:22:42 +02:00
Wolfgang Walther
69ab2f4347 workflows/eval: small improvements
Some naming improvements after we introduced the PR / Push workflows and
small refactors.
2025-06-20 09:22:39 +02:00
Wolfgang Walther
8ab44fec37 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.
2025-06-19 11:54:47 +02:00
Wolfgang Walther
d8332aa3b7 workflows/{pr,push}: init (#415006) 2025-06-18 12:16:55 +00:00
Wolfgang Walther
c08b86e962 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.
2025-06-17 22:38:10 +02:00
Wolfgang Walther
008527d7cd 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.
2025-06-17 22:38:09 +02:00
Wolfgang Walther
959eed1f2a 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.
2025-06-17 22:38:09 +02:00
Matt Sturgeon
2116e927da workflows/labels: handle null reviewer
Review user can be null when the user has deleted their account since
posting the review.

Fixes #417627
2025-06-17 21:04:44 +01:00
Wolfgang Walther
4fe9129b78 workflows/labels: add simple stats
To ease debugging rate-limiting issues.
2025-06-17 15:46:34 +02:00
Wolfgang Walther
f3b67f4eb5 workflows/labels: improve logging for skipped PRs
Conditions that cause a PR to be skipped are now marked clearly in the
log output.
2025-06-17 14:53:54 +02:00
Wolfgang Walther
114b4fcf48 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.
2025-06-17 14:53:32 +02:00
Wolfgang Walther
0e88d8a24d 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.
2025-06-17 14:53:31 +02:00
Wolfgang Walther
656b53b0dd 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.
2025-06-17 09:50:07 +02:00
Wolfgang Walther
075dc097a3 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.
2025-06-17 09:48:54 +02:00
Wolfgang Walther
25a0ee0817 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.
2025-06-17 09:44:16 +02:00
Wolfgang Walther
5343c50acd 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.
2025-06-17 09:18:27 +02:00
Wolfgang Walther
022bbfd663 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.
2025-06-17 09:17:13 +02:00
Wolfgang Walther
97130d08e1 workflows/labels: add more error context
The original error is kept, but the PR number is printed as well. Makes
debugging much easier.
2025-06-16 17:00:01 +02:00
Wolfgang Walther
7efbed4cd7 workflows/labels: save artifacts per PR
Previously, the artifacts of different PRs would overwrite each other,
thus leading to odd JSON parsing errors.
2025-06-16 16:12:06 +02:00
Wolfgang Walther
c12c91f465 workflows/labels: run to completion on error
This runs all PRs in scope to completion, before reporting errors.
2025-06-16 16:08:02 +02:00
Wolfgang Walther
4425979533 workflows/labels: fix first scheduled run
This would fail, because no previous workflow can be found.
2025-06-16 15:55:40 +02:00
Wolfgang Walther
2f3970c5d8 workflows/labels: fix syntax error 2025-06-16 14:44:30 +02:00
Philip Taron
5bd9bdc637 workflow/labels: switch to a scheduled trigger (#416808) 2025-06-16 05:24:03 -07:00
Wolfgang Walther
4d537009c6 workflow/labels: save an API request
With the previous commit we now have the `before` labels available
already, which allows some simplification.
2025-06-16 09:30:48 +02:00
Wolfgang Walther
6f12f662ae 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.
2025-06-16 09:30:44 +02:00
Wolfgang Walther
3cd1a863ee build(deps): bump cachix/install-nix-action from 31.3.0 to 31.4.0 (#416918) 2025-06-15 10:43:18 +00:00
Wolfgang Walther
41b092c90c ci/workflows: run yamlfmt
Introduced after the yamlfmt PR was written.
2025-06-15 12:13:09 +02:00
dependabot[bot]
3b2e355ae3 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>
2025-06-15 10:11:02 +00:00
Wolfgang Walther
8ba5040b9c ci/treefmt: add yamlfmt (#416115) 2025-06-15 10:10:02 +00:00
Wolfgang Walther
4b9fb45060 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 :/.
2025-06-14 18:47:45 +02:00
Wolfgang Walther
2e03351248 workflows/labels: count approving reviewers, not reviews
A single reviewer approving a Pull Request multiple times should only
count once.
2025-06-14 14:48:59 +02:00
Wolfgang Walther
6793e238fa 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.
2025-06-13 17:31:27 +02:00
Wolfgang Walther
7ba7720b28 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.
2025-06-13 17:00:31 +02:00
Wolfgang Walther
67adad267c workflows/labels: manage approval labels (#415259) 2025-06-13 10:14:40 +00:00
Jörg Thalheim
088a69e0f4 workflows/build: build all the basics in a single workflow (#416368) 2025-06-13 11:33:29 +02:00
Jörg Thalheim
dbcae2bbb0 workflows/check: run "checks" in one workflow (#416369) 2025-06-13 11:31:57 +02:00
Wolfgang Walther
f11b58a7a0 workflows/check: run "checks" in one workflow
This introduces "check" as another category of jobs suitable for the
"Require status checks to pass" feature.

Checks as a category would include everything that is done before even
looking at the code: Right branch? Commit messages? Cherry-picked
correctly?

(commit messages are not checked, yet)
2025-06-13 09:20:14 +02:00
Wolfgang Walther
cd82aa54f5 workflows/build: build all the basics in a single workflow
This new workflow builds both manuals, the shell and the lib tests all
in a matrix of four jobs. This allows re-using the shared checkout and
the pinned nixpkgs download and saves time in the most likely cache: No
changes, just download from cache. Each step checks the cancelled
condition, which causes it to run even if the previous steps failed.
This way we get a full picture even if the first step fails immediately.

This could later be optimized to build more in parallel as well, but
we'll first need to clear the conditions on building the manuals on the
master branch only.

This reduces the number of jobs from up to 8 to 4 for this part.
2025-06-13 09:19:17 +02:00
Wolfgang Walther
540fd4e30f workflows: run without condition on changed paths
To enable *required status checks / workflows* in the future, we'd like
to run all workflows unconditionally. Since those workflows are already
using cachix, the additional runs will be very cheap. Yes, we'll run
additional jobs, but that will be temporary only, see next commits.

The immediate upside is, that we're not going to accidentally miss some
of the paths that would cause rebuilds as we did in the past.
2025-06-13 09:18:54 +02:00
Wolfgang Walther
7de0345556 workflows/lint: run all the static lints in same workflow
They still run in separate jobs, but they give us a nice consistent
appearance in the check list: All of them are starting with "Lint /
...".
2025-06-13 09:18:11 +02:00
Wolfgang Walther
66981875e8 treewide: run yamlfmt
This applies changes from running yamlfmt with the `retain_line_breaks`
formatting option enabled.
2025-06-12 14:46:42 +02:00
Wolfgang Walther
2b1c99db41 workflows/reviewers: actually ping maintainers when undrafting (#415680) 2025-06-11 07:24:41 +00:00
Wolfgang Walther
5f09e16f00 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.
2025-06-10 22:15:29 +02:00