Skip to content

Commit

Permalink
fix bug checking for pipeline dependency cycles (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoghaddam385 authored Oct 18, 2021
1 parent 778b9b3 commit dc9aff2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion schemas/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (g dependencyGraph) checkForDependencyCycles() error {
}

// Prime the visit stack with the first independent errand and remove it from the list.
toVisitStack := independentErrands[0:1]
toVisitStack := []*Errand{independentErrands[0]}
independentErrands = independentErrands[1:]

// visitedSet keeps track of all the errands we've already seen so we can ensure we've seen all of them
Expand Down
30 changes: 30 additions & 0 deletions schemas/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,34 @@ func TestPipelineValidate(t *testing.T) {

assert.NoError(t, p.Validate())
})

t.Run("single graph happy path | converging and diverging", func(t *testing.T) {
/*
A --> B --| |--> E
|--> C --|
D --| |--> F --> G
*/
p := Pipeline{
Name: "single graph with cycle",
Errands: []*Errand{
{Name: "A"},
{Name: "B"},
{Name: "C"},
{Name: "D"},
{Name: "E"},
{Name: "F"},
{Name: "G"},
},
Dependencies: []*PipelineDependency{
{Target: "B", DependsOn: "A"},
{Target: "C", DependsOn: "B"},
{Target: "C", DependsOn: "D"},
{Target: "E", DependsOn: "C"},
{Target: "F", DependsOn: "C"},
{Target: "G", DependsOn: "F"},
},
}

assert.NoError(t, p.Validate())
})
}

0 comments on commit dc9aff2

Please sign in to comment.