nix-community / buildbot-nix

A nixos module to make buildbot a proper Nix-CI [maintainer=@Mic92,@MagicRB]
MIT License
114 stars 23 forks source link

Support GitHub's merge queue #269

Closed MattSturgeon closed 2 months ago

MattSturgeon commented 2 months ago

Similar to mergify, GitHub now has a built-in merge queue.

According to Managing a merge queue, in GitHub Actions, CI should target the merge_group event. While third-party CI providers, apparently need to be configured to run only on branches that are prefixed with gh-readonly-queue/{base_branch}.

This will almost certainly require some level of per-repo config support.

Using github's merge queue in this way could lead to reduced load on buildbot, because a) we are only building on branches ready to be merged and b) the branch is already updated on top of the base-branch (and other queued branches), so assuming everything goes well there's no need to rebuild again when merging onto a more up-to-date base-branch revision.

If we're going to need a per-repo config file for this anyway maybe it'd be good to have the ability to configure some builds to happen on unqueued PRs, while the full flake checks are only built on queued PRs? I.e. a "two-stage CI", as described here.

Mic92 commented 2 months ago

Afaik this already is supported. At least this used to work in the past: https://github.com/nix-community/buildbot-nix/blob/ade5f42d7e56c8298d729aa0e804c8062e7a77ac/buildbot_nix/__init__.py#L697

MattSturgeon commented 2 months ago

Afaik this already is supported.

Interesting, good to know, thanks. Apologies for the noise!

Can I ask how it knows whether the repo has merge queue enabled? Is that exposed through a branch protection API or something?

Also, how does it behave in practice; does buildbot build on?:

MattSturgeon commented 2 months ago

My interpretation of having multiple schedulers, is that a repo using the merge queue will trigger builds both on unqueud PR pushes and also staged/queued PRs.

https://github.com/nix-community/buildbot-nix/blob/ade5f42d7e56c8298d729aa0e804c8062e7a77ac/buildbot_nix/__init__.py#L683-L709

I guess that works but it feels a little wasteful. I'd love a way to tell buildbot to either not run[^1] on non-queued PRs or to run a subset of tests (in the spirit of two-stage CI).

[^1]: On yet-to-be-queued PRs, a subset of faster/lighter tests could be run using another CI framework, such as github actions.