Skip to content

Commit

Permalink
Fix DAG cycle detection (woodpecker-ci#3049)
Browse files Browse the repository at this point in the history
Previously a graph like this.

    a <- b
    ^    ^
    |    |
    c <- d

Was incorrectly recognized as having a cycle.

Fixes woodpecker-ci#3048.
  • Loading branch information
KamilaBorowska authored and fernandrone committed Feb 1, 2024
1 parent 081faa3 commit d435a35
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pipeline/frontend/yaml/compiler/dag.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ func dfsVisit(steps map[string]*dagCompilerStep, name string, visited map[string
}
}

delete(visited, name)

return nil
}

Expand Down
20 changes: 20 additions & 0 deletions pipeline/frontend/yaml/compiler/dag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ func TestConvertDAGToStages(t *testing.T) {
_, err = convertDAGToStages(steps, "")
assert.NoError(t, err)

steps = map[string]*dagCompilerStep{
"a": {
step: &backend_types.Step{},
},
"b": {
step: &backend_types.Step{},
dependsOn: []string{"a"},
},
"c": {
step: &backend_types.Step{},
dependsOn: []string{"a"},
},
"d": {
step: &backend_types.Step{},
dependsOn: []string{"b", "c"},
},
}
_, err = convertDAGToStages(steps, "")
assert.NoError(t, err)

steps = map[string]*dagCompilerStep{
"step1": {
step: &backend_types.Step{},
Expand Down

0 comments on commit d435a35

Please sign in to comment.