Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not run clone step if no pipeline step will run #877

Merged
merged 14 commits into from
May 18, 2022
10 changes: 10 additions & 0 deletions agent/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ func (r *Runner) Run(ctx context.Context) error {
return nil
}

if len(work.Config.Stages) < 1 {
qwerty287 marked this conversation as resolved.
Show resolved Hide resolved
state := rpc.State{}
state.Started = time.Now().Unix()
_ = r.client.Init(ctxmeta, work.ID, state)
state.Finished = time.Now().Unix()
state.Exited = true
_ = r.client.Done(ctxmeta, work.ID, state)
return nil
}

timeout := time.Hour
if minutes := work.Timeout; minutes != 0 {
timeout = time.Duration(minutes) * time.Minute
Expand Down
10 changes: 9 additions & 1 deletion pipeline/frontend/yaml/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ func (c *Compiler) Compile(conf *yaml.Config) *backend.Config {
config.Stages = append(config.Stages, stage)
}

var stages []*backend.Stage
// add pipeline steps. 1 pipeline step per stage, at the moment
var stage *backend.Stage
var group string
Expand All @@ -199,14 +200,21 @@ func (c *Compiler) Compile(conf *yaml.Config) *backend.Config {
stage = new(backend.Stage)
stage.Name = fmt.Sprintf("%s_stage_%v", c.prefix, i)
stage.Alias = container.Name
config.Stages = append(config.Stages, stage)
stages = append(stages, stage)
}

name := fmt.Sprintf("%s_step_%d", c.prefix, i)
step := c.createProcess(name, container, "pipeline")
stage.Steps = append(stage.Steps, step)
}

if len(stages) == 0 {
// nothing will run, remove services and clone step
config.Stages = []*backend.Stage{}
} else {
config.Stages = append(config.Stages, stages...)
}

c.setupCacheRebuild(conf, config)

return config
Expand Down
4 changes: 0 additions & 4 deletions server/shared/procBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@ func (b *ProcBuilder) Build() ([]*BuildItem, error) {

ir := b.toInternalRepresentation(parsed, environ, metadata, proc.ID)

if len(ir.Stages) == 0 {
continue
}
qwerty287 marked this conversation as resolved.
Show resolved Hide resolved

item := &BuildItem{
Proc: proc,
Config: ir,
Expand Down
4 changes: 4 additions & 0 deletions web/src/components/repo/build/BuildProcList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@
</div>
</div>
</div>
<div v-if="proc.children === undefined || proc.children.length === 0" class="text-center m-auto">
<span>No pipeline steps available!</span>
</div>
<div
v-for="job in proc.children"
v-else
:key="job.pid"
class="flex p-2 pl-6 cursor-pointer items-center hover:bg-gray-700 hover:dark:bg-dark-gray-900"
:class="{ 'bg-gray-700 !dark:bg-dark-gray-600': selectedProcId && selectedProcId === job.pid }"
Expand Down