diff --git a/cmd/vela-worker/exec.go b/cmd/vela-worker/exec.go index d5d7f7a3..a7a14fed 100644 --- a/cmd/vela-worker/exec.go +++ b/cmd/vela-worker/exec.go @@ -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 } diff --git a/docker-compose.yml b/docker-compose.yml index 851544d1..df704663 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: diff --git a/executor/linux/build.go b/executor/linux/build.go index f6665ee6..f739dc01 100644 --- a/executor/linux/build.go +++ b/executor/linux/build.go @@ -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) } diff --git a/executor/linux/stage.go b/executor/linux/stage.go index cfeff50b..f681d45e 100644 --- a/executor/linux/stage.go +++ b/executor/linux/stage.go @@ -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. @@ -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) } @@ -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() + } } } diff --git a/executor/local/build.go b/executor/local/build.go index 62be5b3f..df5cf576 100644 --- a/executor/local/build.go +++ b/executor/local/build.go @@ -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) } diff --git a/executor/local/stage.go b/executor/local/stage.go index 611c385d..f3a11803 100644 --- a/executor/local/stage.go +++ b/executor/local/stage.go @@ -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) } diff --git a/go.mod b/go.mod index 22ff2514..b5358bbe 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 2571aa1b..6e9d5184 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/internal/step/skip.go b/internal/step/skip.go index ca08740b..f6039973 100644 --- a/internal/step/skip.go +++ b/internal/step/skip.go @@ -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 @@ -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 diff --git a/internal/step/skip_test.go b/internal/step/skip_test.go index f422c057..c03dbc3c 100644 --- a/internal/step/skip_test.go +++ b/internal/step/skip_test.go @@ -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) }