Skip to content

Commit

Permalink
Always write the update output file, even on container failure (#376)
Browse files Browse the repository at this point in the history
* Always write update output file, even on container failure

* Fix typo

* Tidy code
  • Loading branch information
rhyskoedijk authored Oct 31, 2024
1 parent 9b18a3b commit 6aa84ce
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions internal/infra/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,15 @@ func Run(params RunParams) error {
if params.ApiUrl == "" {
params.ApiUrl = fmt.Sprintf("http://host.docker.internal:%v", api.Port())
}
if err := runContainers(ctx, params); err != nil {
return err
}

// run the containers, but don't return the error until AFTER the output is generated.
// this ensures that the output is always written in the scenario where there are multiple outputs,
// some that succeed and some that fail; we still want to see the output of the successful ones.
runContainersErr := runContainers(ctx, params)

api.Complete()

// write the output to a file
output, err := generateOutput(params, api, outFile)
if err != nil {
return err
Expand All @@ -146,7 +149,7 @@ func Run(params RunParams) error {
return diff(params, outFile, output)
}

return nil
return runContainersErr
}

func generateOutput(params RunParams, api *server.API, outFile *os.File) ([]byte, error) {
Expand Down

0 comments on commit 6aa84ce

Please sign in to comment.