Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflows/eval: Request reviews from changed package maintainers #366046

Merged
merged 2 commits into from
Jan 2, 2025

Conversation

infinisil
Copy link
Member

Request reviews from maintainers of changed packages, mirroring what ofborg does, but without having to wait for it anymore. Part of #355847

Things done


This work is funded by Tweag and Antithesis

Add a 👍 reaction to pull requests you find important.

@infinisil infinisil added the backport release-24.11 Backport PR automatically label Dec 18, 2024
@github-actions github-actions bot added 6.topic: policy discussion 6.topic: continuous integration Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions labels Dec 18, 2024
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Dec 18, 2024
Currently we need to rely on ofborg requesting reviews from package
maintainers, which takes a while with ofborg's eval queue. Since
recently we're doing faster evaluations with GitHub Actions, which contain all
necessary information to determine reviewers of changed packages the
same way ofborg does. This PR takes advantage of that.
…ged packages

The handles can change over time and there's nothing guaranteeing the
ones in the maintainer list are up-to-date. In comparison GitHub IDs
never change.
@infinisil
Copy link
Member Author

infinisil commented Dec 18, 2024

Feedback addressed, still works: Infinisil-s-Test-Organization#37 (comment)

Copy link
Contributor

@JohnRTitor JohnRTitor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eval "Process" seems to be failing.

@infinisil
Copy link
Member Author

infinisil commented Dec 19, 2024

@JohnRTitor A bit unfortunate but unfixable here, because the workflow for this PR itself uses the version from the base branch, but fetches the code from the PR, which now takes an extra argument not passed in the workflow

@Mic92
Copy link
Member

Mic92 commented Dec 19, 2024

@JohnRTitor A bit unfortunate but unfixable here, because the workflow for this PR itself uses the version from the base branch, but fetches the code from the PR, which now takes an extra argument not passed in the workflow

This is the reference to look at: Infinisil-s-Test-Organization#37 (comment) instead

Comment on lines +272 to +275
jq -r 'keys[]' comparison/maintainers.json \
| while read -r id; do gh api /user/"$id"; done \
| jq -s '{ reviewers: map(.login) }' \
> reviewers.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
jq -r 'keys[]' comparison/maintainers.json \
| while read -r id; do gh api /user/"$id"; done \
| jq -s '{ reviewers: map(.login) }' \
> reviewers.json
jq -r 'keys[]' comparison/maintainers.json \
| head -n15 \
| while read -r id; do gh api /user/"$id"; done \
| jq -s '{ reviewers: map(.login) }' \
> reviewers.json

GitHub apps are limited to 15 reviewer requests anyway, and this way treewide changes are handled better. Adding a head -n15 here should work, but I did not test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good idea. Should be the list sorted, so it's always the same 15 reviewers?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see two other options to handle treewides / PRs with more than 15 reviewers:

  • Don't request reviewers in this case.
  • Instead of requesting review, post a comment with all maintainers mentioned for this case.

I actually prefer the first option: When you make a treewide change and you get some random 15 reviewers, chances are high that those reviewers:

  • are not responding anyway
  • don't have much to say about that treewide change

So why notify many random people?

(Note that for a treewide, we very likely have already requested reviews from a bunch of people via OWNERS!)

For treewide changes it makes much more sense to pick your reviewers individually, specifically for that change.

Copy link
Member

@Mic92 Mic92 Jan 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is also a limit with posting maintainers in comments. But we probably should avoid mass-pinging so many people and leave it to the pr authors/reviewers to select the right set of people.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we have now implemented requesting reviewers 1-by-1 to work around failures for some of them.

See #370749 for a run with that. Clearly the limit seems to apply for a single API request - and going 1-by-1 requested reviews from 30 reviewers there.

ofborg had limited itself to 10 per run manually. We'll need to do something about this as well.

Comment on lines +56 to +83
relevantFilenames =
drv:
(lib.lists.unique (
builtins.map (pos: lib.strings.removePrefix (toString ../..) pos.file) (
builtins.filter (x: x != null) [
(builtins.unsafeGetAttrPos "maintainers" (drv.meta or { }))
(builtins.unsafeGetAttrPos "src" drv)
# broken because name is always set by stdenv:
# # A hack to make `nix-env -qa` and `nix search` ignore broken packages.
# # TODO(@oxij): remove this assert when something like NixOS/nix#1771 gets merged into nix.
# name = assert validity.handled; name + lib.optionalString
#(builtins.unsafeGetAttrPos "name" drv)
(builtins.unsafeGetAttrPos "pname" drv)
(builtins.unsafeGetAttrPos "version" drv)

# Use ".meta.position" for cases when most of the package is
# defined in a "common" section and the only place where
# reference to the file with a derivation the "pos"
# attribute.
#
# ".meta.position" has the following form:
# "pkgs/tools/package-management/nix/default.nix:155"
# We transform it to the following:
# { file = "pkgs/tools/package-management/nix/default.nix"; }
{ file = lib.head (lib.splitString ":" (drv.meta.position or "")); }
]
)
));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is an extension on top of the current ofborg behavior, but maybe a good time to discuss it:

Can we extend the "relevant file names" for a derivation to include some dependent files like patches or setup hooks?

I remember having to look up maintainers from the derivation manually when changing the setup-hook.sh.

I think some basic rules could be:

  • if the path ends in /default.nix or the path ends in /package.nix and is in /by-name/, then
  • add all files in the same directory (recursively) to the list of relevant files.

A random example that would benefit from it:

pkgs/by-name/me/meson/package.nix would include changes to all the patch and .sh files in the same folder.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we can first start with a minimal feature set and make it more complex later. Now since ofborg has been shutdown and will be re-instantiated with only a smaller feature set.

Copy link
Contributor

