diff --git a/runner/main.go b/runner/main.go index 631ced05d647e32398b1a98ba1b7838678c86a15_cnVubmVyL21haW4uZ28=..d2afc2eb71f79fe6baa21430cdb6b28c2945515d_cnVubmVyL21haW4uZ28= 100644 --- a/runner/main.go +++ b/runner/main.go @@ -8,6 +8,7 @@ "os" "path/filepath" "strings" + "sync" "github.com/go-cmd/cmd" "gopkg.in/yaml.v3" @@ -319,8 +320,27 @@ func (r *Runner) runCommands(tmpDir string, cmds map[string]*cmd.Cmd) ([]string, error) { var compiled []string - for name, cmd := range cmds { - f, err := r.runCommand(tmpDir, name, cmd) - if err != nil { - return nil, err + var wg sync.WaitGroup + errors := make(chan error, len(cmds)) + results := make(chan string, len(cmds)) + for name, command := range cmds { + wg.Add(1) + go func(name string, c *cmd.Cmd) { + defer wg.Done() + f, err := r.runCommand(tmpDir, name, c) + if err != nil { + errors <- err + } + results <- f.Name() + }(name, command) + } + wg.Wait() + select { + case err := <-errors: + // return only the first error if any + return nil, err + default: + close(results) + for res := range results { + compiled = append(compiled, res) } @@ -326,3 +346,3 @@ } - compiled = append(compiled, f.Name()) + return compiled, nil } @@ -328,5 +348,4 @@ } - return compiled, nil } func (r *Runner) runYtt(tmpDir string, compiled []string) (*os.File, error) {