Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions executor/linux/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,24 @@ func (c *client) ExecStage(ctx context.Context, s *pipeline.Stage, m *sync.Map)
}()

logger.Debug("starting execution of stage")

stop := false

// execute the steps for the stage
for _, _step := range s.Steps {
// check if the step should be skipped
//
// https://pkg.go.dev/github.com/go-vela/worker/internal/step#Skip
ruleset := _step.Ruleset

if !stop && s.Independent {
ruleset.If.Parallel = true
} else {
ruleset.If.Parallel = false
}

_step.Ruleset = ruleset

if step.Skip(_step, c.build, c.repo) {
continue
}
Expand All @@ -140,6 +153,10 @@ func (c *client) ExecStage(ctx context.Context, s *pipeline.Stage, m *sync.Map)
if err != nil {
return fmt.Errorf("unable to exec step %s: %w", _step.Name, err)
}

if _step.ExitCode != 0 && !_step.Ruleset.Continue {
stop = true
}
}

return nil
Expand Down
9 changes: 6 additions & 3 deletions executor/linux/stage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ func TestLinux_ExecStage(t *testing.T) {
name: "docker-basic stage",
failure: false,
stage: &pipeline.Stage{
Name: "echo",
Independent: true,
Name: "echo",
Steps: pipeline.ContainerSlice{
{
ID: "github_octocat_1_echo_echo",
Expand All @@ -335,7 +336,8 @@ func TestLinux_ExecStage(t *testing.T) {
name: "docker-stage with step container with image not found",
failure: true,
stage: &pipeline.Stage{
Name: "echo",
Name: "echo",
Independent: true,
Steps: pipeline.ContainerSlice{
{
ID: "github_octocat_1_echo_echo",
Expand All @@ -353,7 +355,8 @@ func TestLinux_ExecStage(t *testing.T) {
name: "docker-stage with step container with bad number",
failure: true,
stage: &pipeline.Stage{
Name: "echo",
Name: "echo",
Independent: true,
Steps: pipeline.ContainerSlice{
{
ID: "github_octocat_1_echo_echo",
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/gin-gonic/gin v1.8.1
github.com/go-vela/sdk-go v0.16.2
github.com/go-vela/server v0.16.2
github.com/go-vela/types v0.16.2
github.com/go-vela/types v0.16.3-0.20221105053740-45311b89c32d
github.com/google/go-cmp v0.5.9
github.com/joho/godotenv v1.4.0
github.com/opencontainers/image-spec v1.0.2
Expand All @@ -34,7 +34,7 @@ require (
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect
github.com/alicebob/miniredis/v2 v2.23.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/buildkite/yaml v0.0.0-20181016232759-0caa5f0796e3 // indirect
github.com/buildkite/yaml v0.0.0-20210326113714-4a3f40911396 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/buildkite/yaml v0.0.0-20181016232759-0caa5f0796e3 h1:q+sMKdA6L8LyGVudTkpGoC73h6ak2iWSPFiFo/pFOU8=
github.com/buildkite/yaml v0.0.0-20181016232759-0caa5f0796e3/go.mod h1:5hCug3EZaHXU3FdCA3gJm0YTNi+V+ooA2qNTiVpky4A=
github.com/buildkite/yaml v0.0.0-20210326113714-4a3f40911396 h1:qLN32md48xyTEqw6XEZMyNMre7njm0XXvDrea6NVwOM=
github.com/buildkite/yaml v0.0.0-20210326113714-4a3f40911396/go.mod h1:AV5wtJnn1/CRaRGlJ8xspkMWfKXV0/pkJVgGleTIrfk=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
Expand Down Expand Up @@ -157,8 +157,8 @@ github.com/go-vela/sdk-go v0.16.2 h1:M9+u89mGomJc2uwUPVGWp9UnUIFm0IhIIsFEfxROhZQ
github.com/go-vela/sdk-go v0.16.2/go.mod h1:BuTkw+MYWbAKJ6+ZtQ/nNmwIcjn/tysCPks4X+csBGE=
github.com/go-vela/server v0.16.2 h1:qovjGN9ZQazjV0JTXzP6o5UPSs1D+wyUMpbG4G6aXZI=
github.com/go-vela/server v0.16.2/go.mod h1:bf9dpkzhL2T6G6fxIwjmMjzoD+e5Xfmg3DcckP6lqHc=
github.com/go-vela/types v0.16.2 h1:c2Kkj7OKv4sjPrsOBbnPSQqfsNpOFM2La7LfP+81EF0=
github.com/go-vela/types v0.16.2/go.mod h1:6KoRkvXMw9DkAcLdtI7PxPqMlT2Bl0DiigQamLGGjwo=
github.com/go-vela/types v0.16.3-0.20221105053740-45311b89c32d h1:D33ReR2tD2bEliMvIamPNTEuf+80h0XUP1yJChXCJkI=
github.com/go-vela/types v0.16.3-0.20221105053740-45311b89c32d/go.mod h1:6KoRkvXMw9DkAcLdtI7PxPqMlT2Bl0DiigQamLGGjwo=
github.com/goccy/go-json v0.9.7 h1:IcB+Aqpx/iMHu5Yooh7jEzJk1JZ7Pjtmys2ukPr7EeM=
github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
Expand Down
9 changes: 5 additions & 4 deletions internal/step/skip.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ func Skip(c *pipeline.Container, b *library.Build, r *library.Repo) bool {
//
// https://pkg.go.dev/github.com/go-vela/types/pipeline#RuleData
ruledata := &pipeline.RuleData{
Branch: b.GetBranch(),
Event: event,
Repo: r.GetFullName(),
Status: b.GetStatus(),
Branch: b.GetBranch(),
Event: event,
Repo: r.GetFullName(),
Status: b.GetStatus(),
Parallel: c.Ruleset.If.Parallel,
}

// check if the build event is tag
Expand Down