Skip to content

Commit

Permalink
feat: Add support for 'skipped' status
Browse files Browse the repository at this point in the history
  • Loading branch information
keskad committed May 20, 2024
1 parent 8310f90 commit b59960f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
/charts/batchv1-chart/*
!/charts/batchv1-chart/Makefile
!/charts/batchv1-chart/values.override.yaml
!/charts/batchv1-chart/README.md.gotmpl
!/charts/batchv1-chart/README.md.gotmpl
.idea

15 changes: 11 additions & 4 deletions pkgs/contract/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import (
"crypto/sha256"
"encoding/hex"
"fmt"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/labels"
"net/url"
"strings"
"time"

"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/labels"
)

type ConfigurationData interface {
Expand All @@ -23,7 +24,6 @@ type PipelineInfo struct {
instanceName string
namespace string
dateStarted time.Time
status Status
stages []PipelineStage
dashboardUrl string
retrievalNum int
Expand Down Expand Up @@ -204,6 +204,7 @@ const (
PipelineErrored Status = "errored"
PipelineSucceeded Status = "succeeded"
PipelineCancelled Status = "cancelled"
PipelineSkipped Status = "skipped"
)

func (s Status) IsFinished() bool {
Expand All @@ -214,6 +215,10 @@ func (s Status) IsRunning() bool {
return s == PipelineRunning
}

func (s Status) IsSkipped() bool {
return s == PipelineSkipped
}

func (s Status) IsErroredOrFailed() bool {
return s == PipelineFailed || s == PipelineErrored
}
Expand All @@ -233,8 +238,10 @@ func (s Status) IsNotStarted() bool {
func (s Status) AsHumanReadableDescription() string {
if s == PipelineRunning || s == PipelinePending {
return "is " + string(s)
} else if s == PipelineFailed || s == PipelineErrored || s == PipelineSucceeded || s == PipelineCancelled {
} else if s == PipelineFailed || s == PipelineErrored || s == PipelineSucceeded {
return string(s)
} else if s == PipelineSkipped || s == PipelineCancelled {
return "was " + string(s)
}
return "is in unknown state"
}
Expand Down
11 changes: 7 additions & 4 deletions pkgs/feedback/jxscm/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package jxscm
import (
"context"
"fmt"
"strconv"
"strings"

"github.com/jenkins-x/go-scm/scm"
"github.com/kube-cicd/pipelines-feedback-core/internal/feedback/jxscm"
"github.com/kube-cicd/pipelines-feedback-core/pkgs/config"
Expand All @@ -11,8 +14,6 @@ import (
"github.com/kube-cicd/pipelines-feedback-core/pkgs/logging"
"github.com/kube-cicd/pipelines-feedback-core/pkgs/templating"
"github.com/pkg/errors"
"strconv"
"strings"
)

const defaultProgressComment = `
Expand Down Expand Up @@ -218,7 +219,7 @@ func (jx *Receiver) UpdateProgress(ctx context.Context, pipeline contract.Pipeli

scmCtx := pipeline.GetSCMContext()
ourStatus := pipeline.GetStatus()
overallStatus := jx.translateStatus(ourStatus, cfg)
overallStatus := jx.translateStatus(ourStatus)

// Update status in PR/MR comment
var prCommentStatusErr error = nil
Expand Down Expand Up @@ -280,7 +281,7 @@ func (jx *Receiver) updateCommitStatus(ctx context.Context, cfg config.Data, cli
return commitStatusErr
}

func (jx *Receiver) translateStatus(status contract.Status, cfg config.Data) scm.State {
func (jx *Receiver) translateStatus(status contract.Status) scm.State {
switch status {
case contract.PipelineRunning:
return scm.StateRunning
Expand All @@ -290,6 +291,8 @@ func (jx *Receiver) translateStatus(status contract.Status, cfg config.Data) scm
return scm.StateSuccess
case contract.PipelineErrored:
return scm.StateError
case contract.PipelineSkipped:
return scm.StateCanceled
case contract.PipelineFailed:
return scm.StateFailure
default:
Expand Down

0 comments on commit b59960f

Please sign in to comment.