about summary refs log tree commit diff
path: root/nix/buildkite/default.nix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-06-02T17·50+0000
committertazjin <tazjin@tvl.su>2022-06-06T12·02+0000
commitdf83e3d556f3cf99c26f0e9059607d4c5f90a4f0 (patch)
tree0181a3d7dcb7761a267e3978ccbc1e7e44b8c087 /nix/buildkite/default.nix
parent302f7e6623cb2586cc247a873dbf3d9877989dcc (diff)
fix(nix/buildkite): Disable `depends_on` if build phase is not run r/4221
Extra steps that use `depends_on` (e.g. if they need output from their
parent) should not actually depend on their parents build step if the
build phase is not active.

This is required to actually decouple the phases.

Change-Id: I398da9a8a53e97ca3c635342259fc722d54b8e4a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5829
Tested-by: BuildkiteCI
Reviewed-by: ezemtsov <eugene.zemtsov@gmail.com>
Diffstat (limited to 'nix/buildkite/default.nix')
-rw-r--r--nix/buildkite/default.nix19
1 files changed, 15 insertions, 4 deletions
diff --git a/nix/buildkite/default.nix b/nix/buildkite/default.nix
index 7b25b0a865a4..5b40fb79b59c 100644
--- a/nix/buildkite/default.nix
+++ b/nix/buildkite/default.nix
@@ -163,6 +163,11 @@ rec {
       # List of phases to include.
       phases = lib.intersectLists activePhases knownPhases;
 
+      # Is the 'build' phase included? This phase is treated specially
+      # because it always contains the plain Nix builds, and some
+      # logic/optimisation depends on knowing whether is executing.
+      buildEnabled = elem "build" phases;
+
       # Convert a target into all of its steps, separated by build
       # phase (as phases end up in different chunks).
       targetToSteps = target:
@@ -181,7 +186,10 @@ rec {
             (attrValues (mapAttrs (normaliseExtraStep knownPhases overridable)
               (target.meta.ci.extraSteps or { })));
 
-          extraSteps = mapAttrs (_: steps: map mkExtraStep steps) splitExtraSteps;
+          extraSteps = mapAttrs
+            (_: steps:
+              map (mkExtraStep buildEnabled) steps)
+            splitExtraSteps;
         in
         extraSteps // {
           build = [ step ] ++ (extraSteps.build or [ ]);
@@ -373,13 +381,16 @@ rec {
 
   # Create the Buildkite configuration for an extra step, optionally
   # wrapping it in a gate group.
-  mkExtraStep = cfg:
+  mkExtraStep = buildEnabled: cfg:
     let
       step = {
         label = ":gear: ${cfg.label} (from ${cfg.parentLabel})";
         skip = if cfg.alwaysRun then false else cfg.parent.skip or false;
-        # TODO(tazjin): Remember to gate this behaviour with active phases.
-        depends_on = lib.optional (!cfg.alwaysRun && !cfg.needsOutput) cfg.parent.key;
+
+        depends_on = lib.optional
+          (buildEnabled && !cfg.alwaysRun && !cfg.needsOutput)
+          cfg.parent.key;
+
         branches =
           if cfg.branches != null
           then lib.concatStringsSep " " cfg.branches else null;