Skip to content
Snippets Groups Projects
Commit 17ff43b02178 authored by steeve.chailloux's avatar steeve.chailloux
Browse files

parallel build

parent 631ced05d647
No related branches found
No related tags found
1 merge request!4Few updates from downstream
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"sync"
"github.com/go-cmd/cmd" "github.com/go-cmd/cmd"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
...@@ -319,8 +320,27 @@ ...@@ -319,8 +320,27 @@
func (r *Runner) runCommands(tmpDir string, cmds map[string]*cmd.Cmd) ([]string, error) { func (r *Runner) runCommands(tmpDir string, cmds map[string]*cmd.Cmd) ([]string, error) {
var compiled []string var compiled []string
for name, cmd := range cmds { var wg sync.WaitGroup
f, err := r.runCommand(tmpDir, name, cmd) errors := make(chan error, len(cmds))
if err != nil { results := make(chan string, len(cmds))
return nil, err 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 @@ ...@@ -326,3 +346,3 @@
} }
compiled = append(compiled, f.Name()) return compiled, nil
} }
...@@ -328,5 +348,4 @@ ...@@ -328,5 +348,4 @@
} }
return compiled, nil
} }
func (r *Runner) runYtt(tmpDir string, compiled []string) (*os.File, error) { func (r *Runner) runYtt(tmpDir string, compiled []string) (*os.File, error) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment