Skip to content

Commit

Permalink
Merge pull request #3 from gitbugactions/maxparallel
Browse files Browse the repository at this point in the history
  • Loading branch information
andre15silva authored Nov 3, 2023
2 parents de53f69 + 5db572f commit 5c84034
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Input struct {
containerDaemonSocket string
containerOptions string
volumeOptions string
maxParallel int
noWorkflowRecurse bool
useGitIgnore bool
githubInstance string
Expand Down
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func Execute(ctx context.Context, version string) {
rootCmd.PersistentFlags().StringVarP(&input.containerDaemonSocket, "container-daemon-socket", "", "", "URI to Docker Engine socket (e.g.: unix://~/.docker/run/docker.sock or - to disable bind mounting the socket)")
rootCmd.PersistentFlags().StringVarP(&input.containerOptions, "container-options", "", "", "Custom docker container options for the job container without an options property in the job definition")
rootCmd.PersistentFlags().StringVarP(&input.volumeOptions, "volume-options", "", "", "Custom docker volume options for the job volume")
rootCmd.PersistentFlags().IntVarP(&input.maxParallel, "max-parallel", "", runtime.NumCPU(), "Maximum number of jobs to run in parallel")
rootCmd.PersistentFlags().StringVarP(&input.githubInstance, "github-instance", "", "github.com", "GitHub instance to use. Don't use this if you are not using GitHub Enterprise Server.")
rootCmd.PersistentFlags().StringVarP(&input.artifactServerPath, "artifact-server-path", "", "", "Defines the path where the artifact server stores uploads and retrieves downloads from. If not specified the artifact server will not start.")
rootCmd.PersistentFlags().StringVarP(&input.artifactServerAddr, "artifact-server-addr", "", common.GetOutboundIP().String(), "Defines the address to which the artifact server binds.")
Expand Down Expand Up @@ -599,6 +600,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
ContainerDaemonSocket: input.containerDaemonSocket,
ContainerOptions: input.containerOptions,
VolumeOptions: input.volumeOptions,
MaxParallel: input.maxParallel,
UseGitIgnore: input.useGitIgnore,
GitHubInstance: input.githubInstance,
ContainerCapAdd: input.containerCapAdd,
Expand Down
4 changes: 2 additions & 2 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"os"
"runtime"

log "github.com/sirupsen/logrus"

Expand Down Expand Up @@ -45,6 +44,7 @@ type Config struct {
ContainerDaemonSocket string // Path to Docker daemon socket
ContainerOptions string // Options for the job container
VolumeOptions string // Options for the job volume
MaxParallel int // maximum number of jobs to run in parallel
UseGitIgnore bool // controls if paths in .gitignore should not be copied into container, default true
GitHubInstance string // GitHub instance to use, default "github.com"
ContainerCapAdd []string // list of kernel capabilities to add to the containers
Expand Down Expand Up @@ -187,7 +187,7 @@ func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor {
}
pipeline = append(pipeline, common.NewParallelExecutor(maxParallel, stageExecutor...))
}
ncpu := runtime.NumCPU()
ncpu := runner.config.MaxParallel
if 1 > ncpu {
ncpu = 1
}
Expand Down

0 comments on commit 5c84034

Please sign in to comment.