mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-02-18 04:15:15 +00:00
Fix DAG cycle detection (#3049)
Previously a graph like this. a <- b ^ ^ | | c <- d Was incorrectly recognized as having a cycle. Fixes #3048.
This commit is contained in:
parent
74f6824d03
commit
4bc2fed550
2 changed files with 22 additions and 0 deletions
|
@ -102,6 +102,8 @@ func dfsVisit(steps map[string]*dagCompilerStep, name string, visited map[string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete(visited, name)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,26 @@ func TestConvertDAGToStages(t *testing.T) {
|
||||||
_, err = convertDAGToStages(steps, "")
|
_, err = convertDAGToStages(steps, "")
|
||||||
assert.NoError(t, err)
|
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{
|
steps = map[string]*dagCompilerStep{
|
||||||
"step1": {
|
"step1": {
|
||||||
step: &backend_types.Step{},
|
step: &backend_types.Step{},
|
||||||
|
|
Loading…
Reference in a new issue