nix build: fix tests incremental building and testing

This commit is contained in:
Alex 2025-02-02 20:25:57 +01:00
parent bcaced807a
commit b96db0bc7c
2 changed files with 24 additions and 11 deletions

View file

@ -23,10 +23,9 @@
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
compileFor = target: release: (compile {
packageFor = target: release: (compile {
inherit system git_version target nixpkgs crane rust-overlay release;
});
packageFor = target: release: (compileFor target release).garage;
}).garage;
in
{
packages = {
@ -43,7 +42,10 @@
dev = packageFor null false;
# test = cargo test
test = (compileFor null false).garage-test;
tests = (compile {
inherit system git_version nixpkgs crane rust-overlay;
release = false;
}).garage-test;
};
# ---- developpment shell, for making native builds only ----

View file

@ -141,6 +141,12 @@ let
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER = "clang";
});
testArgs = commonArgs // {
pname = "garage-tests";
cargoExtraArgs = "${commonArgs.cargoExtraArgs} --tests --workspace";
CARGO_PROFILE = "test";
};
in rec {
toolchain = toolchainFn pkgs;
@ -158,21 +164,26 @@ in rec {
garage = craneLib.buildPackage (commonArgs // {
cargoArtifacts = garage-deps;
doCheck = false;
version = git_version;
GIT_VERSION = git_version;
});
garage-test-deps = craneLib.buildDepsOnly (commonArgs // {
pname = "garage-test";
garage-test-deps = craneLib.buildDepsOnly (testArgs // {
cargoArtifacts = garage;
cargoExtraArgs = "${commonArgs.cargoExtraArgs} --tests --workspace";
CARGO_PROFILE = "test";
});
garage-test = craneLib.cargoTest (commonArgs // {
cargoTestExtraArgs = "--workspace";
garage-test-bin = craneLib.cargoBuild (testArgs // {
cargoArtifacts = garage-test-deps;
CARGO_PROFILE = "test";
doCheck = false;
});
garage-test = craneLib.cargoTest (testArgs // {
cargoArtifacts = garage-test-bin;
nativeBuildInputs = commonArgs.nativeBuildInputs ++ [
pkgs.cacert
];
});
}