mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-01-05 10:20:36 +02:00
Merge remote-tracking branch 'upstream/bolt' into bolt
This commit is contained in:
commit
4e53cc184e
@ -5,8 +5,9 @@ env:
|
|||||||
- GOROOT=/usr/local/go
|
- GOROOT=/usr/local/go
|
||||||
- PATH=$PATH:$GOROOT/bin:$GOPATH/bin
|
- PATH=$PATH:$GOROOT/bin:$GOPATH/bin
|
||||||
script:
|
script:
|
||||||
- make deps
|
- go get -u github.com/jteeuwen/go-bindata/...
|
||||||
- make
|
- make bindata deps
|
||||||
|
- make build
|
||||||
- make test
|
- make test
|
||||||
|
|
||||||
notify:
|
notify:
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -13,5 +13,7 @@ drone.sublime-workspace
|
|||||||
*.db
|
*.db
|
||||||
*.txt
|
*.txt
|
||||||
*.toml
|
*.toml
|
||||||
|
*.min.js
|
||||||
|
bindata.go
|
||||||
|
|
||||||
drone
|
drone
|
16
Makefile
16
Makefile
@ -1,7 +1,7 @@
|
|||||||
SHA := $(shell git rev-parse --short HEAD)
|
SHA := $(shell git rev-parse --short HEAD)
|
||||||
VERSION := 0.4.0-alpha
|
VERSION := 0.4.0-alpha
|
||||||
|
|
||||||
all: build
|
all: concat bindata build
|
||||||
|
|
||||||
deps:
|
deps:
|
||||||
go get -t -v ./...
|
go get -t -v ./...
|
||||||
@ -16,3 +16,17 @@ build:
|
|||||||
clean:
|
clean:
|
||||||
find . -name "*.out" -delete
|
find . -name "*.out" -delete
|
||||||
rm -f drone
|
rm -f drone
|
||||||
|
rm -f bindata.go
|
||||||
|
|
||||||
|
concat:
|
||||||
|
cat server/static/scripts/drone.js \
|
||||||
|
server/static/scripts/services/*.js \
|
||||||
|
server/static/scripts/filters/*.js \
|
||||||
|
server/static/scripts/controllers/*.js \
|
||||||
|
server/static/scripts/term.js > server/static/scripts/drone.min.js
|
||||||
|
|
||||||
|
bindata_debug:
|
||||||
|
go-bindata --debug server/static/...
|
||||||
|
|
||||||
|
bindata:
|
||||||
|
go-bindata server/static/...
|
46
drone.go
46
drone.go
@ -2,6 +2,8 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"html/template"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
@ -11,16 +13,17 @@ import (
|
|||||||
"github.com/drone/drone/server"
|
"github.com/drone/drone/server"
|
||||||
"github.com/drone/drone/server/session"
|
"github.com/drone/drone/server/session"
|
||||||
"github.com/drone/drone/settings"
|
"github.com/drone/drone/settings"
|
||||||
|
"github.com/elazarl/go-bindata-assetfs"
|
||||||
|
|
||||||
queue "github.com/drone/drone/queue/builtin"
|
queue "github.com/drone/drone/queue/builtin"
|
||||||
)
|
)
|
||||||
|
|
||||||
var path = flag.String("config", "drone.toml", "")
|
var conf = flag.String("config", "drone.toml", "")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
settings, err := settings.Parse(*path)
|
settings, err := settings.Parse(*conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -106,12 +109,16 @@ func main() {
|
|||||||
|
|
||||||
queue := api.Group("/queue")
|
queue := api.Group("/queue")
|
||||||
{
|
{
|
||||||
queue.Use(server.SetRepo())
|
|
||||||
queue.GET("", server.GetQueue)
|
queue.GET("", server.GetQueue)
|
||||||
queue.POST("/pull", server.PollBuild)
|
queue.POST("/pull", server.PollBuild)
|
||||||
queue.POST("/push/:owner/:name", server.PushBuild)
|
|
||||||
queue.POST("/push/:owner/:name/:build", server.PushTask)
|
push := queue.Group("/push/:owner/:name")
|
||||||
queue.POST("/push/:owner/:name/:build/:task/logs", server.PushLogs)
|
{
|
||||||
|
push.Use(server.SetRepo())
|
||||||
|
push.POST("", server.PushBuild)
|
||||||
|
push.POST("/:build", server.PushTask)
|
||||||
|
push.POST("/:build/:task/logs", server.PushLogs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
events := api.Group("/stream")
|
events := api.Group("/stream")
|
||||||
@ -131,9 +138,30 @@ func main() {
|
|||||||
auth.POST("", server.GetLogin)
|
auth.POST("", server.GetLogin)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r.SetHTMLTemplate(index())
|
||||||
r.NoRoute(func(c *gin.Context) {
|
r.NoRoute(func(c *gin.Context) {
|
||||||
c.File("server/static/index.html")
|
c.HTML(200, "index.html", nil)
|
||||||
})
|
})
|
||||||
r.Static("/static", "server/static")
|
|
||||||
r.Run(settings.Server.Addr)
|
http.Handle("/static/", static())
|
||||||
|
http.Handle("/", r)
|
||||||
|
http.ListenAndServe(settings.Server.Addr, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// static is a helper function that will setup handlers
|
||||||
|
// for serving static files.
|
||||||
|
func static() http.Handler {
|
||||||
|
return http.StripPrefix("/static/", http.FileServer(&assetfs.AssetFS{
|
||||||
|
Asset: Asset,
|
||||||
|
AssetDir: AssetDir,
|
||||||
|
Prefix: "server/static",
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
// index is a helper function that will setup a template
|
||||||
|
// for rendering the main angular index.html file.
|
||||||
|
func index() *template.Template {
|
||||||
|
file := MustAsset("server/static/index.html")
|
||||||
|
filestr := string(file)
|
||||||
|
return template.Must(template.New("index.html").Parse(filestr))
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ func remove(c *gin.Context) {
|
|||||||
func pull(c *gin.Context) {
|
func pull(c *gin.Context) {
|
||||||
q := fromContext(c)
|
q := fromContext(c)
|
||||||
var work *queue.Work
|
var work *queue.Work
|
||||||
if c.Request.FormValue("ack") != "" {
|
if c.Request.FormValue("ack") == "true" {
|
||||||
work = q.PullAck()
|
work = q.PullAck()
|
||||||
} else {
|
} else {
|
||||||
work = q.Pull()
|
work = q.Pull()
|
||||||
|
@ -48,10 +48,12 @@ func PushBuild(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if build.State != common.StatePending && build.State != common.StateRunning {
|
||||||
if repo.Last == nil || build.Number >= repo.Last.Number {
|
if repo.Last == nil || build.Number >= repo.Last.Number {
|
||||||
repo.Last = build
|
repo.Last = build
|
||||||
store.SetRepo(repo)
|
store.SetRepo(repo)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// <-- FIXME
|
// <-- FIXME
|
||||||
// for some reason the Repo and Build fail to marshal to JSON.
|
// for some reason the Repo and Build fail to marshal to JSON.
|
||||||
|
@ -164,10 +164,10 @@ func SetRepo() gin.HandlerFunc {
|
|||||||
r, err := ds.Repo(owner + "/" + name)
|
r, err := ds.Repo(owner + "/" + name)
|
||||||
switch {
|
switch {
|
||||||
case err != nil && u != nil:
|
case err != nil && u != nil:
|
||||||
c.Fail(401, err)
|
c.Fail(404, err)
|
||||||
return
|
return
|
||||||
case err != nil && u == nil:
|
case err != nil && u == nil:
|
||||||
c.Fail(404, err)
|
c.Fail(401, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.Set("repo", r)
|
c.Set("repo", r)
|
||||||
|
@ -47,17 +47,28 @@
|
|||||||
}
|
}
|
||||||
// update repository
|
// update repository
|
||||||
$scope.repo = event.repo;
|
$scope.repo = event.repo;
|
||||||
$scope.apply();
|
$scope.$apply();
|
||||||
|
|
||||||
if (event.build.number !== parseInt(number)) {
|
var added = false;
|
||||||
return; // ignore
|
for (var i=0;i<$scope.builds.length;i++) {
|
||||||
|
var build = $scope.builds[i];
|
||||||
|
if (event.build.number !== build.number) {
|
||||||
|
continue; // ignore
|
||||||
}
|
}
|
||||||
// update the build status
|
// update the build status
|
||||||
$scope.build.state = event.build.state;
|
build.state = event.build.state;
|
||||||
$scope.build.started = event.build.started;
|
build.started_at = event.build.started_at;
|
||||||
$scope.build.finished = event.build.finished;
|
build.finished_at = event.build.finished_at;
|
||||||
$scope.build.duration = event.build.duration;
|
build.duration = event.build.duration;
|
||||||
|
$scope.builds[i] = build;
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
|
added = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!added) {
|
||||||
|
$scope.builds.push(event.build);
|
||||||
|
$scope.$apply();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +108,9 @@
|
|||||||
|
|
||||||
// fetch the logs for the finished build.
|
// fetch the logs for the finished build.
|
||||||
logs.get(fullName, number, step).then(function(payload){
|
logs.get(fullName, number, step).then(function(payload){
|
||||||
$scope.logs = payload.data;
|
var convert = new Filter({stream:false,newline:false});
|
||||||
|
var term = document.getElementById("term")
|
||||||
|
term.innerHTML = convert.toHtml(payload.data);
|
||||||
}).catch(function(err){
|
}).catch(function(err){
|
||||||
$scope.error = err;
|
$scope.error = err;
|
||||||
});
|
});
|
||||||
@ -127,8 +140,8 @@
|
|||||||
}
|
}
|
||||||
// update the build status
|
// update the build status
|
||||||
$scope.build.state = event.build.state;
|
$scope.build.state = event.build.state;
|
||||||
$scope.build.started = event.build.started;
|
$scope.build.started_at = event.build.started_at;
|
||||||
$scope.build.finished = event.build.finished;
|
$scope.build.finished_at = event.build.finished_at;
|
||||||
$scope.build.duration = event.build.duration;
|
$scope.build.duration = event.build.duration;
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
|
|
||||||
@ -137,8 +150,8 @@
|
|||||||
}
|
}
|
||||||
// update the task status
|
// update the task status
|
||||||
$scope.task.state = event.task.state;
|
$scope.task.state = event.task.state;
|
||||||
$scope.task.started = event.task.started;
|
$scope.task.started_at = event.task.started_at;
|
||||||
$scope.task.finished = event.task.finished;
|
$scope.task.finished_at = event.task.finished_at;
|
||||||
$scope.task.duration = event.task.duration;
|
$scope.task.duration = event.task.duration;
|
||||||
$scope.task.exit_code = event.task.exit_code;
|
$scope.task.exit_code = event.task.exit_code;
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<pre>{{ logs }}</pre>
|
<pre id="term">{{ logs }}</pre>
|
||||||
|
|
||||||
<table border="1">
|
<table border="1">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="build in builds">
|
<tr ng-repeat="build in builds | orderBy:'-number'">
|
||||||
<td><a ng-href="/{{ repo.full_name }}/{{ build.number }}">{{ build.number }}</a></td>
|
<td><a ng-href="/{{ repo.full_name }}/{{ build.number }}">{{ build.number }}</a></td>
|
||||||
<td>{{ build.state }}</td>
|
<td>{{ build.state }}</td>
|
||||||
<td>{{ build.started_at | fromNow }}</td>
|
<td>{{ build.started_at | fromNow }}</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user