Commit Graph

84 Commits

Author SHA1 Message Date
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
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
98d2a5f4c0 workflows: use bash shell explicitly
This forces better error handling as described in [1].

Without this change, bash would *not* run with `-o pipefail`, which
means some errors go unnoticed. By naming `bash` explicitly, `-o
pipefail` is enabled.

1:
https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#defaultsrunshell
(cherry picked from commit 0f5e504f9e)
2025-06-13 12:00:46 +02:00
Wolfgang Walther
f8340acd43 workflows: cancel running jobs on pull request updates
We can avoid running old jobs to completion, when pushing changes to a
pull request. This is done via concurrency groups. We set them on the
workflow level, with the following keys in the group name:
- `github.workflow` to only cancel / block the same workflow.
- `github.event_name` to avoid blocking between pull_request and
pull_request_target.
- `github.head_ref` which is unique for a PR, but the same when changing
it. This will cause PRs to cancel in progress jobs. Unset on pushes to
master & co.
- `github.run_id` as fallback for push events. In this case, the run_id
is unique for every push, thus *no* cancelling happens on the dev
branches.

(cherry picked from commit 6d4b1f8e30)
2025-06-01 12:35:40 +00:00
Wolfgang Walther
214dfb2f3f workflows/{eval,labels}: allow testing labeling job in forks
A while ago, I added those "owner == NixOS" conditions, because I
couldn't figure out why my fork kept failing those jobs, even though I
had set up the apps correctly.

Turns out, that when a label doesn't exist, those actions try to
implicitly create it. But to do that, they actually need write
permissions on the *issues* endpoint, the pull-requests endpoint is not
enough. Even though the docs state otherwise.

Thus, adding those permissions. This will also lead to new labels being
created when they are added via code (for example in
.github/labels.yml), even when they had not been created, yet. Labels
created this way will initially be grayish color and without description
- but we can always add those later, there is no point in failing
pipelines for everyone in that case.

(cherry picked from commit d2ff68b564)
2025-05-31 07:19:56 +00:00
Wolfgang Walther
042d2e6417 workflows: avoid running jobs when editing title etc.
We intend to use the edited event to react to base branch changes - but
before this change, we also ran those jobs on simple edits like title or
description.

While this works for some of the quicker jobs, it will not be
sustainable for all evaluation-related jobs. But evaluation needs to be
re-triggered on a base branch change as well, thus this change.

(cherry picked from commit 9b01e09a35)
2025-05-22 19:14:03 +00:00
Wolfgang Walther
d3e4865b10 workflows: use ARM runners
ARM runners are supposed to be more energy efficient than x86. Also,
from limited testing, they appear to be faster for the eval jobs as
well. Average run time for the "Outpaths (x86_64-linux)" job was 4m 27s,
so far. In the first run, this job came in at 3m 9s. This effect did not
show for other jobs, yet.

The following two exceptions are made right now:
- nixpkgs-lib-tests currently fails on the ARM runner building Nix 2.3
- nixpkgs-vet is currently pinned to a x86_64-linux only binary release
2025-05-11 12:11:10 +02:00
Wolfgang Walther
de670fa466 workflows/labels: fix wrong yaml file 2025-05-04 19:57:30 +02:00
Wolfgang Walther
6cb93f221b workflows/labeler: fix double quotes
Because GitHub Actions doesn't like double quotes.
2025-05-04 19:25:26 +02:00
Wolfgang Walther
e67623596d workflows/labeler: fix repo owner condition
Introduced in #402332, but broken on all ends:
- pull_request needs to be event.pull_request
- pull_request.head is an object, not a string
- github.ref_protected is about the target branch, because this runs as
a pull_request_target event

Thus, we need to list the branches manually.
2025-05-04 18:52:43 +02:00
Wolfgang Walther
1909520015 workflows/labels: skip for staging-next / haskell-updates / python-updates
Labelling those PRs is more annoying then useful.
2025-05-04 13:53:32 +02:00
Peder Bergebakken Sundt
8ed4f7b5a6 workflows/labels: add a sync-labels: false step, migrate some rules 2025-01-20 12:35:38 +01:00
Wolfgang Walther
88afad8833 workflows: basic consistency in formatting workflows
Same top-level ordering of keys / empty lines and same indentation for
yaml lists. One blank line between each step.

Makes it easier to read and compare the workflows.
2025-01-09 21:29:41 +01:00
NAHO
fcfbe6fff4 workflows: update Ubuntu runner to ubuntu-24.04
Link: https://github.com/actions/runner-images/issues/10636
2025-01-05 00:18:58 +01:00
NAHO
2660dd1e71 workflows: lock Ubuntu runner to ubuntu-22.04
Lock the Ubuntu runner to ubuntu-22.04 to avoid accidental updates [1]
and increase reproducibility.

[1]: https://github.com/actions/runner-images/issues/10636
2025-01-05 00:18:57 +01:00
Adam Stephens
15e9fcd961 workflows/*: ensure jobs have names 2024-07-31 23:28:40 -04:00
dependabot[bot]
98748903e3 build(deps): bump actions/labeler from 4.3.0 to 5.0.0
Bumps [actions/labeler](https://github.com/actions/labeler) from 4.3.0 to 5.0.0.
- [Release notes](https://github.com/actions/labeler/releases)
- [Commits](ac9175f8a1...8558fd7429)

---
updated-dependencies:
- dependency-name: actions/labeler
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-17 12:24:44 +01:00
Victor Engmark
4177297b14 ci: pin third party actions
For reproducibility.

Command:

```shell
for file in .github/workflows/*.y*ml; do
    npx pin-github-action --comment=' {ref}' "$file"
done
```

Then had to manually replace all the versions with accurate specifiers
(for example, "v4" → "v4.1.1" in case of `actions/checkout`).
2023-11-29 09:51:22 +01:00
zowoq
3a1f02b46b .github/workflows/labels.yml: fix typo
mistake in d1570428a2
2023-01-21 11:30:55 +10:00
zowoq
d1570428a2 .github/workflows/labels.yml: allow PRs to skip labels 2023-01-21 09:33:59 +10:00
Jörg Thalheim
92a720cbac ci: add warning to actions with writeable GITHUB_TOKEN
Co-authored-by: ckie <25263210+ckiee@users.noreply.github.com>
2022-03-21 08:54:42 +01:00
dependabot[bot]
e07220a5ad build(deps): bump actions/labeler from 3 to 4
Bumps [actions/labeler](https://github.com/actions/labeler) from 3 to 4.
- [Release notes](https://github.com/actions/labeler/releases)
- [Commits](https://github.com/actions/labeler/compare/v3...v4)
2022-03-02 05:08:31 +01:00
Graham Christensen
9d95ba3dd6 actions: add some permission restrictions 2021-04-24 13:07:57 -04:00
zowoq
574c4a7468 .github/workflows/labels.yml: set event types
opened, synchronize, reopened are the defaults for `pull_request_target`,
`edited` will trigger the label action if the PRs base branch is changed.
2021-04-03 06:09:27 +10:00
zowoq
cce9a296bd .github/workflows/labels.yml: label PRs 2021-03-20 17:51:02 -07:00