Handling zero-steps as transitive dependencies

This commit is contained in:
Laszlo Fogas 2019-07-22 14:29:15 +02:00
parent 6879bf62cb
commit 3bb0f64025
2 changed files with 54 additions and 1 deletions

View file

@ -156,7 +156,8 @@ func filterItemsWithMissingDependencies(items []*buildItem) []*buildItem {
filtered = append(filtered, item)
}
}
return filtered
// Recursive to handle transitive deps
return filterItemsWithMissingDependencies(filtered)
}
return items

View file

@ -288,6 +288,58 @@ depends_on: [ zerostep ]
}
}
func TestZeroStepsAsMultiPipelineTransitiveDeps(t *testing.T) {
build := &model.Build{Branch: "dev"}
b := procBuilder{
Repo: &model.Repo{},
Curr: build,
Last: &model.Build{},
Netrc: &model.Netrc{},
Secs: []*model.Secret{},
Regs: []*model.Registry{},
Link: "",
Yamls: []*remote.FileMeta{
&remote.FileMeta{Name: "zerostep", Data: []byte(`
skip_clone: true
pipeline:
build:
when:
branch: notdev
image: scratch
`)},
&remote.FileMeta{Name: "justastep", Data: []byte(`
pipeline:
build:
image: scratch
`)},
&remote.FileMeta{Name: "shouldbefiltered", Data: []byte(`
pipeline:
build:
image: scratch
depends_on: [ zerostep ]
`)},
&remote.FileMeta{Name: "shouldbefilteredtoo", Data: []byte(`
pipeline:
build:
image: scratch
depends_on: [ shouldbefiltered ]
`)},
},
}
buildItems, err := b.Build()
if err != nil {
t.Fatal(err)
}
if len(buildItems) != 1 {
t.Fatal("Zerostep and the step that depends on it, and the one depending on it should not generate a build item")
}
if "justastep" != buildItems[0].Proc.Name {
t.Fatal("justastep should have been generated")
}
}
func TestTree(t *testing.T) {
build := &model.Build{}