feat(tvix): add CI targets for checking crate features powerset
Closes: https://b.tvl.fyi/issues/401 With this change all crate features (and their combinations) will be built and tested in CI. From now on, when adding/removing a Cargo feature for a crate, you will want to add it to the features power set that gets tested in CI. For each crate there's a default.nix with a `mkFeaturePowerset` invocation, modify the list to include/remove the feature. Note that you don't want to add "collection" features, such as `fs` for tvix-[ca]store or `default`. Change-Id: I966dde1413d057770787da3296cce9c1924570e0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11717 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
This commit is contained in:
parent
c93849a3fc
commit
1b39d5868a
10 changed files with 112 additions and 47 deletions
|
@ -104,6 +104,11 @@ Rust projects under `//tvix`, be sure to run
|
|||
`mg run //tools:crate2nix-generate` in `//tvix` itself and commit the changes
|
||||
to the generated `Cargo.nix` file. This only applies to the full TVL checkout.
|
||||
|
||||
When adding/removing a Cargo feature for a crate, you will want to add it to the
|
||||
features power set that gets tested in CI. For each crate there's a default.nix with a
|
||||
`mkFeaturePowerset` invocation, modify the list to include/remove the feature.
|
||||
Note that you don't want to add "collection" features, such as `fs` for tvix-[ca]store or `default`.
|
||||
|
||||
## License structure
|
||||
|
||||
All code implemented for Tvix is licensed under the GPL-3.0, with the
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
{ depot, pkgs, ... }:
|
||||
{ depot, lib, ... }:
|
||||
|
||||
depot.tvix.crates.workspaceMembers.tvix-build.build.override {
|
||||
(depot.tvix.crates.workspaceMembers.tvix-build.build.override {
|
||||
runTests = true;
|
||||
}
|
||||
}).overrideAttrs (old: rec {
|
||||
meta.ci.targets = lib.filter (x: lib.hasPrefix "with-features" x || x == "no-features") (lib.attrNames passthru);
|
||||
passthru = depot.tvix.utils.mkFeaturePowerset {
|
||||
inherit (old) crateName;
|
||||
features = [ "tonic-reflection" ];
|
||||
};
|
||||
})
|
||||
|
|
|
@ -92,7 +92,7 @@ rstest_reuse = "0.6.0"
|
|||
xattr = "1.3.1"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
default = ["cloud"]
|
||||
cloud = [
|
||||
"dep:bigtable_rs",
|
||||
"object_store/aws",
|
||||
|
|
|
@ -1,23 +1,28 @@
|
|||
{ depot, pkgs, ... }:
|
||||
{ depot, pkgs, lib, ... }:
|
||||
|
||||
(depot.tvix.crates.workspaceMembers.tvix-castore.build.override {
|
||||
runTests = true;
|
||||
testPreRun = ''
|
||||
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt;
|
||||
'';
|
||||
|
||||
# enable some optional features.
|
||||
features = [ "default" "cloud" ];
|
||||
}).overrideAttrs (_: {
|
||||
meta.ci.targets = [ "integration-tests" ];
|
||||
passthru.integration-tests = depot.tvix.crates.workspaceMembers.tvix-castore.build.override {
|
||||
}).overrideAttrs (old: rec {
|
||||
meta.ci.targets = [ "integration-tests" ] ++ lib.filter (x: lib.hasPrefix "with-features" x || x == "no-features") (lib.attrNames passthru);
|
||||
passthru = (depot.tvix.utils.mkFeaturePowerset {
|
||||
inherit (old) crateName;
|
||||
features = ([ "cloud" "fuse" "tonic-reflection" ]
|
||||
# virtiofs feature currently fails to build on Darwin
|
||||
++ lib.optional pkgs.stdenv.isLinux "virtiofs");
|
||||
override.testPreRun = ''
|
||||
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
|
||||
'';
|
||||
}) // {
|
||||
integration-tests = depot.tvix.crates.workspaceMembers.${old.crateName}.build.override (old: {
|
||||
runTests = true;
|
||||
testPreRun = ''
|
||||
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt;
|
||||
export PATH="$PATH:${pkgs.lib.makeBinPath [ pkgs.cbtemulator pkgs.google-cloud-bigtable-tool ]}"
|
||||
'';
|
||||
|
||||
# enable some optional features.
|
||||
features = [ "default" "cloud" "integration" ];
|
||||
features = old.features ++ [ "integration" ];
|
||||
});
|
||||
};
|
||||
})
|
||||
|
|
|
@ -293,4 +293,6 @@ in
|
|||
"shell"
|
||||
"rust-docs"
|
||||
];
|
||||
|
||||
utils = import ./utils.nix { inherit lib depot; };
|
||||
}
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
# TODO: find a way to build the benchmarks via crate2nix
|
||||
{ depot, pkgs, ... }:
|
||||
{ depot, pkgs, lib, ... }:
|
||||
|
||||
depot.tvix.crates.workspaceMembers.tvix-eval.build.override {
|
||||
(depot.tvix.crates.workspaceMembers.tvix-eval.build.override {
|
||||
runTests = true;
|
||||
|
||||
# Make C++ Nix available, to compare eval results against.
|
||||
testInputs = [ pkgs.nix ];
|
||||
}
|
||||
}).overrideAttrs (old: rec {
|
||||
meta.ci.targets = lib.filter (x: lib.hasPrefix "with-features" x || x == "no-features") (lib.attrNames passthru);
|
||||
passthru = depot.tvix.utils.mkFeaturePowerset {
|
||||
inherit (old) crateName;
|
||||
features = [ "nix_tests" ];
|
||||
override.testInputs = [ pkgs.nix ];
|
||||
};
|
||||
})
|
||||
|
|
|
@ -1,8 +1,17 @@
|
|||
{ depot, pkgs, ... }:
|
||||
{ depot, pkgs, lib, ... }:
|
||||
|
||||
(depot.tvix.crates.workspaceMembers.tvix-glue.build.override {
|
||||
runTests = true;
|
||||
testPreRun = ''
|
||||
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt;
|
||||
'';
|
||||
}).overrideAttrs (old: rec {
|
||||
meta.ci.targets = lib.filter (x: lib.hasPrefix "with-features" x || x == "no-features") (lib.attrNames passthru);
|
||||
passthru = depot.tvix.utils.mkFeaturePowerset {
|
||||
inherit (old) crateName;
|
||||
features = [ "nix_tests" ];
|
||||
override.testPreRun = ''
|
||||
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt;
|
||||
'';
|
||||
};
|
||||
})
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
{ depot, ... }:
|
||||
{ depot, lib, ... }:
|
||||
|
||||
depot.tvix.crates.workspaceMembers.nix-compat.build.override {
|
||||
(depot.tvix.crates.workspaceMembers.nix-compat.build.override {
|
||||
runTests = true;
|
||||
# make sure we also enable async here, so run the tests behind that feature flag.
|
||||
features = [ "default" "async" "wire" ];
|
||||
}
|
||||
}).overrideAttrs (old: rec {
|
||||
meta.ci.targets = lib.filter (x: lib.hasPrefix "with-features" x || x == "no-features") (lib.attrNames passthru);
|
||||
passthru = depot.tvix.utils.mkFeaturePowerset {
|
||||
inherit (old) crateName;
|
||||
features = [ "async" "wire" ];
|
||||
};
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ depot, pkgs, ... }:
|
||||
{ depot, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
mkImportCheck = p: expectedPath: {
|
||||
|
@ -22,31 +22,35 @@ let
|
|||
};
|
||||
in
|
||||
|
||||
(depot.tvix.crates.workspaceMembers.tvix-store.build.override {
|
||||
(depot.tvix.crates.workspaceMembers.tvix-store.build.override (old: {
|
||||
runTests = true;
|
||||
testPreRun = ''
|
||||
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
|
||||
'';
|
||||
|
||||
# enable some optional features.
|
||||
features = [ "default" "cloud" ]
|
||||
# virtiofs feature currently fails to build on Darwin.
|
||||
++ pkgs.lib.optional pkgs.stdenv.isLinux "virtiofs";
|
||||
}).overrideAttrs (_: {
|
||||
meta.ci.targets = [ "integration-tests" ];
|
||||
meta.ci.extraSteps = {
|
||||
import-docs = (mkImportCheck "tvix/store/docs" ./docs);
|
||||
features = old.features
|
||||
# virtiofs feature currently fails to build on Darwin
|
||||
++ lib.optional pkgs.stdenv.isLinux "virtiofs";
|
||||
})).overrideAttrs (old: rec {
|
||||
meta.ci = {
|
||||
targets = [ "integration-tests" ] ++ lib.filter (x: lib.hasPrefix "with-features" x || x == "no-features") (lib.attrNames passthru);
|
||||
extraSteps.import-docs = (mkImportCheck "tvix/store/docs" ./docs);
|
||||
};
|
||||
passthru.integration-tests = depot.tvix.crates.workspaceMembers.tvix-store.build.override {
|
||||
passthru = (depot.tvix.utils.mkFeaturePowerset {
|
||||
inherit (old) crateName;
|
||||
features = ([ "cloud" "fuse" "otlp" "tonic-reflection" ]
|
||||
# virtiofs feature currently fails to build on Darwin
|
||||
++ lib.optional pkgs.stdenv.isLinux "virtiofs");
|
||||
override.testPreRun = ''
|
||||
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
|
||||
'';
|
||||
}) // {
|
||||
integration-tests = depot.tvix.crates.workspaceMembers.${old.crateName}.build.override (old: {
|
||||
runTests = true;
|
||||
testPreRun = ''
|
||||
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt
|
||||
export SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt;
|
||||
export PATH="$PATH:${pkgs.lib.makeBinPath [ pkgs.cbtemulator pkgs.google-cloud-bigtable-tool ]}"
|
||||
'';
|
||||
|
||||
# enable some optional features.
|
||||
features = [ "default" "cloud" "integration" ]
|
||||
# virtiofs feature currently fails to build on Darwin.
|
||||
++ pkgs.lib.optional pkgs.stdenv.isLinux "virtiofs";
|
||||
features = old.features ++ [ "integration" ];
|
||||
});
|
||||
};
|
||||
})
|
||||
|
|
23
tvix/utils.nix
Normal file
23
tvix/utils.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{ lib, depot, ... }:
|
||||
|
||||
{
|
||||
mkFeaturePowerset = { crateName, features, override ? { } }:
|
||||
let
|
||||
powerset = xs:
|
||||
let
|
||||
addElement = set: element:
|
||||
set ++ map (e: [ element ] ++ e) set;
|
||||
in
|
||||
lib.foldl' addElement [ [ ] ] xs;
|
||||
in
|
||||
lib.listToAttrs (map
|
||||
(featuresPowerset: {
|
||||
name = if featuresPowerset != [ ] then "with-features-${lib.concatStringsSep "-" featuresPowerset}" else "no-features";
|
||||
value = depot.tvix.crates.workspaceMembers.${crateName}.build.override (old: {
|
||||
runTests = true;
|
||||
features = featuresPowerset;
|
||||
} // (if lib.isFunction override then override old else override)
|
||||
);
|
||||
})
|
||||
(powerset features));
|
||||
}
|
Loading…
Reference in a new issue