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