fix: add simple concurrency limit (#823)
Co-authored-by: Casey Lee <cplee@nektos.com>
This commit is contained in:
parent
a6aea44fb0
commit
4d552e65ce
1 changed files with 15 additions and 1 deletions
|
@ -117,7 +117,16 @@ func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor {
|
||||||
for r, run := range stage.Runs {
|
for r, run := range stage.Runs {
|
||||||
job := run.Job()
|
job := run.Job()
|
||||||
matrixes := job.GetMatrixes()
|
matrixes := job.GetMatrixes()
|
||||||
|
maxParallel := 4
|
||||||
|
if job.Strategy != nil {
|
||||||
|
maxParallel = job.Strategy.MaxParallel
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(matrixes) < maxParallel {
|
||||||
|
maxParallel = len(matrixes)
|
||||||
|
}
|
||||||
|
|
||||||
|
b := 0
|
||||||
for i, matrix := range matrixes {
|
for i, matrix := range matrixes {
|
||||||
rc := runner.newRunContext(run, matrix)
|
rc := runner.newRunContext(run, matrix)
|
||||||
rc.JobName = rc.Name
|
rc.JobName = rc.Name
|
||||||
|
@ -144,9 +153,14 @@ func (runner *runnerImpl) NewPlanExecutor(plan *model.Plan) common.Executor {
|
||||||
return nil
|
return nil
|
||||||
})(WithJobLogger(ctx, jobName, rc.Config.Secrets, rc.Config.InsecureSecrets))
|
})(WithJobLogger(ctx, jobName, rc.Config.Secrets, rc.Config.InsecureSecrets))
|
||||||
})
|
})
|
||||||
|
b++
|
||||||
|
if b == maxParallel {
|
||||||
|
pipeline = append(pipeline, common.NewParallelExecutor(stageExecutor...))
|
||||||
|
stageExecutor = make([]common.Executor, 0)
|
||||||
|
b = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pipeline = append(pipeline, common.NewParallelExecutor(stageExecutor...))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return common.NewPipelineExecutor(pipeline...)
|
return common.NewPipelineExecutor(pipeline...)
|
||||||
|
|
Loading…
Add table
Reference in a new issue