feat(nix/buildkite): Add parentOverride argument to extra steps
This can be used to override the parent derivation if its output is required, for example to inject versions which are only used during releases to avoid cache-busting. Change-Id: I2211496efa8f9bc98ea43b23e4f3f92c61a6da73 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5184 Tested-by: BuildkiteCI Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: ezemtsov <eugene.zemtsov@gmail.com>
This commit is contained in:
parent
ba7197c271
commit
bb140e16a2
1 changed files with 23 additions and 9 deletions
|
@ -159,6 +159,13 @@ rec {
|
||||||
let
|
let
|
||||||
step = mkStep headBranch parentTargetMap target;
|
step = mkStep headBranch parentTargetMap target;
|
||||||
|
|
||||||
|
# Same step, but with an override function applied. This is
|
||||||
|
# used in mkExtraStep if the extra step needs to modify the
|
||||||
|
# parent derivation somehow.
|
||||||
|
#
|
||||||
|
# Note that this will never affect the label.
|
||||||
|
overridable = f: mkStep headBranch parentTargetMap (f target);
|
||||||
|
|
||||||
# Split build/post-build steps
|
# Split build/post-build steps
|
||||||
splitExtraSteps = partition ({ postStep, ... }: postStep)
|
splitExtraSteps = partition ({ postStep, ... }: postStep)
|
||||||
(attrValues (mapAttrs
|
(attrValues (mapAttrs
|
||||||
|
@ -168,7 +175,7 @@ rec {
|
||||||
})
|
})
|
||||||
(target.meta.ci.extraSteps or { })));
|
(target.meta.ci.extraSteps or { })));
|
||||||
|
|
||||||
mkExtraStep' = { name, value, ... }: mkExtraStep step name value;
|
mkExtraStep' = { name, value, ... }: mkExtraStep overridable name value;
|
||||||
extraBuildSteps = map mkExtraStep' splitExtraSteps.wrong; # 'wrong' -> no prompt
|
extraBuildSteps = map mkExtraStep' splitExtraSteps.wrong; # 'wrong' -> no prompt
|
||||||
extraPostSteps = map mkExtraStep' splitExtraSteps.right; # 'right' -> has prompt
|
extraPostSteps = map mkExtraStep' splitExtraSteps.right; # 'right' -> has prompt
|
||||||
in
|
in
|
||||||
|
@ -260,6 +267,10 @@ rec {
|
||||||
# command. Output will be available as 'result'.
|
# command. Output will be available as 'result'.
|
||||||
# TODO: Figure out multiple-output derivations.
|
# TODO: Figure out multiple-output derivations.
|
||||||
#
|
#
|
||||||
|
# parentOverride (optional): A function (drv -> drv) to override
|
||||||
|
# the parent's target definition when preparing its output. Only
|
||||||
|
# used in extra steps that use needsOutput.
|
||||||
|
#
|
||||||
# branches (optional): Git references (branches, tags ... ) on
|
# branches (optional): Git references (branches, tags ... ) on
|
||||||
# which this step should be allowed to run. List of strings.
|
# which this step should be allowed to run. List of strings.
|
||||||
#
|
#
|
||||||
|
@ -291,15 +302,18 @@ 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 = parent: key: { command
|
mkExtraStep = overridableParent: key:
|
||||||
|
{ command
|
||||||
, label ? key
|
, label ? key
|
||||||
, prompt ? false
|
, prompt ? false
|
||||||
, needsOutput ? false
|
, needsOutput ? false
|
||||||
|
, parentOverride ? (x: x)
|
||||||
, branches ? null
|
, branches ? null
|
||||||
, alwaysRun ? false
|
, alwaysRun ? false
|
||||||
, postBuild ? false
|
, postBuild ? false
|
||||||
}@cfg:
|
}@cfg:
|
||||||
let
|
let
|
||||||
|
parent = overridableParent parentOverride;
|
||||||
parentLabel = parent.env.READTREE_TARGET;
|
parentLabel = parent.env.READTREE_TARGET;
|
||||||
|
|
||||||
step = {
|
step = {
|
||||||
|
|
Loading…
Reference in a new issue