From 80a0732837220fd09f4d3b1025096ec7b901270e Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Thu, 29 May 2025 18:23:26 +0200 Subject: [PATCH 1/2] workflows/{check-shell,lib-tests}: use nixpks CI cachix cache Any change to shell.nix or ci/ currently needs to rebuild treefmt on 4 systems from scratch. We can avoid that by using the existing cachix cache. Adding the cache to lib-tests won't do much on it's own, yet, but it will with the next commit. (cherry picked from commit f87dac4be32235f7a7409eaf3faaa10213264e34) (cherry picked from commit 6a9e0894eb4448ada4ca25b9e3ab2feb5027e12a) --- .github/workflows/check-shell.yml | 6 ++++++ .github/workflows/lib-tests.yml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/check-shell.yml b/.github/workflows/check-shell.yml index b8cbe062b6a9..fc90a449fb34 100644 --- a/.github/workflows/check-shell.yml +++ b/.github/workflows/check-shell.yml @@ -44,5 +44,11 @@ jobs: - uses: cachix/install-nix-action@526118121621777ccd86f79b04685a9319637641 # v31 + - uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16 + with: + # This cache is for the nixpkgs repo checks and should not be trusted or used elsewhere. + name: nixpkgs-ci + authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + - name: Build shell run: nix-build untrusted/ci -A shell diff --git a/.github/workflows/lib-tests.yml b/.github/workflows/lib-tests.yml index d176a76411f8..f11dca13581d 100644 --- a/.github/workflows/lib-tests.yml +++ b/.github/workflows/lib-tests.yml @@ -32,6 +32,12 @@ jobs: with: extra_nix_config: sandbox = true + - uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16 + with: + # This cache is for the nixpkgs repo checks and should not be trusted or used elsewhere. + name: nixpkgs-ci + authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + - name: Building Nixpkgs lib-tests run: | nix-build untrusted/ci -A lib-tests From e506dfcf53f60f99248fa7369ec16062c7eb36b8 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Thu, 29 May 2025 18:30:34 +0200 Subject: [PATCH 2/2] lib/tests: avoid full rebuild when only maintainers change The vast majority of CI jobs to build the lib tests are caused by changes in the maintainer list. In this case, we currently run the full test-suite which takes 3-4 minutes. By moving the maintainers and teams tests out of the test-with-nix file, we save almost all of that. Building only those two tests on a change is almost instant. This only works, because we previously enabled cachix for the workflow. Note, that these tests are not actually run with both nix versions, even though they were listed in the "test with specific nix version" file. That's because we only differ in the nix version run *inside* the sandbox, but not doing the outer build. Since this file seems to be re-used by NixOS/nix' CI, this is technically a small loss in coverage for that repo, but nixpkgs CI considerations outweigh that. But because of this, I left the other non-nix-version-specific tests in that file. (cherry picked from commit a7f4e0f9ae31e5ec90dd6ca7d5465d4ed97ee099) (cherry picked from commit af25d1ce8cf120179348c1fd1006bc7a3cf52d3c) --- lib/tests/maintainers.nix | 2 +- lib/tests/release.nix | 11 ++++++++++- lib/tests/test-with-nix.nix | 8 -------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/tests/maintainers.nix b/lib/tests/maintainers.nix index d04bb07ea2c8..289a46e7409d 100644 --- a/lib/tests/maintainers.nix +++ b/lib/tests/maintainers.nix @@ -54,7 +54,7 @@ let missingGithubIds = lib.concatLists (lib.mapAttrsToList checkMaintainer lib.maintainers); - success = pkgs.runCommand "checked-maintainers-success" { } ">$out"; + success = pkgs.runCommand "checked-maintainers-success" { } "mkdir $out"; failure = pkgs.runCommand "checked-maintainers-failure" diff --git a/lib/tests/release.nix b/lib/tests/release.nix index c3acda85304f..d73679d47a37 100644 --- a/lib/tests/release.nix +++ b/lib/tests/release.nix @@ -20,5 +20,14 @@ let in pkgs.symlinkJoin { name = "nixpkgs-lib-tests"; - paths = map testWithNix nixVersions; + paths = map testWithNix nixVersions ++ [ + (import ./maintainers.nix { + inherit pkgs; + lib = import ../.; + }) + (import ./teams.nix { + inherit pkgs; + lib = import ../.; + }) + ]; } diff --git a/lib/tests/test-with-nix.nix b/lib/tests/test-with-nix.nix index 0be65a743f00..4f9aa53f83dd 100644 --- a/lib/tests/test-with-nix.nix +++ b/lib/tests/test-with-nix.nix @@ -19,14 +19,6 @@ pkgs.runCommand "nixpkgs-lib-tests-nix-${nix.version}" buildInputs = [ (import ./check-eval.nix) (import ./fetchers.nix) - (import ./maintainers.nix { - inherit pkgs; - lib = import ../.; - }) - (import ./teams.nix { - inherit pkgs; - lib = import ../.; - }) (import ../path/tests { inherit pkgs; })