nix, ci: build with Crane
This removes our dependency on cargo2nix, which was causing us some
issues. Whereas cargo2nix creates one Nix derivation per crate, Crane
uses only two derivations:
1. Build dependencies only
2. Build the final binary
This means that during the second step, no caching can be done. For
instance, if we do a change in garage_model, we need to recompile all of
the Garage crates including those that do not depend on garage_model.
On the upside, this allows all of the Garage crates to be built at once
using cargo build logic, which is optimized for high parallelism and
better pipelining between all of the steps of the build. All in all,
this makes most builds faster than cargo2nix.
A few other changes have been made to the build scripts and CI:
- Unit tests are now run within a Nix derivation. In fact, we have
different derivations to run the tests using LMDB and Sqlite as
metadata db engines.
- For debug builds, most CI steps now run in parallel (with the notable
exception of the smoke test that runs after the build, which is
inevitable).
- We no longer pass the GIT_VERSION argument when building debug builds
and running the tests. This means that dev binaries and test
binaries don't know the exact version of Garage they are from. That
shouldn't be an issue in most cases.
- The not-dynamic.sh scripts has been fixed to fail if the file does not
exist.
2025-02-01 21:48:10 +01:00
|
|
|
{
|
|
|
|
/* build inputs */
|
|
|
|
nixpkgs,
|
|
|
|
crane,
|
|
|
|
rust-overlay,
|
|
|
|
|
|
|
|
/* parameters */
|
|
|
|
system,
|
|
|
|
git_version ? null,
|
|
|
|
target ? null,
|
|
|
|
release ? false,
|
|
|
|
features ? null,
|
|
|
|
extraTestEnv ? {}
|
|
|
|
}:
|
2022-07-25 14:58:47 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
log = v: builtins.trace v v;
|
|
|
|
|
nix, ci: build with Crane
This removes our dependency on cargo2nix, which was causing us some
issues. Whereas cargo2nix creates one Nix derivation per crate, Crane
uses only two derivations:
1. Build dependencies only
2. Build the final binary
This means that during the second step, no caching can be done. For
instance, if we do a change in garage_model, we need to recompile all of
the Garage crates including those that do not depend on garage_model.
On the upside, this allows all of the Garage crates to be built at once
using cargo build logic, which is optimized for high parallelism and
better pipelining between all of the steps of the build. All in all,
this makes most builds faster than cargo2nix.
A few other changes have been made to the build scripts and CI:
- Unit tests are now run within a Nix derivation. In fact, we have
different derivations to run the tests using LMDB and Sqlite as
metadata db engines.
- For debug builds, most CI steps now run in parallel (with the notable
exception of the smoke test that runs after the build, which is
inevitable).
- We no longer pass the GIT_VERSION argument when building debug builds
and running the tests. This means that dev binaries and test
binaries don't know the exact version of Garage they are from. That
shouldn't be an issue in most cases.
- The not-dynamic.sh scripts has been fixed to fail if the file does not
exist.
2025-02-01 21:48:10 +01:00
|
|
|
# NixOS and Rust/Cargo triples do not match for ARM, fix it here.
|
|
|
|
rustTarget = if target == "armv6l-unknown-linux-musleabihf" then
|
|
|
|
"arm-unknown-linux-musleabihf"
|
|
|
|
else
|
|
|
|
target;
|
|
|
|
|
|
|
|
rustTargetEnvMap = {
|
|
|
|
"x86_64-unknown-linux-musl" = "X86_64_UNKNOWN_LINUX_MUSL";
|
|
|
|
"aarch64-unknown-linux-musl" = "AARCH64_UNKNOWN_LINUX_MUSL";
|
|
|
|
"i686-unknown-linux-musl" = "I686_UNKNOWN_LINUX_MUSL";
|
|
|
|
"arm-unknown-linux-musleabihf" = "ARM_UNKNOWN_LINUX_MUSLEABIHF";
|
|
|
|
};
|
|
|
|
|
|
|
|
pkgsNative = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [ (import rust-overlay) ];
|
|
|
|
};
|
|
|
|
|
2023-01-26 12:20:12 +01:00
|
|
|
pkgs = if target != null then
|
nix, ci: build with Crane
This removes our dependency on cargo2nix, which was causing us some
issues. Whereas cargo2nix creates one Nix derivation per crate, Crane
uses only two derivations:
1. Build dependencies only
2. Build the final binary
This means that during the second step, no caching can be done. For
instance, if we do a change in garage_model, we need to recompile all of
the Garage crates including those that do not depend on garage_model.
On the upside, this allows all of the Garage crates to be built at once
using cargo build logic, which is optimized for high parallelism and
better pipelining between all of the steps of the build. All in all,
this makes most builds faster than cargo2nix.
A few other changes have been made to the build scripts and CI:
- Unit tests are now run within a Nix derivation. In fact, we have
different derivations to run the tests using LMDB and Sqlite as
metadata db engines.
- For debug builds, most CI steps now run in parallel (with the notable
exception of the smoke test that runs after the build, which is
inevitable).
- We no longer pass the GIT_VERSION argument when building debug builds
and running the tests. This means that dev binaries and test
binaries don't know the exact version of Garage they are from. That
shouldn't be an issue in most cases.
- The not-dynamic.sh scripts has been fixed to fail if the file does not
exist.
2025-02-01 21:48:10 +01:00
|
|
|
import nixpkgs {
|
2023-01-26 12:20:12 +01:00
|
|
|
inherit system;
|
|
|
|
crossSystem = {
|
|
|
|
config = target;
|
|
|
|
isStatic = true;
|
2022-11-16 22:21:24 +01:00
|
|
|
};
|
nix, ci: build with Crane
This removes our dependency on cargo2nix, which was causing us some
issues. Whereas cargo2nix creates one Nix derivation per crate, Crane
uses only two derivations:
1. Build dependencies only
2. Build the final binary
This means that during the second step, no caching can be done. For
instance, if we do a change in garage_model, we need to recompile all of
the Garage crates including those that do not depend on garage_model.
On the upside, this allows all of the Garage crates to be built at once
using cargo build logic, which is optimized for high parallelism and
better pipelining between all of the steps of the build. All in all,
this makes most builds faster than cargo2nix.
A few other changes have been made to the build scripts and CI:
- Unit tests are now run within a Nix derivation. In fact, we have
different derivations to run the tests using LMDB and Sqlite as
metadata db engines.
- For debug builds, most CI steps now run in parallel (with the notable
exception of the smoke test that runs after the build, which is
inevitable).
- We no longer pass the GIT_VERSION argument when building debug builds
and running the tests. This means that dev binaries and test
binaries don't know the exact version of Garage they are from. That
shouldn't be an issue in most cases.
- The not-dynamic.sh scripts has been fixed to fail if the file does not
exist.
2025-02-01 21:48:10 +01:00
|
|
|
overlays = [ (import rust-overlay) ];
|
2023-01-26 12:20:12 +01:00
|
|
|
}
|
|
|
|
else
|
nix, ci: build with Crane
This removes our dependency on cargo2nix, which was causing us some
issues. Whereas cargo2nix creates one Nix derivation per crate, Crane
uses only two derivations:
1. Build dependencies only
2. Build the final binary
This means that during the second step, no caching can be done. For
instance, if we do a change in garage_model, we need to recompile all of
the Garage crates including those that do not depend on garage_model.
On the upside, this allows all of the Garage crates to be built at once
using cargo build logic, which is optimized for high parallelism and
better pipelining between all of the steps of the build. All in all,
this makes most builds faster than cargo2nix.
A few other changes have been made to the build scripts and CI:
- Unit tests are now run within a Nix derivation. In fact, we have
different derivations to run the tests using LMDB and Sqlite as
metadata db engines.
- For debug builds, most CI steps now run in parallel (with the notable
exception of the smoke test that runs after the build, which is
inevitable).
- We no longer pass the GIT_VERSION argument when building debug builds
and running the tests. This means that dev binaries and test
binaries don't know the exact version of Garage they are from. That
shouldn't be an issue in most cases.
- The not-dynamic.sh scripts has been fixed to fail if the file does not
exist.
2025-02-01 21:48:10 +01:00
|
|
|
pkgsNative;
|
2022-07-25 14:58:47 +02:00
|
|
|
|
nix, ci: build with Crane
This removes our dependency on cargo2nix, which was causing us some
issues. Whereas cargo2nix creates one Nix derivation per crate, Crane
uses only two derivations:
1. Build dependencies only
2. Build the final binary
This means that during the second step, no caching can be done. For
instance, if we do a change in garage_model, we need to recompile all of
the Garage crates including those that do not depend on garage_model.
On the upside, this allows all of the Garage crates to be built at once
using cargo build logic, which is optimized for high parallelism and
better pipelining between all of the steps of the build. All in all,
this makes most builds faster than cargo2nix.
A few other changes have been made to the build scripts and CI:
- Unit tests are now run within a Nix derivation. In fact, we have
different derivations to run the tests using LMDB and Sqlite as
metadata db engines.
- For debug builds, most CI steps now run in parallel (with the notable
exception of the smoke test that runs after the build, which is
inevitable).
- We no longer pass the GIT_VERSION argument when building debug builds
and running the tests. This means that dev binaries and test
binaries don't know the exact version of Garage they are from. That
shouldn't be an issue in most cases.
- The not-dynamic.sh scripts has been fixed to fail if the file does not
exist.
2025-02-01 21:48:10 +01:00
|
|
|
inherit (pkgs) lib stdenv;
|
2022-10-14 15:45:37 +02:00
|
|
|
|
2025-02-03 16:55:14 +01:00
|
|
|
toolchainFn = (p: p.rust-bin.stable."1.82.0".default.override {
|
nix, ci: build with Crane
This removes our dependency on cargo2nix, which was causing us some
issues. Whereas cargo2nix creates one Nix derivation per crate, Crane
uses only two derivations:
1. Build dependencies only
2. Build the final binary
This means that during the second step, no caching can be done. For
instance, if we do a change in garage_model, we need to recompile all of
the Garage crates including those that do not depend on garage_model.
On the upside, this allows all of the Garage crates to be built at once
using cargo build logic, which is optimized for high parallelism and
better pipelining between all of the steps of the build. All in all,
this makes most builds faster than cargo2nix.
A few other changes have been made to the build scripts and CI:
- Unit tests are now run within a Nix derivation. In fact, we have
different derivations to run the tests using LMDB and Sqlite as
metadata db engines.
- For debug builds, most CI steps now run in parallel (with the notable
exception of the smoke test that runs after the build, which is
inevitable).
- We no longer pass the GIT_VERSION argument when building debug builds
and running the tests. This means that dev binaries and test
binaries don't know the exact version of Garage they are from. That
shouldn't be an issue in most cases.
- The not-dynamic.sh scripts has been fixed to fail if the file does not
exist.
2025-02-01 21:48:10 +01:00
|
|
|
targets = lib.optionals (target != null) [ rustTarget ];
|
|
|
|
extensions = [
|
|
|
|
"rust-src"
|
|
|
|
"rustfmt"
|
2023-01-26 12:20:12 +01:00
|
|
|
];
|
nix, ci: build with Crane
This removes our dependency on cargo2nix, which was causing us some
issues. Whereas cargo2nix creates one Nix derivation per crate, Crane
uses only two derivations:
1. Build dependencies only
2. Build the final binary
This means that during the second step, no caching can be done. For
instance, if we do a change in garage_model, we need to recompile all of
the Garage crates including those that do not depend on garage_model.
On the upside, this allows all of the Garage crates to be built at once
using cargo build logic, which is optimized for high parallelism and
better pipelining between all of the steps of the build. All in all,
this makes most builds faster than cargo2nix.
A few other changes have been made to the build scripts and CI:
- Unit tests are now run within a Nix derivation. In fact, we have
different derivations to run the tests using LMDB and Sqlite as
metadata db engines.
- For debug builds, most CI steps now run in parallel (with the notable
exception of the smoke test that runs after the build, which is
inevitable).
- We no longer pass the GIT_VERSION argument when building debug builds
and running the tests. This means that dev binaries and test
binaries don't know the exact version of Garage they are from. That
shouldn't be an issue in most cases.
- The not-dynamic.sh scripts has been fixed to fail if the file does not
exist.
2025-02-01 21:48:10 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
craneLib = (crane.mkLib pkgs).overrideToolchain toolchainFn;
|
|
|
|
|
|
|
|
src = craneLib.cleanCargoSource ../.;
|
2023-01-26 12:20:12 +01:00
|
|
|
|
|
|
|
/* We ship some parts of the code disabled by default by putting them behind a flag.
|
|
|
|
It speeds up the compilation (when the feature is not required) and released crates have less dependency by default (less attack surface, disk space, etc.).
|
|
|
|
But we want to ship these additional features when we release Garage.
|
|
|
|
In the end, we chose to exclude all features from debug builds while putting (all of) them in the release builds.
|
|
|
|
*/
|
|
|
|
rootFeatures = if features != null then
|
|
|
|
features
|
|
|
|
else
|
nix, ci: build with Crane
This removes our dependency on cargo2nix, which was causing us some
issues. Whereas cargo2nix creates one Nix derivation per crate, Crane
uses only two derivations:
1. Build dependencies only
2. Build the final binary
This means that during the second step, no caching can be done. For
instance, if we do a change in garage_model, we need to recompile all of
the Garage crates including those that do not depend on garage_model.
On the upside, this allows all of the Garage crates to be built at once
using cargo build logic, which is optimized for high parallelism and
better pipelining between all of the steps of the build. All in all,
this makes most builds faster than cargo2nix.
A few other changes have been made to the build scripts and CI:
- Unit tests are now run within a Nix derivation. In fact, we have
different derivations to run the tests using LMDB and Sqlite as
metadata db engines.
- For debug builds, most CI steps now run in parallel (with the notable
exception of the smoke test that runs after the build, which is
inevitable).
- We no longer pass the GIT_VERSION argument when building debug builds
and running the tests. This means that dev binaries and test
binaries don't know the exact version of Garage they are from. That
shouldn't be an issue in most cases.
- The not-dynamic.sh scripts has been fixed to fail if the file does not
exist.
2025-02-01 21:48:10 +01:00
|
|
|
([ "bundled-libs" "lmdb" "sqlite" "k2v" ] ++ (lib.optionals release [
|
|
|
|
"consul-discovery"
|
|
|
|
"kubernetes-discovery"
|
|
|
|
"metrics"
|
|
|
|
"telemetry-otlp"
|
|
|
|
"syslog"
|
|
|
|
]));
|
2022-10-13 14:35:39 +02:00
|
|
|
|
nix, ci: build with Crane
This removes our dependency on cargo2nix, which was causing us some
issues. Whereas cargo2nix creates one Nix derivation per crate, Crane
uses only two derivations:
1. Build dependencies only
2. Build the final binary
This means that during the second step, no caching can be done. For
instance, if we do a change in garage_model, we need to recompile all of
the Garage crates including those that do not depend on garage_model.
On the upside, this allows all of the Garage crates to be built at once
using cargo build logic, which is optimized for high parallelism and
better pipelining between all of the steps of the build. All in all,
this makes most builds faster than cargo2nix.
A few other changes have been made to the build scripts and CI:
- Unit tests are now run within a Nix derivation. In fact, we have
different derivations to run the tests using LMDB and Sqlite as
metadata db engines.
- For debug builds, most CI steps now run in parallel (with the notable
exception of the smoke test that runs after the build, which is
inevitable).
- We no longer pass the GIT_VERSION argument when building debug builds
and running the tests. This means that dev binaries and test
binaries don't know the exact version of Garage they are from. That
shouldn't be an issue in most cases.
- The not-dynamic.sh scripts has been fixed to fail if the file does not
exist.
2025-02-01 21:48:10 +01:00
|
|
|
featuresStr = lib.concatStringsSep "," rootFeatures;
|
2022-07-25 14:58:47 +02:00
|
|
|
|
2023-01-26 12:20:12 +01:00
|
|
|
/* We compile fully static binaries with musl to simplify deployment on most systems.
|
|
|
|
When possible, we reactivate PIE hardening (see above).
|
2022-07-25 14:58:47 +02:00
|
|
|
|
2023-01-26 12:20:12 +01:00
|
|
|
Also, if you set the RUSTFLAGS environment variable, the following parameters will
|
|
|
|
be ignored.
|
2022-07-25 14:58:47 +02:00
|
|
|
|
2023-01-26 12:20:12 +01:00
|
|
|
For more information on static builds, please refer to Rust's RFC 1721.
|
|
|
|
https://rust-lang.github.io/rfcs/1721-crt-static.html#specifying-dynamicstatic-c-runtime-linkage
|
2022-07-25 14:58:47 +02:00
|
|
|
*/
|
nix, ci: build with Crane
This removes our dependency on cargo2nix, which was causing us some
issues. Whereas cargo2nix creates one Nix derivation per crate, Crane
uses only two derivations:
1. Build dependencies only
2. Build the final binary
This means that during the second step, no caching can be done. For
instance, if we do a change in garage_model, we need to recompile all of
the Garage crates including those that do not depend on garage_model.
On the upside, this allows all of the Garage crates to be built at once
using cargo build logic, which is optimized for high parallelism and
better pipelining between all of the steps of the build. All in all,
this makes most builds faster than cargo2nix.
A few other changes have been made to the build scripts and CI:
- Unit tests are now run within a Nix derivation. In fact, we have
different derivations to run the tests using LMDB and Sqlite as
metadata db engines.
- For debug builds, most CI steps now run in parallel (with the notable
exception of the smoke test that runs after the build, which is
inevitable).
- We no longer pass the GIT_VERSION argument when building debug builds
and running the tests. This means that dev binaries and test
binaries don't know the exact version of Garage they are from. That
shouldn't be an issue in most cases.
- The not-dynamic.sh scripts has been fixed to fail if the file does not
exist.
2025-02-01 21:48:10 +01:00
|
|
|
codegenOptsMap = {
|
|
|
|
"x86_64-unknown-linux-musl" =
|
|
|
|
[ "target-feature=+crt-static" "link-arg=-static-pie" ];
|
2023-01-26 12:20:12 +01:00
|
|
|
"aarch64-unknown-linux-musl" = [
|
|
|
|
"target-feature=+crt-static"
|
|
|
|
"link-arg=-static"
|
|
|
|
]; # segfault with static-pie
|
|
|
|
"i686-unknown-linux-musl" = [
|
|
|
|
"target-feature=+crt-static"
|
|
|
|
"link-arg=-static"
|
|
|
|
]; # segfault with static-pie
|
nix, ci: build with Crane
This removes our dependency on cargo2nix, which was causing us some
issues. Whereas cargo2nix creates one Nix derivation per crate, Crane
uses only two derivations:
1. Build dependencies only
2. Build the final binary
This means that during the second step, no caching can be done. For
instance, if we do a change in garage_model, we need to recompile all of
the Garage crates including those that do not depend on garage_model.
On the upside, this allows all of the Garage crates to be built at once
using cargo build logic, which is optimized for high parallelism and
better pipelining between all of the steps of the build. All in all,
this makes most builds faster than cargo2nix.
A few other changes have been made to the build scripts and CI:
- Unit tests are now run within a Nix derivation. In fact, we have
different derivations to run the tests using LMDB and Sqlite as
metadata db engines.
- For debug builds, most CI steps now run in parallel (with the notable
exception of the smoke test that runs after the build, which is
inevitable).
- We no longer pass the GIT_VERSION argument when building debug builds
and running the tests. This means that dev binaries and test
binaries don't know the exact version of Garage they are from. That
shouldn't be an issue in most cases.
- The not-dynamic.sh scripts has been fixed to fail if the file does not
exist.
2025-02-01 21:48:10 +01:00
|
|
|
"armv6l-unknown-linux-musleabihf" = [
|
|
|
|
"target-feature=+crt-static"
|
|
|
|
"link-arg=-static"
|
|
|
|
]; # compile as dynamic with static-pie
|
2022-07-25 14:58:47 +02:00
|
|
|
};
|
|
|
|
|
nix, ci: build with Crane
This removes our dependency on cargo2nix, which was causing us some
issues. Whereas cargo2nix creates one Nix derivation per crate, Crane
uses only two derivations:
1. Build dependencies only
2. Build the final binary
This means that during the second step, no caching can be done. For
instance, if we do a change in garage_model, we need to recompile all of
the Garage crates including those that do not depend on garage_model.
On the upside, this allows all of the Garage crates to be built at once
using cargo build logic, which is optimized for high parallelism and
better pipelining between all of the steps of the build. All in all,
this makes most builds faster than cargo2nix.
A few other changes have been made to the build scripts and CI:
- Unit tests are now run within a Nix derivation. In fact, we have
different derivations to run the tests using LMDB and Sqlite as
metadata db engines.
- For debug builds, most CI steps now run in parallel (with the notable
exception of the smoke test that runs after the build, which is
inevitable).
- We no longer pass the GIT_VERSION argument when building debug builds
and running the tests. This means that dev binaries and test
binaries don't know the exact version of Garage they are from. That
shouldn't be an issue in most cases.
- The not-dynamic.sh scripts has been fixed to fail if the file does not
exist.
2025-02-01 21:48:10 +01:00
|
|
|
codegenOpts = if target != null then codegenOptsMap.${target} else [
|
|
|
|
"link-arg=-fuse-ld=mold"
|
|
|
|
];
|
|
|
|
|
|
|
|
commonArgs =
|
|
|
|
{
|
|
|
|
inherit src;
|
|
|
|
pname = "garage";
|
|
|
|
version = "dev";
|
|
|
|
|
|
|
|
strictDeps = true;
|
|
|
|
cargoExtraArgs = "--locked --features ${featuresStr}";
|
|
|
|
cargoTestExtraArgs = "--workspace";
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
pkgsNative.protobuf
|
|
|
|
pkgs.stdenv.cc
|
|
|
|
] ++ lib.optionals (target == null) [
|
|
|
|
pkgs.clang
|
|
|
|
pkgs.mold
|
|
|
|
];
|
|
|
|
|
|
|
|
CARGO_PROFILE = if release then "release" else "dev";
|
|
|
|
CARGO_BUILD_RUSTFLAGS =
|
|
|
|
lib.concatStringsSep
|
|
|
|
" "
|
|
|
|
(builtins.map (flag: "-C ${flag}") codegenOpts);
|
|
|
|
}
|
|
|
|
//
|
|
|
|
(if rustTarget != null then {
|
|
|
|
CARGO_BUILD_TARGET = rustTarget;
|
|
|
|
|
|
|
|
"CARGO_TARGET_${rustTargetEnvMap.${rustTarget}}_LINKER" = "${stdenv.cc.targetPrefix}cc";
|
|
|
|
|
|
|
|
HOST_CC = "${stdenv.cc.nativePrefix}cc";
|
|
|
|
TARGET_CC = "${stdenv.cc.targetPrefix}cc";
|
|
|
|
} else {
|
|
|
|
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER = "clang";
|
|
|
|
});
|
|
|
|
|
|
|
|
in rec {
|
|
|
|
toolchain = toolchainFn pkgs;
|
|
|
|
|
|
|
|
devShell = pkgs.mkShell {
|
|
|
|
buildInputs = [
|
|
|
|
toolchain
|
|
|
|
] ++ (with pkgs; [
|
|
|
|
protobuf
|
|
|
|
clang
|
|
|
|
mold
|
|
|
|
]);
|
|
|
|
};
|
|
|
|
|
|
|
|
# ---- building garage ----
|
|
|
|
|
|
|
|
garage-deps = craneLib.buildDepsOnly commonArgs;
|
|
|
|
|
|
|
|
garage = craneLib.buildPackage (commonArgs // {
|
|
|
|
cargoArtifacts = garage-deps;
|
|
|
|
|
|
|
|
doCheck = false;
|
|
|
|
} //
|
|
|
|
(if git_version != null then {
|
|
|
|
version = git_version;
|
|
|
|
GIT_VERSION = git_version;
|
|
|
|
} else {}));
|
2023-01-26 12:20:12 +01:00
|
|
|
|
nix, ci: build with Crane
This removes our dependency on cargo2nix, which was causing us some
issues. Whereas cargo2nix creates one Nix derivation per crate, Crane
uses only two derivations:
1. Build dependencies only
2. Build the final binary
This means that during the second step, no caching can be done. For
instance, if we do a change in garage_model, we need to recompile all of
the Garage crates including those that do not depend on garage_model.
On the upside, this allows all of the Garage crates to be built at once
using cargo build logic, which is optimized for high parallelism and
better pipelining between all of the steps of the build. All in all,
this makes most builds faster than cargo2nix.
A few other changes have been made to the build scripts and CI:
- Unit tests are now run within a Nix derivation. In fact, we have
different derivations to run the tests using LMDB and Sqlite as
metadata db engines.
- For debug builds, most CI steps now run in parallel (with the notable
exception of the smoke test that runs after the build, which is
inevitable).
- We no longer pass the GIT_VERSION argument when building debug builds
and running the tests. This means that dev binaries and test
binaries don't know the exact version of Garage they are from. That
shouldn't be an issue in most cases.
- The not-dynamic.sh scripts has been fixed to fail if the file does not
exist.
2025-02-01 21:48:10 +01:00
|
|
|
# ---- testing garage ----
|
|
|
|
|
|
|
|
garage-test-bin = craneLib.cargoBuild (commonArgs // {
|
|
|
|
cargoArtifacts = garage-deps;
|
|
|
|
|
|
|
|
pname = "garage-tests";
|
|
|
|
|
|
|
|
CARGO_PROFILE = "test";
|
|
|
|
cargoExtraArgs = "${commonArgs.cargoExtraArgs} --tests --workspace";
|
|
|
|
doCheck = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
garage-test = craneLib.cargoTest (commonArgs // {
|
|
|
|
cargoArtifacts = garage-test-bin;
|
|
|
|
nativeBuildInputs = commonArgs.nativeBuildInputs ++ [
|
|
|
|
pkgs.cacert
|
|
|
|
];
|
|
|
|
} // extraTestEnv);
|
|
|
|
}
|