Resolve duplicate issues
This commit is contained in:
@@ -142,7 +142,7 @@ func (svc workflowConverter) makeGraph(def *types.Workflow) (*wfexec.Graph, type
|
||||
}
|
||||
|
||||
if len(wfii) > 0 {
|
||||
return nil, wfii
|
||||
return nil, wfii.Distinct()
|
||||
}
|
||||
|
||||
return g, nil
|
||||
|
||||
@@ -149,6 +149,10 @@ func (set WorkflowIssueSet) Value() (driver.Value, error) {
|
||||
return json.Marshal(set)
|
||||
}
|
||||
|
||||
func (issue *WorkflowIssue) String() string {
|
||||
return fmt.Sprintf("%s [%v]", issue.Description, issue.Culprit)
|
||||
}
|
||||
|
||||
func (set *WorkflowIssueSet) Scan(value interface{}) error {
|
||||
//lint:ignore S1034 This typecast is intentional, we need to get []byte out of a []uint8
|
||||
switch value.(type) {
|
||||
@@ -186,6 +190,23 @@ func (set WorkflowIssueSet) Append(err error, culprit map[string]int) WorkflowIs
|
||||
})
|
||||
}
|
||||
|
||||
// Distinct returns set of issues without duplicates
|
||||
func (set WorkflowIssueSet) Distinct() (out WorkflowIssueSet) {
|
||||
idx := make(map[string]bool)
|
||||
out = make([]*WorkflowIssue, 0, len(set))
|
||||
|
||||
for i := range set {
|
||||
if idx[set[i].String()] {
|
||||
continue
|
||||
}
|
||||
|
||||
out = append(out, set[i])
|
||||
idx[set[i].String()] = true
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (set WorkflowIssueSet) SetCulprit(name string, pos int) WorkflowIssueSet {
|
||||
for i := range set {
|
||||
set[i].Culprit[name] = pos
|
||||
|
||||
@@ -18,7 +18,6 @@ func Test0015_step_issue(t *testing.T) {
|
||||
loadScenario(ctx, t)
|
||||
|
||||
t.Run("exclusive gateway step issue", func(t *testing.T) {
|
||||
t.Skipf("workflow step resolution & validation need to be to be fixed")
|
||||
_, _, err := execWorkflow(ctx, "case1", types.WorkflowExecParams{})
|
||||
|
||||
issues, is := err.(types.WorkflowIssueSet)
|
||||
@@ -31,7 +30,6 @@ func Test0015_step_issue(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("inclusive gateway step issue", func(t *testing.T) {
|
||||
t.Skipf("workflow step resolution & validation need to be to be fixed")
|
||||
_, _, err := execWorkflow(ctx, "case2", types.WorkflowExecParams{})
|
||||
|
||||
issues, is := err.(types.WorkflowIssueSet)
|
||||
@@ -44,7 +42,6 @@ func Test0015_step_issue(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("function step issue", func(t *testing.T) {
|
||||
t.Skipf("workflow step resolution & validation need to be to be fixed")
|
||||
_, _, err := execWorkflow(ctx, "case3", types.WorkflowExecParams{})
|
||||
|
||||
issues, is := err.(types.WorkflowIssueSet)
|
||||
@@ -56,7 +53,6 @@ func Test0015_step_issue(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("iterator step issue", func(t *testing.T) {
|
||||
t.Skipf("workflow step resolution & validation need to be to be fixed")
|
||||
_, _, err := execWorkflow(ctx, "case4", types.WorkflowExecParams{})
|
||||
|
||||
issues, is := err.(types.WorkflowIssueSet)
|
||||
|
||||
Reference in New Issue
Block a user