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
|
||||
- PATH=$PATH:$GOROOT/bin:$GOPATH/bin
|
||||
script:
|
||||
- make deps
|
||||
- make
|
||||
- go get -u github.com/jteeuwen/go-bindata/...
|
||||
- make bindata deps
|
||||
- make build
|
||||
- make test
|
||||
|
||||
notify:
|
||||
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -13,5 +13,7 @@ drone.sublime-workspace
|
||||
*.db
|
||||
*.txt
|
||||
*.toml
|
||||
*.min.js
|
||||
bindata.go
|
||||
|
||||
drone
|
||||
drone
|
||||
|
16
Makefile
16
Makefile
@ -1,7 +1,7 @@
|
||||
SHA := $(shell git rev-parse --short HEAD)
|
||||
VERSION := 0.4.0-alpha
|
||||
|
||||
all: build
|
||||
all: concat bindata build
|
||||
|
||||
deps:
|
||||
go get -t -v ./...
|
||||
@ -16,3 +16,17 @@ build:
|
||||
clean:
|
||||
find . -name "*.out" -delete
|
||||
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 (
|
||||
"flag"
|
||||
"html/template"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
@ -11,16 +13,17 @@ import (
|
||||
"github.com/drone/drone/server"
|
||||
"github.com/drone/drone/server/session"
|
||||
"github.com/drone/drone/settings"
|
||||
"github.com/elazarl/go-bindata-assetfs"
|
||||
|
||||
queue "github.com/drone/drone/queue/builtin"
|
||||
)
|
||||
|
||||
var path = flag.String("config", "drone.toml", "")
|
||||
var conf = flag.String("config", "drone.toml", "")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
settings, err := settings.Parse(*path)
|
||||
settings, err := settings.Parse(*conf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -106,12 +109,16 @@ func main() {
|
||||
|
||||
queue := api.Group("/queue")
|
||||
{
|
||||
queue.Use(server.SetRepo())
|
||||
queue.GET("", server.GetQueue)
|
||||
queue.POST("/pull", server.PollBuild)
|
||||
queue.POST("/push/:owner/:name", server.PushBuild)
|
||||
queue.POST("/push/:owner/:name/:build", server.PushTask)
|
||||
queue.POST("/push/:owner/:name/:build/:task/logs", server.PushLogs)
|
||||
|
||||
push := queue.Group("/push/:owner/:name")
|
||||
{
|
||||
push.Use(server.SetRepo())
|
||||
push.POST("", server.PushBuild)
|
||||
push.POST("/:build", server.PushTask)
|
||||
push.POST("/:build/:task/logs", server.PushLogs)
|
||||
}
|
||||
}
|
||||
|
||||
events := api.Group("/stream")
|
||||
@ -131,9 +138,30 @@ func main() {
|
||||
auth.POST("", server.GetLogin)
|
||||
}
|
||||
|
||||
r.SetHTMLTemplate(index())
|
||||
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) {
|
||||
q := fromContext(c)
|
||||
var work *queue.Work
|
||||
if c.Request.FormValue("ack") != "" {
|
||||
if c.Request.FormValue("ack") == "true" {
|
||||
work = q.PullAck()
|
||||
} else {
|
||||
work = q.Pull()
|
||||
|
@ -48,9 +48,11 @@ func PushBuild(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if repo.Last == nil || build.Number >= repo.Last.Number {
|
||||
repo.Last = build
|
||||
store.SetRepo(repo)
|
||||
if build.State != common.StatePending && build.State != common.StateRunning {
|
||||
if repo.Last == nil || build.Number >= repo.Last.Number {
|
||||
repo.Last = build
|
||||
store.SetRepo(repo)
|
||||
}
|
||||
}
|
||||
|
||||
// <-- FIXME
|
||||
|
@ -164,10 +164,10 @@ func SetRepo() gin.HandlerFunc {
|
||||
r, err := ds.Repo(owner + "/" + name)
|
||||
switch {
|
||||
case err != nil && u != nil:
|
||||
c.Fail(401, err)
|
||||
c.Fail(404, err)
|
||||
return
|
||||
case err != nil && u == nil:
|
||||
c.Fail(404, err)
|
||||
c.Fail(401, err)
|
||||
return
|
||||
}
|
||||
c.Set("repo", r)
|
||||
|
@ -47,17 +47,28 @@
|
||||
}
|
||||
// update repository
|
||||
$scope.repo = event.repo;
|
||||
$scope.apply();
|
||||
|
||||
if (event.build.number !== parseInt(number)) {
|
||||
return; // ignore
|
||||
}
|
||||
// update the build status
|
||||
$scope.build.state = event.build.state;
|
||||
$scope.build.started = event.build.started;
|
||||
$scope.build.finished = event.build.finished;
|
||||
$scope.build.duration = event.build.duration;
|
||||
$scope.$apply();
|
||||
|
||||
var added = false;
|
||||
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
|
||||
build.state = event.build.state;
|
||||
build.started_at = event.build.started_at;
|
||||
build.finished_at = event.build.finished_at;
|
||||
build.duration = event.build.duration;
|
||||
$scope.builds[i] = build;
|
||||
$scope.$apply();
|
||||
added = true;
|
||||
}
|
||||
|
||||
if (!added) {
|
||||
$scope.builds.push(event.build);
|
||||
$scope.$apply();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -97,7 +108,9 @@
|
||||
|
||||
// fetch the logs for the finished build.
|
||||
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){
|
||||
$scope.error = err;
|
||||
});
|
||||
@ -127,8 +140,8 @@
|
||||
}
|
||||
// update the build status
|
||||
$scope.build.state = event.build.state;
|
||||
$scope.build.started = event.build.started;
|
||||
$scope.build.finished = event.build.finished;
|
||||
$scope.build.started_at = event.build.started_at;
|
||||
$scope.build.finished_at = event.build.finished_at;
|
||||
$scope.build.duration = event.build.duration;
|
||||
$scope.$apply();
|
||||
|
||||
@ -137,8 +150,8 @@
|
||||
}
|
||||
// update the task status
|
||||
$scope.task.state = event.task.state;
|
||||
$scope.task.started = event.task.started;
|
||||
$scope.task.finished = event.task.finished;
|
||||
$scope.task.started_at = event.task.started_at;
|
||||
$scope.task.finished_at = event.task.finished_at;
|
||||
$scope.task.duration = event.task.duration;
|
||||
$scope.task.exit_code = event.task.exit_code;
|
||||
$scope.$apply();
|
||||
|
@ -387,4 +387,4 @@ Filter = (function() {
|
||||
|
||||
return Filter;
|
||||
|
||||
})();
|
||||
})();
|
||||
|
@ -57,7 +57,7 @@
|
||||
|
||||
<hr>
|
||||
|
||||
<pre>{{ logs }}</pre>
|
||||
<pre id="term">{{ logs }}</pre>
|
||||
|
||||
<table border="1">
|
||||
<thead>
|
||||
|
@ -21,7 +21,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<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>{{ build.state }}</td>
|
||||
<td>{{ build.started_at | fromNow }}</td>
|
||||
|
Loading…
Reference in New Issue
Block a user