Merge pull request 'don't rebuild eval tests on each ci run' (#4252) from borgbackup into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/4252
This commit is contained in:
@@ -23,7 +23,13 @@ in
|
|||||||
unit-test-module = (
|
unit-test-module = (
|
||||||
self.clanLib.test.flakeModules.makeEvalChecks {
|
self.clanLib.test.flakeModules.makeEvalChecks {
|
||||||
inherit module;
|
inherit module;
|
||||||
inherit self inputs;
|
inherit inputs;
|
||||||
|
fileset = lib.fileset.unions [
|
||||||
|
# The hello-world service being tested
|
||||||
|
../../clanServices/hello-world
|
||||||
|
# Required modules
|
||||||
|
../../nixosModules/clanCore
|
||||||
|
];
|
||||||
testName = "hello-world";
|
testName = "hello-world";
|
||||||
tests = ./tests/eval-tests.nix;
|
tests = ./tests/eval-tests.nix;
|
||||||
# Optional arguments passed to the test
|
# Optional arguments passed to the test
|
||||||
|
|||||||
@@ -15,7 +15,15 @@ in
|
|||||||
unit-test-module = (
|
unit-test-module = (
|
||||||
self.clanLib.test.flakeModules.makeEvalChecks {
|
self.clanLib.test.flakeModules.makeEvalChecks {
|
||||||
inherit module;
|
inherit module;
|
||||||
inherit self inputs;
|
inherit inputs;
|
||||||
|
fileset = lib.fileset.unions [
|
||||||
|
# The zerotier service being tested
|
||||||
|
../../clanServices/zerotier
|
||||||
|
# Required modules
|
||||||
|
../../nixosModules/clanCore
|
||||||
|
# Dependencies like clan-cli
|
||||||
|
../../pkgs/clan-cli
|
||||||
|
];
|
||||||
testName = "zerotier";
|
testName = "zerotier";
|
||||||
tests = ./tests/eval-tests.nix;
|
tests = ./tests/eval-tests.nix;
|
||||||
testArgs = { };
|
testArgs = { };
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
makeEvalChecks =
|
makeEvalChecks =
|
||||||
{
|
{
|
||||||
self,
|
fileset,
|
||||||
inputs,
|
inputs,
|
||||||
testName,
|
testName,
|
||||||
tests,
|
tests,
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
testArgs ? { },
|
testArgs ? { },
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inputOverrides = self.clanLib.flake-inputs.getOverrides inputs;
|
inputOverrides = clanLib.flake-inputs.getOverrides inputs;
|
||||||
attrName = "eval-tests-${testName}";
|
attrName = "eval-tests-${testName}";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
@@ -39,16 +39,44 @@
|
|||||||
}
|
}
|
||||||
// testArgs
|
// testArgs
|
||||||
);
|
);
|
||||||
checks.${attrName} = pkgs.runCommand "tests" { nativeBuildInputs = [ pkgs.nix-unit ]; } ''
|
checks.${attrName} =
|
||||||
export HOME="$(realpath .)"
|
let
|
||||||
|
# The root is two directories up from where this file is located
|
||||||
|
root = ../..;
|
||||||
|
|
||||||
nix-unit --eval-store "$HOME" \
|
# Combine the user-provided fileset with all flake-module.nix files
|
||||||
--extra-experimental-features flakes \
|
# and other essential files
|
||||||
--show-trace \
|
src = lib.fileset.toSource {
|
||||||
${inputOverrides} \
|
inherit root;
|
||||||
--flake ${self}#legacyPackages.${system}.${attrName}
|
fileset = lib.fileset.unions [
|
||||||
touch $out
|
# Core flake files
|
||||||
'';
|
(root + "/flake.nix")
|
||||||
|
(root + "/flake.lock")
|
||||||
|
|
||||||
|
# All flake-module.nix files anywhere in the tree
|
||||||
|
(lib.fileset.fileFilter (file: file.name == "flake-module.nix") root)
|
||||||
|
|
||||||
|
# The flakeModules/clan.nix if it exists
|
||||||
|
(lib.fileset.maybeMissing (root + "/flakeModules/clan.nix"))
|
||||||
|
|
||||||
|
# Core libraries
|
||||||
|
(root + "/lib")
|
||||||
|
|
||||||
|
# User-provided fileset
|
||||||
|
fileset
|
||||||
|
];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
pkgs.runCommand "tests" { nativeBuildInputs = [ pkgs.nix-unit ]; } ''
|
||||||
|
export HOME="$(realpath .)"
|
||||||
|
|
||||||
|
nix-unit --eval-store "$HOME" \
|
||||||
|
--extra-experimental-features flakes \
|
||||||
|
--show-trace \
|
||||||
|
${inputOverrides} \
|
||||||
|
--flake ${src}#legacyPackages.${system}.${attrName}
|
||||||
|
touch $out
|
||||||
|
'';
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
{ self, inputs, ... }:
|
{
|
||||||
|
self,
|
||||||
|
inputs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
{
|
{
|
||||||
perSystem =
|
perSystem =
|
||||||
{ ... }:
|
{ ... }:
|
||||||
@@ -10,7 +15,11 @@
|
|||||||
test-types-module = (
|
test-types-module = (
|
||||||
self.clanLib.test.flakeModules.makeEvalChecks {
|
self.clanLib.test.flakeModules.makeEvalChecks {
|
||||||
module = throw "";
|
module = throw "";
|
||||||
inherit self inputs;
|
inherit inputs;
|
||||||
|
fileset = lib.fileset.unions [
|
||||||
|
# Only lib is needed for type tests
|
||||||
|
../../lib
|
||||||
|
];
|
||||||
testName = "types";
|
testName = "types";
|
||||||
tests = ./tests.nix;
|
tests = ./tests.nix;
|
||||||
# Optional arguments passed to the test
|
# Optional arguments passed to the test
|
||||||
|
|||||||
Reference in New Issue
Block a user