feat: add bug-report flag (#1056)
* feat: add bug-report flag * fix: use docker host CPU count * feat: add config files to bug-report Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
@@ -201,10 +201,7 @@ type containerReference struct {
|
||||
input *NewContainerInput
|
||||
}
|
||||
|
||||
func GetDockerClient(ctx context.Context) (*client.Client, error) {
|
||||
var err error
|
||||
var cli *client.Client
|
||||
|
||||
func GetDockerClient(ctx context.Context) (cli *client.Client, err error) {
|
||||
// TODO: this should maybe need to be a global option, not hidden in here?
|
||||
// though i'm not sure how that works out when there's another Executor :D
|
||||
// I really would like something that works on OSX native for eg
|
||||
@@ -232,6 +229,22 @@ func GetDockerClient(ctx context.Context) (*client.Client, error) {
|
||||
return cli, err
|
||||
}
|
||||
|
||||
func GetHostInfo(ctx context.Context) (info types.Info, err error) {
|
||||
var cli *client.Client
|
||||
cli, err = GetDockerClient(ctx)
|
||||
if err != nil {
|
||||
return info, err
|
||||
}
|
||||
defer cli.Close()
|
||||
|
||||
info, err = cli.Info(ctx)
|
||||
if err != nil {
|
||||
return info, err
|
||||
}
|
||||
|
||||
return info, nil
|
||||
}
|
||||
|
||||
func (cr *containerReference) connect() common.Executor {
|
||||
return func(ctx context.Context) error {
|
||||
if cr.cli != nil {
|
||||
|
@@ -9,9 +9,11 @@ import (
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/nektos/act/pkg/common"
|
||||
"github.com/nektos/act/pkg/model"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/nektos/act/pkg/common"
|
||||
"github.com/nektos/act/pkg/container"
|
||||
"github.com/nektos/act/pkg/model"
|
||||
)
|
||||
|
||||
// Runner provides capabilities to run GitHub actions
|
||||
@@ -171,7 +173,15 @@ func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor {
|
||||
}
|
||||
pipeline = append(pipeline, common.NewParallelExecutor(maxParallel, stageExecutor...))
|
||||
}
|
||||
return common.NewParallelExecutor(runtime.NumCPU(), pipeline...)(ctx)
|
||||
var ncpu int
|
||||
info, err := container.GetHostInfo(ctx)
|
||||
if err != nil {
|
||||
log.Errorf("failed to obtain container engine info: %s", err)
|
||||
ncpu = 1 // sane default?
|
||||
} else {
|
||||
ncpu = info.NCPU
|
||||
}
|
||||
return common.NewParallelExecutor(ncpu, pipeline...)(ctx)
|
||||
})
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user