@JohnRTitor JohnRTitor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay LGTM, let's just merge this initial PR, we can improve later based on feedbacks recieved

@JohnRTitor JohnRTitor merged commit a69bc54 into NixOS:master Jan 2, 2025
36 of 37 checks passed
@nix-backports
Copy link

nix-backports bot commented Jan 2, 2025

Backport failed for release-24.11, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-24.11
git worktree add -d .worktree/backport-366046-to-release-24.11 origin/release-24.11
cd .worktree/backport-366046-to-release-24.11
git switch --create backport-366046-to-release-24.11
git cherry-pick -x b9d800d46814e44db4d0a0104141aeb54e0c3c9a b844cba4e6fcac4c4ceef81e481a5f93a01e4631

@FliegendeWurst
Copy link
Member

It seems there are some limitations for who we can request reviews from.

gh: Reviews may only be requested from collaborators. One or more of the users or teams you specified is not a collaborator of the NixOS/nixpkgs repository. (HTTP 422)

https://github.com/NixOS/nixpkgs/actions/runs/12580696560/job/35063365466

@Mic92
Copy link
Member

Mic92 commented Jan 2, 2025

@FliegendeWurst #370186

@FliegendeWurst
Copy link
Member

That only applies for the other issue #355847 (comment)

@Mic92
Copy link
Member

Mic92 commented Jan 2, 2025

Ah right, we need a special github token than.

@Mic92
Copy link
Member

Mic92 commented Jan 2, 2025

We should probably revert this pull request until these two issues are addressed.

@FliegendeWurst
Copy link
Member

Ah right, we need a special github token than.

I don't think it's possible to request reviews from non-members. So a better token would not help.

@JohnRTitor
Copy link
Contributor

I don't think it's possible to request reviews from non-members

Exactly, you either need to be a repo collaborator or an org member.

@wolfgangwalther
Copy link
Contributor

We should probably revert this pull request until these two issues are addressed.

I don't think we need to revert it. Yes, we might have failing CI jobs, but ultimately we don't lose anything: The only thing that is not happening with those kind of failures is the request for maintainer reviews. Exactly the same outcome as when reverting the whole feature... except for the many cases where it already works right now.

Exactly, you either need to be a repo collaborator or an org member.

How can it actually happen that a listed maintainer is not an org member? IIUC, maintainers are automatically added to the org, right? That means they probably left the org manually.

But.. I checked the maintainers listed in the comparisons.zip/maintainers.json file in the GA run mentioned above: https://github.com/NixOS/nixpkgs/actions/runs/12580696560#artifacts

All of the 6 maintainers appear to be in the NixOS org to me. I don't understand why GH would throw an error here.

@symphorien
Copy link
Member

A different failure mode in https://github.com/NixOS/nixpkgs/actions/runs/12588895670/job/35088361244


Run # Get all currently set rebuild labels
gh: Review cannot be requested from pull request author. (HTTP 422)
{"message":"Review cannot be requested from pull request author.","documentation_url":"https://docs.github.com/rest/pulls/review-requests#request-reviewers-for-a-pull-request","status":"422"}

@emilazy
Copy link
Member

emilazy commented Jan 2, 2025

Yes, we might have failing CI jobs, but ultimately we don't lose anything: The only thing that is not happening with those kind of failures is the request for maintainer reviews.

I get an email for every single PR I open telling me the job failed, and every PR has a big red ❌ on it that makes it look like eval failed. I think those are sufficient cause to revert this until it can be fixed.

@GGG-KILLER
Copy link
Contributor

I get an email for every single PR I open telling me the job failed, and every PR has a big red ❌ on it that makes it look like eval failed. I think those are sufficient cause to revert this until it can be fixed.

Instead of reversing this change, can't we temporarily add a ||: to the line that adds the reviewers?
That way it'll keep requesting them in the cases it works and not block PRs when it fails.

@emilazy
Copy link
Member

emilazy commented Jan 3, 2025

Sure, that also works if someone PRs it. I just think we shouldn’t be too hesitant to revert PRs that cause treewide issues, since we didn’t have this PR 16 hours ago anyway and it is cheap to merge again with fixes but leaving things merged in a broken state multiplies the problems they cause. Better to revert and bring it back without the issue than to leave the problem present while waiting for a fix.

@GGG-KILLER
Copy link
Contributor

Sure, that also works if someone PRs it. I just think we shouldn’t be too hesitant to revert PRs that cause treewide issues, since we didn’t have this PR 16 hours ago anyway and it is cheap to merge again with fixes but leaving things merged in a broken state multiplies the problems they cause. Better to revert and bring it back without the issue than to leave the problem present while waiting for a fix.

I'm not against reversing this, I'd just prefer to have a somewhat working reviewer request automation instead of having to wait 2 business months for ofborg to request them itself, but either work for me.

I can't PR the hack fix right now but I'm willing to do it, if someone wants to revert it meanwhile I'm okay with it as well, better than having a CI check giving a false negative on a PR.

@infinisil
Copy link
Member Author

I'm kind of on holidays, but I can make a quick fix, working on it..

@Atemu
Copy link
Member

Atemu commented Jan 3, 2025

We can also just revert until you're back.

@infinisil infinisil deleted the maintainer-reviews branch January 3, 2025 03:09
@infinisil
Copy link
Member Author

Maybe that would've been better, but here's the fix, already tested: #370456 :)

@wolfgangwalther wolfgangwalther added backport release-24.11 Backport PR automatically and removed backport release-24.11 Backport PR automatically labels Jan 3, 2025
@nix-backports
Copy link

nix-backports bot commented Jan 3, 2025

Successfully created backport PR for release-24.11:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: continuous integration Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions 6.topic: policy discussion 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux backport release-24.11 Backport PR automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.