Skip to content

ci: split tests into chunks #7391

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

khaneliman
Copy link
Collaborator

@khaneliman khaneliman commented Jul 5, 2025

Similar goal of #6539 but applying it to the actual tests themselves for parallelization. Again, blocked by being able to change our checks ( I can't do that )

We have lots of tests and would like to add more. However, adding more testing coverage comes at the cost of a slower CI when we run them sequentially. This adds test outputs that are chunked however we'd like to tune for batch sizes. Allowing us to create a parallelized CI workflow.

Been testing in my fork and seems to cut time in half https://github.com/khaneliman/home-manager/actions/runs/16084828656

Description

Checklist

  • Change is backwards compatible.

  • Code formatted with nix fmt or
    nix-shell -p treefmt nixfmt-rfc-style deadnix keep-sorted --run treefmt.

  • Code tested through nix-shell --pure tests -A run.all
    or nix build --reference-lock-file flake.lock ./tests#test-all using Flakes.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.

Maintainer CC

@zowoq
Copy link
Contributor

zowoq commented Jul 6, 2025

Have you looks at using buildbot for the tests? After the initial run I'd expect it to be quick as most tests would be cached. Darwin would be a bit bottlenecked so I'd suggest only testing aarch64-darwin and not x86_64-darwin.

@khaneliman
Copy link
Collaborator Author

Have you looks at using buildbot for the tests? After the initial run I'd expect it to be quick as most tests would be cached. Darwin would be a bit bottlenecked so I'd suggest only testing aarch64-darwin and not x86_64-darwin.

Yes, that's been something I have thought about but wasn't sure how to get set up in the checks here and everything there.

@zowoq
Copy link
Contributor

zowoq commented Jul 6, 2025

As there is a separate flake.nix for the tests I'll need to implement flake_dir in buildbot but I think this diff is all that would need to be done in home-manager. I can configure buildbot to just run on a branch without enabling it for the entire repo so can see it working without causing any disruption in other PRs. I should be able to have this done in the next day or two.

diff --git a/buildbot-nix.toml b/buildbot-nix.toml
new file mode 100644
index 00000000..55433a03
--- /dev/null
+++ b/buildbot-nix.toml
@@ -0,0 +1,3 @@
+attribute = "packages"
+flake_dir = "./tests"
+lock_file = "./flake.lock"
diff --git a/tests/flake.nix b/tests/flake.nix
index 34f39d35..f5d183d0 100644
--- a/tests/flake.nix
+++ b/tests/flake.nix
@@ -20,7 +20,10 @@
   outputs =
     { nixpkgs, ... }:
     let
-      forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
+      forAllSystems = nixpkgs.lib.genAttrs [
+        "aarch64-darwin"
+        "x86_64-linux"
+      ];
     in
     {
       devShells = forAllSystems (

@khaneliman
Copy link
Collaborator Author

khaneliman commented Jul 6, 2025

As there is a separate flake.nix for the tests I'll need to implement flake_dir in buildbot but I think this diff is all that would need to be done in home-manager. I can configure buildbot to just run on a branch without enabling it for the entire repo so can see it working without causing any disruption in other PRs. I should be able to have this done in the next day or two.

diff --git a/buildbot-nix.toml b/buildbot-nix.toml
new file mode 100644
index 00000000..55433a03
--- /dev/null
+++ b/buildbot-nix.toml
@@ -0,0 +1,3 @@
+attribute = "packages"
+flake_dir = "./tests"
+lock_file = "./flake.lock"
diff --git a/tests/flake.nix b/tests/flake.nix
index 34f39d35..f5d183d0 100644
--- a/tests/flake.nix
+++ b/tests/flake.nix
@@ -20,7 +20,10 @@
   outputs =
     { nixpkgs, ... }:
     let
-      forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
+      forAllSystems = nixpkgs.lib.genAttrs [
+        "aarch64-darwin"
+        "x86_64-linux"
+      ];
     in
     {
       devShells = forAllSystems (

I think in nixvim we ended up creating a separate flake output for buildbot itself so that we could keep the flake building on all platforms and only forward certain platforms to the ci.

https://github.com/nix-community/nixvim/blob/main/buildbot-nix.toml#L1-L1 looks like it lets us tell buildbot which outputs to use?

@zowoq
Copy link
Contributor

zowoq commented Jul 7, 2025

Yes, can use different flake output. The ~1400 tests in packages is too much for buildbot but chunking them seems to be fine.

qowoz@60215a9

https://buildbot.nix-community.org/#/builders/4466/builds/5

I deployed the flake_dir change just to test this, still need to upstream it to buildbot-nix repo so it can be deployed again. nix-community/buildbot-nix#450

@Mic92
Copy link
Member

Mic92 commented Jul 7, 2025

Longterm buildbot-nix probably will not schedule "skipped builds" for repositories with a lot of flake outputs. I need to do some refactoring for updating gcroots though.

@zowoq
Copy link
Contributor

zowoq commented Jul 13, 2025

The buildbot changes are deployed now if you'd like to move forward with that, note that the nix-community-buildbot label no longer works, instead the repo needs to be added to the list in the infra repo.

@khaneliman
Copy link
Collaborator Author

The buildbot changes are deployed now if you'd like to move forward with that, note that the nix-community-buildbot label no longer works, instead the repo needs to be added to the list in the infra repo.

Thanks, I'll try and do that within the next couple days.

@khaneliman khaneliman force-pushed the parallel2 branch 2 times, most recently from 934b770 to 126930f Compare July 17, 2025 20:15
@zowoq
Copy link
Contributor

zowoq commented Jul 18, 2025

I've discovered that the buildbot method I used previously for testing only seems to work for the repo default branch so I can't test this PR directly, instead I've pushed the commits to master on my fork.

https://buildbot.nix-community.org/#/builders/4466/builds/17
https://buildbot.nix-community.org/#/builders/4466/builds/18

We have lots of tests and would like to add more. However, adding more
testing coverage comes at the cost of a slower CI when we run them
sequentially. This adds test outputs that are chunked however we'd like
to tune for batch sizes. Allowing us to create a parallelized CI
workflow.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
Filters tests to specific platforms for buildbot.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
Support testing on buildbot CI

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
@khaneliman
Copy link
Collaborator Author

Looks like we have some checks that we dont normally run in CI that are failing. Will need to look into those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants