about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-06-02T17·45+0000
committertazjin <tazjin@tvl.su>2022-06-06T12·02+0000
commit302f7e6623cb2586cc247a873dbf3d9877989dcc (patch)
tree62fb7e9503029494f89f80ac65024aa197287089
parentebd701b221a7df872b4514aa758c7e410fedc3c8 (diff)
feat(nix/buildkite): Allow toggling of individual phases r/4220
Using the `activePhases` attribute, the set of phases included in an
evaluation can be modified.

This lets users generate e.g. ONLY the release steps of a pipeline.

Change-Id: Ib0c38826dd69666094d619f5f324d1baafce8134
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5828
Tested-by: BuildkiteCI
Reviewed-by: ezemtsov <eugene.zemtsov@gmail.com>
-rw-r--r--nix/buildkite/default.nix24
1 files changed, 18 insertions, 6 deletions
diff --git a/nix/buildkite/default.nix b/nix/buildkite/default.nix
index 5b83f9c66..7b25b0a86 100644
--- a/nix/buildkite/default.nix
+++ b/nix/buildkite/default.nix
@@ -142,14 +142,26 @@ rec {
       #
       # Can be used for status reporting steps and the like.
       postBuildSteps ? [ ]
+    , # Build phases that are active for this invocation (i.e. their
+      # steps should be generated).
+      #
+      # This can be used to disable outputting parts of a pipeline if,
+      # for example, build and release phases are created in separate
+      # eval contexts.
+      #
+      # TODO(tazjin): Fail/warn if unknown phase is requested.
+      activePhases ? [ "build" "release" ]
     }:
     let
-      # List of phases to include. Currently the only phases are 'build'
-      # (Nix builds and extra steps that are not post-build steps) and
-      # 'post' (all post-build steps).
+      # Currently the only known phases are 'build' (Nix builds and
+      # extra steps that are not post-build steps) and 'release' (all
+      # post-build steps).
       #
-      # TODO(tazjin): Configurable set of phases.
-      phases = [ "build" "release" ];
+      # TODO(tazjin): Fully configurable set of phases?
+      knownPhases = [ "build" "release" ];
+
+      # List of phases to include.
+      phases = lib.intersectLists activePhases knownPhases;
 
       # Convert a target into all of its steps, separated by build
       # phase (as phases end up in different chunks).
@@ -166,7 +178,7 @@ rec {
 
           # Split extra steps by phase.
           splitExtraSteps = lib.groupBy ({ phase, ... }: phase)
-            (attrValues (mapAttrs (normaliseExtraStep phases overridable)
+            (attrValues (mapAttrs (normaliseExtraStep knownPhases overridable)
               (target.meta.ci.extraSteps or { })));
 
           extraSteps = mapAttrs (_: steps: map mkExtraStep steps) splitExtraSteps;