Skip to content
This repository has been archived by the owner on Sep 29, 2021. It is now read-only.

Commit

Permalink
Merge pull request #77 from suzuki-shunsuke/fix/fix-pahse-status-when…
Browse files Browse the repository at this point in the history
…-skipped

fix: fix the status of skipped phase
  • Loading branch information
suzuki-shunsuke authored Oct 15, 2020
2 parents 473c141 + e9fead7 commit e3d6d33
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions examples/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func TestBuildflow(t *testing.T) { //nolint:funlen
title: "dynamic task by items",
file: "dynamic_task.yaml",
},
{
title: "skip a phase",
file: "skip_phase.yaml",
},
{
title: "buildflow run fails as expected",
file: "fail.yaml",
Expand Down
9 changes: 9 additions & 0 deletions examples/skip_phase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
phases:
- name: skipped
tasks:
- name: hello
command:
command: echo hello
condition:
skip: true
4 changes: 2 additions & 2 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func (ctrl Controller) runPhase(ctx context.Context, params Params, idx int, wd
params.Phases[params.PhaseName] = phase

if p, f := ctrl.checkSkipPhase(params, phase, phaseCfg); f {
return phase, nil
return p, nil
} else {
phase = p
}
Expand Down Expand Up @@ -509,8 +509,8 @@ func (ctrl Controller) Run(ctx context.Context, wd string) error {
if phase.Error != nil {
phase.Status = constant.Failed
}
phase.outputResult(ctrl.Stderr, phaseCfg.Name)
params.Phases[phaseCfg.Name] = phase
phase.outputResult(ctrl.Stderr, phaseCfg.Name)
if err != nil {
return err
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/phase.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ func (phase Phase) outputResult(stderr io.Writer, name string) {
if phase.Error != nil {
fmt.Fprintln(stderr, "error:", phase.Error)
}
if phase.Status == constant.Skipped {
return
}
utc := locale.UTC()
runTasks := []Task{}
for _, task := range phase.Tasks.GetAll() {
Expand Down

0 comments on commit e3d6d33

Please sign in to comment.