From 7e21566af3f11966e319266f600e3397b24be0e6 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 27 Aug 2015 10:12:29 +0200 Subject: [PATCH 1/5] Integrated clean task --- make.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/make.go b/make.go index 3eea7696b..f85bd28fa 100644 --- a/make.go +++ b/make.go @@ -34,6 +34,7 @@ var steps = map[string]step{ "build": build, "test": test, "image": image, + "clean": clean, } func main() { @@ -170,6 +171,47 @@ func image() error { return nil } +func clean() error { + err := filepath.Walk(".", func(path string, f os.FileInfo, err error) error { + suffixes := []string{ + ".out", + "_bindata.go", + } + + for _, suffix := range suffixes { + if strings.HasSuffix(path, suffix) { + if err := os.Remove(path); err != nil { + return err + } + } + } + + return nil + }) + + if err != nil { + return err + } + + files := []string{ + "bin/drone", + "bin/drone-agent", + "bin/drone-build", + } + + for _, file := range files { + if _, err := os.Stat(file); err != nil { + continue + } + + if err := os.Remove(file); err != nil { + return err + } + } + + return nil +} + // trace is a helper fucntion that writes a command // to stdout similar to bash +x func trace(args []string) { From c2346e3275efe46f1c4dfa13560a69600eb9e1e0 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 27 Aug 2015 10:53:12 +0200 Subject: [PATCH 2/5] Integrated styles task --- .gitignore | 1 + make.go | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 35e5df54d..63905c71f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ drone.sublime-workspace *.rice-box.go *.db *.txt +*.min.css *.min.js *_bindata.go *.toml diff --git a/make.go b/make.go index f85bd28fa..2383e17d6 100644 --- a/make.go +++ b/make.go @@ -9,6 +9,7 @@ package main import ( "fmt" + "io/ioutil" "os" "os/exec" "path/filepath" @@ -67,10 +68,42 @@ func scripts() error { return nil } -// styles step concatinates the css files. +// styles step concatinates the stylesheet files. func styles() error { - // concatinate styles - // inject css variables? + files := []string{ + "cmd/drone-server/static/styles/reset.css", + "cmd/drone-server/static/styles/fonts.css", + "cmd/drone-server/static/styles/alert.css", + "cmd/drone-server/static/styles/blankslate.css", + "cmd/drone-server/static/styles/list.css", + "cmd/drone-server/static/styles/label.css", + "cmd/drone-server/static/styles/range.css", + "cmd/drone-server/static/styles/switch.css", + "cmd/drone-server/static/styles/main.css", + } + + f, err := os.OpenFile( + "cmd/drone-server/static/styles/drone.min.css", + os.O_CREATE|os.O_RDWR|os.O_TRUNC, + 0660) + + defer f.Close() + + if err != nil { + fmt.Println("Failed to open output file") + return err + } + + for _, input := range files { + content, err := ioutil.ReadFile(input) + + if err != nil { + return err + } + + f.Write(content) + } + return nil } From ab44a65e8143452b584bf8fd030603360182c594 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 27 Aug 2015 10:57:17 +0200 Subject: [PATCH 3/5] Integrated scripts task --- make.go | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/make.go b/make.go index 2383e17d6..c9a4cd355 100644 --- a/make.go +++ b/make.go @@ -64,7 +64,45 @@ func embed() error { // scripts step concatinates all javascript files. func scripts() error { - // concatinate scripts + files := []string{ + "cmd/drone-server/static/scripts/term.js", + "cmd/drone-server/static/scripts/drone.js", + "cmd/drone-server/static/scripts/controllers/repos.js", + "cmd/drone-server/static/scripts/controllers/builds.js", + "cmd/drone-server/static/scripts/controllers/users.js", + "cmd/drone-server/static/scripts/services/repos.js", + "cmd/drone-server/static/scripts/services/builds.js", + "cmd/drone-server/static/scripts/services/users.js", + "cmd/drone-server/static/scripts/services/logs.js", + "cmd/drone-server/static/scripts/services/tokens.js", + "cmd/drone-server/static/scripts/services/feed.js", + "cmd/drone-server/static/scripts/filters/filter.js", + "cmd/drone-server/static/scripts/filters/gravatar.js", + "cmd/drone-server/static/scripts/filters/time.js", + } + + f, err := os.OpenFile( + "cmd/drone-server/static/scripts/drone.min.js", + os.O_CREATE|os.O_RDWR|os.O_TRUNC, + 0660) + + defer f.Close() + + if err != nil { + fmt.Println("Failed to open output file") + return err + } + + for _, input := range files { + content, err := ioutil.ReadFile(input) + + if err != nil { + return err + } + + f.Write(content) + } + return nil } From d6a546a309e2105d66d58027b907f8960f0bb160 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 27 Aug 2015 11:03:03 +0200 Subject: [PATCH 4/5] Removed in go implemented tasks from Makefile --- Makefile | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/Makefile b/Makefile index b2122286a..58694db59 100644 --- a/Makefile +++ b/Makefile @@ -3,16 +3,6 @@ SHA := $(shell git rev-parse --short HEAD) VERSION := 0.4.0-alpha -all: concat bindata build - -deps: - go get github.com/jteeuwen/go-bindata/... - -test: - go vet github.com/drone/drone/pkg/... - go vet github.com/drone/drone/cmd/... - go test -cover -short github.com/drone/drone/pkg/... - # Execute the database test suite against mysql 5.5 # # You can launch a mysql container locally for testing: @@ -22,38 +12,14 @@ test_mysql: TEST_DRIVER="mysql" TEST_DATASOURCE="root@tcp(127.0.0.1:3306)/test" go test -short github.com/drone/drone/pkg/store/builtin mysql -P 3306 --protocol=tcp -u root -e 'drop database test;' -build: - go build -o bin/drone -ldflags "-X main.revision=$(SHA) -X main.version=$(VERSION).$(SHA)" github.com/drone/drone/cmd/drone-server - go build -o bin/drone-agent -ldflags "-X main.revision=$(SHA) -X main.version=$(VERSION).$(SHA)" github.com/drone/drone/cmd/drone-agent - run: - bin/drone-server --debug - -clean: - find . -name "*.out" -delete - find . -name "*_bindata.go" -delete - rm -f bin/drone* - -concat: - cat cmd/drone-server/static/scripts/drone.js \ - cmd/drone-server/static/scripts/services/*.js \ - cmd/drone-server/static/scripts/filters/*.js \ - cmd/drone-server/static/scripts/controllers/*.js \ - cmd/drone-server/static/scripts/term.js > cmd/drone-server/static/scripts/drone.min.js + bin/drone --debug # installs the drone binaries into bin install: install -t /usr/local/bin bin/drone install -t /usr/local/bin bin/drone-agent -# embeds all the static files directly -# into the drone binary file -bindata: - $$GOPATH/bin/go-bindata -o="cmd/drone-server/drone_bindata.go" cmd/drone-server/static/... - -bindata_debug: - $$GOPATH/bin/go-bindata --debug -o="cmd/drone-server/drone_bindata.go" cmd/drone-server/static/... - docker: docker build --file=cmd/drone-build/Dockerfile.alpine --rm=true -t drone/drone-build . From 075fd5e52259c250b072858f9c3980182838d210 Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Thu, 27 Aug 2015 11:03:23 +0200 Subject: [PATCH 5/5] Execute the new go make tasks --- .drone.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 87ca16e3c..b1bd7bd56 100644 --- a/.drone.yml +++ b/.drone.yml @@ -9,9 +9,12 @@ script: - go get golang.org/x/tools/cmd/cover - go get golang.org/x/tools/cmd/vet - go get -u github.com/jteeuwen/go-bindata/... - - make bindata deps + + - go run make.go bindata - go run make.go build - - go run make.go vet test + - go run make.go vet + - go run make.go test + - make dist notify: