Skip to content

Commit

Permalink
handle reporting errors more gracefully (#1143)
Browse files Browse the repository at this point in the history
  • Loading branch information
motatoes authored Feb 9, 2024
1 parent 50b9944 commit 8f823e4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cli/cmd/digger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,12 @@ func gitHubCI(lock core_locking.Lock, policyChecker core_policy.Checker, backend

if err != nil {
serializedBatch, reportingError := backendApi.ReportProjectJobStatus(repoName, job.ProjectName, inputs.Id, "failed", time.Now(), nil)
digger.UpdateStatusComment(serializedBatch.Jobs, serializedBatch.PrNumber, &githubPrService, commentId64)

if reportingError != nil {
log.Printf("Failed to report job status to backend. %v", reportingError)
reportErrorAndExit(githubActor, fmt.Sprintf("Failed run commands. %s", err), 5)
}
digger.UpdateStatusComment(serializedBatch.Jobs, serializedBatch.PrNumber, &githubPrService, commentId64)

reportErrorAndExit(githubActor, fmt.Sprintf("Failed to run commands. %s", err), 5)
}

Expand All @@ -158,11 +159,10 @@ func gitHubCI(lock core_locking.Lock, policyChecker core_policy.Checker, backend
_, _, err = digger.RunJobs(jobs, &githubPrService, &githubPrService, lock, reporter, planStorage, policyChecker, backendApi, inputs.Id, true, commentId64, currentDir)
if err != nil {
serializedBatch, reportingError := backendApi.ReportProjectJobStatus(repoName, job.ProjectName, inputs.Id, "failed", time.Now(), nil)
digger.UpdateStatusComment(serializedBatch.Jobs, serializedBatch.PrNumber, &githubPrService, commentId64)

if reportingError != nil {
log.Printf("Failed to report job status to backend. %v", reportingError)
reportErrorAndExit(githubActor, fmt.Sprintf("Failed run commands. %s", err), 5)
}
digger.UpdateStatusComment(serializedBatch.Jobs, serializedBatch.PrNumber, &githubPrService, commentId64)
reportErrorAndExit(githubActor, fmt.Sprintf("Failed to run commands. %s", err), 5)
}
reportErrorAndExit(githubActor, "Digger finished successfully", 0)
Expand Down

0 comments on commit 8f823e4

Please sign in to comment.