From 302f7e6623cb2586cc247a873dbf3d9877989dcc Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Thu, 2 Jun 2022 17:45:45 +0000 Subject: feat(nix/buildkite): Allow toggling of individual phases 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 --- nix/buildkite/default.nix | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/nix/buildkite/default.nix b/nix/buildkite/default.nix index 5b83f9c6618a..7b25b0a865a4 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; -- cgit 1.4.1