Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper committed Nov 1, 2024
1 parent 3db6801 commit 97d3472
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 16 deletions.
6 changes: 6 additions & 0 deletions cmd/vela-worker/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ func (w *Worker) exec(index int, config *api.Worker) error {
return err
}

for _, wabba := range p.Stages {
for _, wobba := range wabba.Steps {
fmt.Printf("\n\n NAME: %s, STATUS: %s, STAGE STATUS: %s\n\n", wobba.Name, wobba.Ruleset.If.Status, wobba.Ruleset.If.StageStatus)
}
}

break
}

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ services:
# https://go-vela.github.io/docs/administration/server/
server:
container_name: server
image: target/vela-server:latest
image: server:local
networks:
- vela
environment:
Expand Down
2 changes: 1 addition & 1 deletion executor/linux/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ func (c *client) ExecBuild(ctx context.Context) error {
// check if the step should be skipped
//
// https://pkg.go.dev/github.com/go-vela/worker/internal/step#Skip
skip, err := step.Skip(_step, c.build)
skip, err := step.Skip(_step, c.build, "")
if err != nil {
return fmt.Errorf("unable to plan step: %w", c.err)
}
Expand Down
11 changes: 10 additions & 1 deletion executor/linux/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ func (c *client) ExecStage(ctx context.Context, s *pipeline.Stage, m *sync.Map)
// stop value determines when a stage's step series should stop executing
stop := false

stageStatus := c.build.GetStatus()

// execute the steps for the stage
for _, _step := range s.Steps {
// first check to see if we need to stop the stage before it even starts.
Expand All @@ -138,7 +140,7 @@ func (c *client) ExecStage(ctx context.Context, s *pipeline.Stage, m *sync.Map)
// check if the step should be skipped
//
// https://pkg.go.dev/github.com/go-vela/worker/internal/step#Skip
skip, err := step.Skip(_step, c.build)
skip, err := step.Skip(_step, c.build, stageStatus)
if err != nil {
return fmt.Errorf("unable to plan step: %w", c.err)
}
Expand Down Expand Up @@ -214,6 +216,13 @@ func (c *client) ExecStage(ctx context.Context, s *pipeline.Stage, m *sync.Map)
// the continue rule is set to true.
if _step.ExitCode != 0 && !_step.Ruleset.Continue {
stop = true

// if stage is independent, set the stage status to failure
if s.Independent {
stageStatus = constants.StatusFailure
} else {
stageStatus = c.build.GetStatus()
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion executor/local/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (c *client) ExecBuild(ctx context.Context) error {
// check if the step should be skipped
//
// https://pkg.go.dev/github.com/go-vela/worker/internal/step#Skip
skip, err := step.Skip(_step, c.build)
skip, err := step.Skip(_step, c.build, "")
if err != nil {
return fmt.Errorf("unable to plan step: %w", c.err)
}
Expand Down
2 changes: 1 addition & 1 deletion executor/local/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (c *client) ExecStage(ctx context.Context, s *pipeline.Stage, m *sync.Map)
// check if the step should be skipped
//
// https://pkg.go.dev/github.com/go-vela/worker/internal/step#Skip
skip, err := step.Skip(_step, c.build)
skip, err := step.Skip(_step, c.build, "")
if err != nil {
return fmt.Errorf("unable to plan step: %w", c.err)
}
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ module github.com/go-vela/worker

go 1.23.2

replace (
github.com/go-vela/sdk-go => ../sdk-go
github.com/go-vela/server => ../server
)

require (
github.com/Masterminds/semver/v3 v3.3.0
github.com/distribution/reference v0.6.0
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27
github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/go-vela/sdk-go v0.25.2-0.20241022142543-b9de2ce2abea h1:tdUe3vW8HCMutfmttFt3UE0hH8qHSz4PgQYs4Q2eBX0=
github.com/go-vela/sdk-go v0.25.2-0.20241022142543-b9de2ce2abea/go.mod h1:4Q8UW6fLzke4SVU1dJBViZMOSfMiIKMGZ42lPrzk5WA=
github.com/go-vela/server v0.25.1-0.20241022141112-a2b0d9146d65 h1:BepNezNRDLfookgMn81U9WB0/aMBxkqot9w8nLPWNhU=
github.com/go-vela/server v0.25.1-0.20241022141112-a2b0d9146d65/go.mod h1:hdVkyyxnRtk+Vjs7nCnKEkwWmd9yVQUV5Akpt7BY6wg=
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
Expand Down
13 changes: 7 additions & 6 deletions internal/step/skip.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
// Skip creates the ruledata from the build and repository
// information and returns true if the data does not match
// the ruleset for the given container.
func Skip(c *pipeline.Container, b *api.Build) (bool, error) {
func Skip(c *pipeline.Container, b *api.Build, stageStatus string) (bool, error) {
// check if the container provided is empty
if c == nil {
return true, nil
Expand All @@ -29,11 +29,12 @@ func Skip(c *pipeline.Container, b *api.Build) (bool, error) {

// create ruledata from build and repository information
ruledata := &pipeline.RuleData{
Branch: b.GetBranch(),
Event: event,
Repo: b.GetRepo().GetFullName(),
Status: b.GetStatus(),
Parallel: c.Ruleset.If.Parallel,
Branch: b.GetBranch(),
Event: event,
Repo: b.GetRepo().GetFullName(),
Status: b.GetStatus(),
StageStatus: stageStatus,
Parallel: c.Ruleset.If.Parallel,
}

// check if the build event is tag
Expand Down
2 changes: 1 addition & 1 deletion internal/step/skip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func TestStep_Skip(t *testing.T) {
// run test
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
got, err := Skip(test.container, test.build)
got, err := Skip(test.container, test.build, "")
if err != nil {
t.Errorf("Skip returned error: %s", err)
}
Expand Down

0 comments on commit 97d3472

Please sign in to comment.