Commit graph

12 commits

Author SHA1 Message Date
Wolfgang Walther e50d57a2a0 workflows/check: don't check github api for owners file
This removes the "owners" check from codeowners-validator. With it, all
tokens and permissions can be removed, because these were only needed to
make these requests.

This solves the problem of codeowners-validator not supporting our new
nested team structure for nixpkgs-maintainers. To make the onboarding of
new teams easier, we moved all teams "under" the nixpkgs-maintainers
team. This makes them inherit the right privileges (triage) for Nixpkgs.

However, this inheritance is not recognized by codeowners-validator,
thus it assumes that these teams don't have access to Nixpkgs. This then
fails the owners check immediately.

Removing the owners check also has a few other advantages:
- This check depends on external state: If a user is renamed or a team
removed, the check will fail. This makes it a bad check for required
status checks or merge queues - the check might fail randomly,
independent of the current PR.
- Running this check in a fork will never work, because the respective
users and teams don't have access to the fork's repo.

Both of this required us to set `continue-on-error: true` most of the
time.

(cherry picked from commit f7d6d11e8e)
2025-09-30 10:38:14 +00:00
Wolfgang Walther 91c088d3b7 ci/github-script/prepare: identify real base branch
When a contributor mistakenly sets the wrong target branch for a Pull
Request, this can lead to bad consequences for CI. Most prominent is the
mass ping of codeowners, that is already handled in
`ci/request-reviews/verify-base-branch.sh`. But there are other things
that go wrong:
- After eval, a mass ping of maintainers would still be possible, in
theory. Practically, this doesn't happen, because we have a limit of 10
reviewer requests at the same time.
- This will most often contain a change to `ci/pinned.json`, thus the
full Eval matrix of all Lix/Nix versions will be run, burning a lot of
resources.
- The PR will be labelled with almost all labels that are available.

We can improve on the current situation with some API calls to determine
the "best" merge-base for the current PR. We then consider this as the
"real base". If the current target is not the real base, we fail the
prepare step, which is early enough to prevent all other CI from
running.

(cherry picked from commit 87d9b08ffb)
2025-08-25 12:05:51 +00:00
Wolfgang Walther 8353c8c10e ci/github-script/prepare: avoid running CI when targeting channel branches
This moves the no-channel-base check into the prepare script to exit
early and prevent all of CI to run against those branches. We also
provide better output by posting a "Changes Requested" review, using the
existing infrastructure from the old cherry-picks check.

The review will be dismissed automatically once the branch has been
corrected, because the commits check will run and do it.

(cherry picked from commit 0601cf6fd0)
2025-08-25 12:05:51 +00:00
Wolfgang Walther 78287e87be workflows/check: allow owners to fail when ci/OWNERS is untouched
The owners check is not reproducible, because it depends on the state of
the NixOS org on GitHub. Owners can rename their accounts or they can
leave the organisation and access to Nixpkgs can be removed from teams.
All of this breaks the owners check for reasons unrelated to the PR at
hand.

This PR makes the check for the owners file conditionally required: Only
when the ci/OWNERS file is actually modified a failed check will block
merging the PR. When that's not the case, the check will still fail
visibily in the checklist, but the failure can be ignored.

This is especially relevant for the Merge Queue, which should not be
entirely blocked whenever any of these events happen.

Also, it allows passing the checks in a fork when testing, where the
owners check will *always* fail, because the respective teams and
members are never part of the "user org" that a fork is.

(cherry picked from commit 956d0a744d)
2025-08-24 19:11:25 +00:00
Wolfgang Walther 1e8419b52e ci/github-script/prepare: fix logging of branch classification
Logging objects to stdout is not possible with `core.info`, so we
fallback to `console.log` instead. There's no functional difference for
these anyway.

(cherry picked from commit f94fd64d53)
2025-08-20 16:58:11 +00:00
Wolfgang Walther 9b0135b347 ci/github-script/prepare: determine changed files
(cherry picked from commit 46a1b0a7bc)
2025-08-20 16:58:11 +00:00
Wolfgang Walther 5b61337620 ci/github-script/prepare: classify branches
(cherry picked from commit 4220a03df8)
2025-08-20 16:58:11 +00:00
Wolfgang Walther 51298d2e28 ci/github-script/prepare: load systems
(cherry picked from commit 9caf455441)
2025-08-20 16:58:11 +00:00
Wolfgang Walther e6d63110df
ci: apply safe formatting with biome
(cherry picked from commit 1fa55d3900)
2025-08-20 16:33:41 +02:00
Wolfgang Walther 64d1d69b9f ci/github-script/prepare: refactor
Using core.info instead of console.log and simplifying the arguments for
API calls a bit.

(cherry picked from commit a8cb53611b)
2025-08-20 13:22:29 +00:00
Wolfgang Walther 0fa17a8e6c ci/github-script/prepare: run biome
This will be added to treefmt in a different commit / PR.

(cherry picked from commit f5d3e43368)
2025-08-20 13:22:29 +00:00
Wolfgang Walther b60acc12a9 ci/github-script/prepare: init from actions/get-merge-commit
This just moves the code over to ci/github-script to make it easy to
test and iterate on locally.

The name `prepare` is chosen, because the script will be extended with
the other steps from "PR / prepare" next.

(cherry picked from commit c787c66de6)
2025-08-20 13:22:29 +00:00