Skip to content

Commit

Permalink
Handling zero-steps as transitive dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlocph committed Jul 22, 2019
1 parent 6879bf6 commit 3bb0f64
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/procBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 52 additions & 0 deletions server/procBuilder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}

Expand Down

0 comments on commit 3bb0f64

Please sign in to comment.