Skip to content

Commit 314b1ab

Browse files
committed
feat: skip downloads for builds with fatal commit conclusions
Prevent downloading target outputs when the commit step has a fatal conclusion, avoiding downloads for builds that failed at the commit stage.
1 parent 445baa6 commit 314b1ab

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

pkg/cmd/build.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,10 @@ func pullBuildOutputs(ctx context.Context, client stainless.Client, res stainles
507507
// Get all targets
508508
allTargets := getBuildTargetInfo(res)
509509

510-
// Filter to only completed targets
510+
// Filter to only completed targets without fatal conclusions
511511
var targets []string
512512
for _, target := range allTargets {
513-
if isTargetCompleted(target.status) {
513+
if isTargetCompleted(target.status) && !hasFailedCommitStep(res, stainless.Target(target.name)) {
514514
targets = append(targets, target.name)
515515
}
516516
}
@@ -571,6 +571,26 @@ func pullBuildOutputs(ctx context.Context, client stainless.Client, res stainles
571571
return nil
572572
}
573573

574+
// hasFailedCommitStep checks if a target has a fatal commit conclusion
575+
func hasFailedCommitStep(build stainless.BuildObject, target stainless.Target) bool {
576+
buildTarget := getBuildTarget(&build, target)
577+
if buildTarget == nil {
578+
return false
579+
}
580+
581+
commitUnion := getStepUnion(buildTarget, "commit")
582+
if commitUnion == nil {
583+
return false
584+
}
585+
586+
status, _, conclusion := extractStepInfo(commitUnion)
587+
if status == "completed" && conclusion == "fatal" {
588+
return true
589+
}
590+
591+
return false
592+
}
593+
574594
// stripHTTPAuth removes HTTP authentication credentials from a URL for display purposes
575595
func stripHTTPAuth(urlStr string) string {
576596
parsedURL, err := url.Parse(urlStr)

0 commit comments

Comments
 (0)