enable granular step data for matrix

This commit is contained in:
Brad Rydzewski 2017-04-04 18:30:06 +09:00
parent 0daee76aa8
commit 16a07e660a
6 changed files with 28 additions and 15 deletions

View file

@ -258,6 +258,8 @@ func PostApproval(c *gin.Context) {
//
// publish topic
//
buildCopy := *build
buildCopy.Procs = model.Tree(buildCopy.Procs)
message := pubsub.Message{
Labels: map[string]string{
"repo": repo.FullName,
@ -267,10 +269,11 @@ func PostApproval(c *gin.Context) {
message.Data, _ = json.Marshal(model.Event{
Type: model.Enqueued,
Repo: *repo,
Build: *build,
Build: buildCopy,
})
// TODO remove global reference
config.pubsub.Publish(c, "topic/events", message)
//
// end publish topic
//
@ -517,6 +520,8 @@ func PostBuild(c *gin.Context) {
//
// publish topic
//
buildCopy := *build
buildCopy.Procs = model.Tree(buildCopy.Procs)
message := pubsub.Message{
Labels: map[string]string{
"repo": repo.FullName,
@ -526,7 +531,7 @@ func PostBuild(c *gin.Context) {
message.Data, _ = json.Marshal(model.Event{
Type: model.Enqueued,
Repo: *repo,
Build: *build,
Build: buildCopy,
})
// TODO remove global reference
config.pubsub.Publish(c, "topic/events", message)

View file

@ -293,7 +293,10 @@ func PostHook(c *gin.Context) {
}
}
}
store.FromContext(c).ProcCreate(build.Procs)
err = store.FromContext(c).ProcCreate(build.Procs)
if err != nil {
logrus.Errorf("error persisting procs %s/%d: %s", repo.FullName, build.Number, err)
}
//
// publish topic
@ -304,10 +307,12 @@ func PostHook(c *gin.Context) {
"private": strconv.FormatBool(repo.IsPrivate),
},
}
buildCopy := *build
buildCopy.Procs = model.Tree(buildCopy.Procs)
message.Data, _ = json.Marshal(model.Event{
Type: model.Enqueued,
Repo: *repo,
Build: *build,
Build: buildCopy,
})
// TODO remove global reference
config.pubsub.Publish(c, "topic/events", message)

View file

@ -153,6 +153,7 @@ func (s *RPC) Update(c context.Context, id string, state rpc.State) error {
}
build.Procs, _ = s.store.ProcList(build)
build.Procs = model.Tree(build.Procs)
message := pubsub.Message{
Labels: map[string]string{
"repo": repo.FullName,
@ -305,29 +306,34 @@ func (s *RPC) Done(c context.Context, id string, state rpc.State) error {
log.Printf("error: done: cannot ack proc_id %d: %s", procID, err)
}
done := false
status := model.StatusSuccess
// TODO handle this error
procs, _ := s.store.ProcList(build)
for _, p := range procs {
if p.Running() && p.PPID == proc.PID {
p.State = model.StatusSkipped
if p.Started != 0 {
p.State = model.StatusKilled
p.State = model.StatusSuccess // for deamons that are killed
p.Stopped = proc.Stopped
}
if err := s.store.ProcUpdate(p); err != nil {
log.Printf("error: done: cannot update proc_id %d child state: %s", p.ID, err)
}
}
if !p.Running() && p.PPID == 0 {
done = true
}
running := false
status := model.StatusSuccess
for _, p := range procs {
if p.PPID == 0 {
if p.Running() {
running = true
}
if p.Failing() {
status = model.StatusFailure
status = p.State
}
}
}
if done {
if !running {
build.Status = status
build.Finished = proc.Stopped
if err := s.store.UpdateBuild(build); err != nil {
@ -339,7 +345,7 @@ func (s *RPC) Done(c context.Context, id string, state rpc.State) error {
log.Printf("error: done: cannot close build_id %d logger: %s", proc.ID, err)
}
build.Procs = procs
build.Procs = model.Tree(procs)
message := pubsub.Message{
Labels: map[string]string{
"repo": repo.FullName,

View file

@ -16,7 +16,6 @@ CREATE TABLE procs (
,proc_platform VARCHAR(250)
,proc_environ VARCHAR(2000)
,UNIQUE(proc_build_id, proc_pid)
,UNIQUE(proc_build_id, proc_name)
);
CREATE INDEX proc_build_ix ON procs (proc_build_id);

View file

@ -17,7 +17,6 @@ CREATE TABLE procs (
,proc_environ VARCHAR(2000)
,UNIQUE(proc_build_id, proc_pid)
,UNIQUE(proc_build_id, proc_name)
);
CREATE INDEX proc_build_ix ON procs (proc_build_id);

View file

@ -16,7 +16,6 @@ CREATE TABLE procs (
,proc_platform TEXT
,proc_environ TEXT
,UNIQUE(proc_build_id, proc_pid)
,UNIQUE(proc_build_id, proc_name)
);
CREATE INDEX proc_build_ix ON procs (proc_build_id);