From df83e3d556f3cf99c26f0e9059607d4c5f90a4f0 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 2 Jun 2022 17:50:01 +0000 Subject: fix(nix/buildkite): Disable `depends_on` if build phase is not run 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 --- nix/buildkite/default.nix | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/nix/buildkite/default.nix b/nix/buildkite/default.nix index 7b25b0a865..5b40fb79b5 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; -- cgit 1.4.1