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 <eugene.zemtsov@gmail.com>
This commit is contained in:
parent
302f7e6623
commit
df83e3d556
1 changed files with 15 additions and 4 deletions
|
@ -163,6 +163,11 @@ rec {
|
||||||
# List of phases to include.
|
# List of phases to include.
|
||||||
phases = lib.intersectLists activePhases knownPhases;
|
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
|
# Convert a target into all of its steps, separated by build
|
||||||
# phase (as phases end up in different chunks).
|
# phase (as phases end up in different chunks).
|
||||||
targetToSteps = target:
|
targetToSteps = target:
|
||||||
|
@ -181,7 +186,10 @@ rec {
|
||||||
(attrValues (mapAttrs (normaliseExtraStep knownPhases overridable)
|
(attrValues (mapAttrs (normaliseExtraStep knownPhases overridable)
|
||||||
(target.meta.ci.extraSteps or { })));
|
(target.meta.ci.extraSteps or { })));
|
||||||
|
|
||||||
extraSteps = mapAttrs (_: steps: map mkExtraStep steps) splitExtraSteps;
|
extraSteps = mapAttrs
|
||||||
|
(_: steps:
|
||||||
|
map (mkExtraStep buildEnabled) steps)
|
||||||
|
splitExtraSteps;
|
||||||
in
|
in
|
||||||
extraSteps // {
|
extraSteps // {
|
||||||
build = [ step ] ++ (extraSteps.build or [ ]);
|
build = [ step ] ++ (extraSteps.build or [ ]);
|
||||||
|
@ -373,13 +381,16 @@ rec {
|
||||||
|
|
||||||
# Create the Buildkite configuration for an extra step, optionally
|
# Create the Buildkite configuration for an extra step, optionally
|
||||||
# wrapping it in a gate group.
|
# wrapping it in a gate group.
|
||||||
mkExtraStep = cfg:
|
mkExtraStep = buildEnabled: cfg:
|
||||||
let
|
let
|
||||||
step = {
|
step = {
|
||||||
label = ":gear: ${cfg.label} (from ${cfg.parentLabel})";
|
label = ":gear: ${cfg.label} (from ${cfg.parentLabel})";
|
||||||
skip = if cfg.alwaysRun then false else cfg.parent.skip or false;
|
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 =
|
branches =
|
||||||
if cfg.branches != null
|
if cfg.branches != null
|
||||||
then lib.concatStringsSep " " cfg.branches else null;
|
then lib.concatStringsSep " " cfg.branches else null;
|
||||||
|
|
Loading…
Reference in a new issue