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

parallel build


Signed-off-by: default avatarSteeve Chailloux <steeve.chailloux@proton.ch>
parent 631ced05d647
No related branches found
No related tags found
No related merge requests found
......@@ -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) {
......
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