mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
github status api
This commit is contained in:
parent
7f162c80b9
commit
d07c0cb80d
4 changed files with 17 additions and 12 deletions
2
drone.go
2
drone.go
|
@ -38,7 +38,7 @@ func main() {
|
|||
session := session.New(settings.Session)
|
||||
eventbus_ := eventbus.New()
|
||||
queue_ := queue.New()
|
||||
updater := runner.NewUpdater(eventbus_, store)
|
||||
updater := runner.NewUpdater(eventbus_, store, remote)
|
||||
runner_ := runner.Runner{Updater: updater}
|
||||
go run(&runner_, queue_)
|
||||
|
||||
|
|
|
@ -79,14 +79,14 @@ func (r *Runner) Run(w *queue.Work) error {
|
|||
w.Build.State = common.StateError
|
||||
w.Build.Finished = time.Now().UTC().Unix()
|
||||
w.Build.Duration = w.Build.Finished - w.Build.Started
|
||||
r.SetBuild(w.Repo, w.Build)
|
||||
r.SetBuild(w.User, w.Repo, w.Build)
|
||||
}
|
||||
}()
|
||||
|
||||
// marks the build as running
|
||||
w.Build.Started = time.Now().UTC().Unix()
|
||||
w.Build.State = common.StateRunning
|
||||
err := r.SetBuild(w.Repo, w.Build)
|
||||
err := r.SetBuild(w.User, w.Repo, w.Build)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ func (r *Runner) Run(w *queue.Work) error {
|
|||
break
|
||||
}
|
||||
}
|
||||
err = r.SetBuild(w.Repo, w.Build)
|
||||
err = r.SetBuild(w.User, w.Repo, w.Build)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -3,31 +3,32 @@ package builtin
|
|||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
//"io/ioutil"
|
||||
|
||||
"github.com/drone/drone/common"
|
||||
"github.com/drone/drone/datastore"
|
||||
"github.com/drone/drone/eventbus"
|
||||
"github.com/drone/drone/remote"
|
||||
)
|
||||
|
||||
type Updater interface {
|
||||
SetBuild(*common.Repo, *common.Build) error
|
||||
SetBuild(*common.User, *common.Repo, *common.Build) error
|
||||
SetTask(*common.Repo, *common.Build, *common.Task) error
|
||||
SetLogs(*common.Repo, *common.Build, *common.Task, io.ReadCloser) error
|
||||
}
|
||||
|
||||
// NewUpdater returns an implementation of the Updater interface
|
||||
// that directly modifies the database and sends messages to the bus.
|
||||
func NewUpdater(bus eventbus.Bus, store datastore.Datastore) Updater {
|
||||
return &updater{bus, store}
|
||||
func NewUpdater(bus eventbus.Bus, store datastore.Datastore, rem remote.Remote) Updater {
|
||||
return &updater{bus, store, rem}
|
||||
}
|
||||
|
||||
type updater struct {
|
||||
bus eventbus.Bus
|
||||
store datastore.Datastore
|
||||
bus eventbus.Bus
|
||||
store datastore.Datastore
|
||||
remote remote.Remote
|
||||
}
|
||||
|
||||
func (u *updater) SetBuild(r *common.Repo, b *common.Build) error {
|
||||
func (u *updater) SetBuild(user *common.User, r *common.Repo, b *common.Build) error {
|
||||
err := u.store.SetBuildState(r.FullName, b)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -42,6 +43,11 @@ func (u *updater) SetBuild(r *common.Repo, b *common.Build) error {
|
|||
u.store.SetRepo(repo)
|
||||
}
|
||||
}
|
||||
|
||||
// err = u.remote.Status(user, r, b, "")
|
||||
// if err != nil {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
msg, err := json.Marshal(b)
|
||||
|
|
|
@ -46,7 +46,6 @@ func GetLogin(c *gin.Context) {
|
|||
|
||||
// exit if authorization fails
|
||||
if c.Writer.Status() != 200 {
|
||||
log.Errorf("authorization failed.")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue