feat(ops/buildkite): Support "soft failures"

Example Usage:

```nix
{ pkgs, ... }:

(pkgs.writeText "foo" "bar").overrideAttrs (_: {
  meta.ci.extraSteps.bar = {
    label = "testing soft_fail";
    softFail = [
      { exit_status = 253; }
      { exit_status = 251; }
    ];
    command = pkgs.writeShellScript "fail" ''
      # Trigger a soft failure by exiting 253 or 251
      exit 253
    '';
  };
})
```

Buildkite Documentation: https://buildkite.com/changelog/56-command-steps-can-now-be-made-to-soft-fail

Change-Id: Idfce15a8d9cde568aa24ebd03956ada399bba5d2
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7076
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
William Carroll 2022-10-24 10:16:40 -04:00 committed by wpcarro
parent 9ada456260
commit 1cd7678bdb

View file

@ -331,6 +331,7 @@ rec {
, branches ? null , branches ? null
, alwaysRun ? false , alwaysRun ? false
, prompt ? false , prompt ? false
, softFail ? false
# TODO(tazjin): Default to 'build' after 2022-10-01. # TODO(tazjin): Default to 'build' after 2022-10-01.
, phase ? if (isNull postBuild || !postBuild) then "build" else "release" , phase ? if (isNull postBuild || !postBuild) then "build" else "release"
@ -363,6 +364,7 @@ rec {
needsOutput needsOutput
parent parent
parentLabel parentLabel
softFail
skip skip
agents; agents;
@ -430,6 +432,8 @@ rec {
echo '+++ Running extra step command' echo '+++ Running extra step command'
exec ${cfg.command} exec ${cfg.command}
''; '';
soft_fail = cfg.softFail;
} // (lib.optionalAttrs (cfg.agents != null) { inherit (cfg) agents; }) } // (lib.optionalAttrs (cfg.agents != null) { inherit (cfg) agents; })
// (lib.optionalAttrs (cfg.branches != null) { // (lib.optionalAttrs (cfg.branches != null) {
branches = lib.concatStringsSep " " cfg.branches; branches = lib.concatStringsSep " " cfg.branches;