about summary refs log tree commit diff
path: root/tvix/utils.nix
diff options
context:
space:
mode:
authorIlan Joselevich <personal@ilanjoselevich.com>2024-05-26T14·27+0300
committerIlan Joselevich <personal@ilanjoselevich.com>2024-06-03T16·35+0000
commit1b39d5868adb93175202353b910789f323e63ce1 (patch)
tree2469a20f90b93e299a0ea05c1fc0132684c9e374 /tvix/utils.nix
parentc93849a3fc943d106532e94ccf06cbe19e49d929 (diff)
feat(tvix): add CI targets for checking crate features powerset r/8211
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
Diffstat (limited to 'tvix/utils.nix')
-rw-r--r--tvix/utils.nix23
1 files changed, 23 insertions, 0 deletions
diff --git a/tvix/utils.nix b/tvix/utils.nix
new file mode 100644
index 000000000000..ed751566bd9c
--- /dev/null
+++ b/tvix/utils.nix
@@ -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));
+}