mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-02-17 03:45:13 +00:00
Pid ID refactor
This commit is contained in:
parent
e2b76ac449
commit
2edc5fcfb7
2 changed files with 44 additions and 5 deletions
|
@ -59,7 +59,9 @@ func (b *procBuilder) Build() ([]*buildItem, error) {
|
||||||
|
|
||||||
sort.Sort(remote.ByName(b.Yamls))
|
sort.Sort(remote.ByName(b.Yamls))
|
||||||
|
|
||||||
for j, y := range b.Yamls {
|
pidSequence := 1
|
||||||
|
|
||||||
|
for _, y := range b.Yamls {
|
||||||
// matrix axes
|
// matrix axes
|
||||||
axes, err := matrix.ParseString(string(y.Data))
|
axes, err := matrix.ParseString(string(y.Data))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -69,11 +71,11 @@ func (b *procBuilder) Build() ([]*buildItem, error) {
|
||||||
axes = append(axes, matrix.Axis{})
|
axes = append(axes, matrix.Axis{})
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, axis := range axes {
|
for _, axis := range axes {
|
||||||
proc := &model.Proc{
|
proc := &model.Proc{
|
||||||
BuildID: b.Curr.ID,
|
BuildID: b.Curr.ID,
|
||||||
PID: j + i + 1,
|
PID: pidSequence,
|
||||||
PGID: j + i + 1,
|
PGID: pidSequence,
|
||||||
State: model.StatusPending,
|
State: model.StatusPending,
|
||||||
Environ: axis,
|
Environ: axis,
|
||||||
Name: sanitizePath(y.Name),
|
Name: sanitizePath(y.Name),
|
||||||
|
@ -123,6 +125,7 @@ func (b *procBuilder) Build() ([]*buildItem, error) {
|
||||||
item.Labels = map[string]string{}
|
item.Labels = map[string]string{}
|
||||||
}
|
}
|
||||||
items = append(items, item)
|
items = append(items, item)
|
||||||
|
pidSequence++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -201,6 +201,42 @@ pipeline:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if buildItems[1].Proc.State != model.StatusPending {
|
if buildItems[1].Proc.State != model.StatusPending {
|
||||||
t.Fatal("Should not run on dev branch")
|
t.Fatal("Should run on dev branch")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTree(t *testing.T) {
|
||||||
|
build := &model.Build{}
|
||||||
|
|
||||||
|
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{Data: []byte(`
|
||||||
|
pipeline:
|
||||||
|
build:
|
||||||
|
image: scratch
|
||||||
|
yyy: ${DRONE_COMMIT_MESSAGE}
|
||||||
|
`)},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := b.Build()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(build.Procs) != 3 {
|
||||||
|
t.Fatal("Should generate three in total")
|
||||||
|
}
|
||||||
|
if build.Procs[1].PPID != 1 {
|
||||||
|
t.Fatal("Clone step should be a children of the stage")
|
||||||
|
}
|
||||||
|
if build.Procs[2].PPID != 1 {
|
||||||
|
t.Fatal("Build step should be a children of the stage")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue