2018-03-07 23:09:25 +01:00
# Semaphore Tasks
# These tasks should be used to build and develop Semaphore
#
# Tasks without a `desc:` field are intended mainly to be called
# internally by other tasks and therefore are not listed when running `task` or `task -l`
2018-03-10 23:34:18 +01:00
version : '2'
tasks :
all :
desc : Install, Compile, Test and Build Semaphore for local architecture
cmds :
2018-03-12 13:27:13 +01:00
- task : deps
- task : compile
- task : test
- task : build:local
2018-03-10 23:34:18 +01:00
deps :
desc : Install all dependencies
cmds :
2018-03-11 15:22:50 +01:00
- task : deps:tools
2018-03-10 23:34:18 +01:00
- task : deps:be
- task : deps:fe
deps:be :
2018-03-11 15:22:50 +01:00
desc : Vendor application dependencies
2018-03-10 23:34:18 +01:00
cmds :
2018-03-11 15:22:50 +01:00
- dep ensure -vendor-only
2018-03-10 23:34:18 +01:00
deps:fe :
desc : Installs npm requirements for front end from package.json
2018-03-12 13:27:13 +01:00
dir : web
2018-03-10 23:34:18 +01:00
cmds :
- npm i -g less pug-cli
2018-03-12 13:27:13 +01:00
- npm install
2018-03-10 23:34:18 +01:00
2018-03-11 15:22:50 +01:00
deps:tools :
desc : Installs tools needed
2018-03-12 13:27:13 +01:00
dir : web
2018-03-20 23:40:54 +01:00
vars :
GORELEASER_VERSION : "0.62.5"
2018-03-10 23:34:18 +01:00
cmds :
- npm install -g nodemon
2018-03-11 15:22:50 +01:00
- go get -u github.com/golang/dep/cmd/dep
2018-03-12 13:27:13 +01:00
- go get github.com/cespare/reflex || true
2018-03-11 15:22:50 +01:00
- go get -u github.com/gobuffalo/packr/...
- go get -u github.com/haya14busa/goverage
2018-03-20 23:40:54 +01:00
- '{{ if ne OS "windows" }} curl -L https://github.com/goreleaser/goreleaser/releases/download/v{{ .GORELEASER_VERSION }}/goreleaser_$(uname -s)_$(uname -m).tar.gz | tar -xz -C ${GOPATH}/bin{{ else }}ver>nul{{ end }}'
- '{{ if ne OS "windows" }} chmod +x ${GOPATH}/bin/goreleaser{{ else }}ver>nul{{ end }}'
- '{{ if eq OS "windows" }} echo "NOTICE: You must download goreleaser manually to build this application https://github.com/goreleaser/goreleaser/releases "{{ else }}:{{ end }}'
2018-03-10 23:34:18 +01:00
compile :
desc : Generates compiled frontend and backend resources (must be in this order)
cmds :
- task : compile:fe
- task : compile:be
compile:fe :
desc : Runs less, pug and node
2018-03-12 13:27:13 +01:00
dir : web
2018-03-10 23:34:18 +01:00
sources :
2018-03-12 13:27:13 +01:00
- resources/css/semaphore.less
- resources/html/*.pug
- resources/html/**/*.pug
2018-03-10 23:34:18 +01:00
generates :
2018-03-12 13:27:13 +01:00
- public/css/semaphore.css
- public/html/*.html
- public/html/**/*.html
- bundle.json
2018-03-10 23:34:18 +01:00
cmds :
2018-03-12 13:27:13 +01:00
- lessc resources/less/semaphore.less > public/css/semaphore.css
- pug resources/pug --out public/html
- cp node_modules/font-awesome/fonts/* public/fonts
- node bundler.js
2018-03-10 23:34:18 +01:00
compile:be :
desc : Runs Packr for static assets
sources :
2018-03-12 13:27:13 +01:00
- web/public/*
2018-03-10 23:34:18 +01:00
- db/migrations/*
generates :
- db/db-packr.go
- api/api-packr.go
cmds :
- packr
2018-03-08 00:42:11 +01:00
- go run util/version_gen/generator.go {{ if .TAG }}{{ .TAG }}{{ else }}{{ if .SEMAPHORE_VERSION }}{{ .SEMAPHORE_VERSION }}{{ else }}{{ .BRANCH }}-{{ .SHA }}-{{ .TIMESTAMP }}{{ if .DIRTY }}-dirty{{ end }}{{ end }}{{end}}
vars :
TAG :
sh : git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null | sed -n 's/^\([^^~]\{1,\}\)\(\^0\)\{0,1\}$/\1/p'
BRANCH :
sh : git rev-parse --abbrev-ref HEAD
DIRTY :
sh : git status --porcelain
SHA :
sh : git log --pretty=format:'%h' -n 1
TIMESTAMP :
sh : date +%s
2018-03-10 23:34:18 +01:00
watch :
desc : Watch fe and be file changes and rebuild
2018-03-12 13:27:13 +01:00
dir : web/resources
2018-03-10 23:34:18 +01:00
cmds :
- task : watch:fe
- task : watch:be
watch:be :
cmds :
2018-03-12 13:27:13 +01:00
- reflex -r '\.go$' -R '^node_modules/' -s -d none -- sh -c 'go build -i -o /tmp/semaphore_bin cli/main.go && /tmp/semaphore_bin -config $(pwd)/config.json'
2018-03-10 23:34:18 +01:00
watch:fe :
2018-03-14 14:44:58 +01:00
dir : web
2018-03-10 23:34:18 +01:00
cmds :
- nodemon -w js -i bundle.js -e js bundler.js &
2018-03-14 14:44:58 +01:00
- nodemon -w css -e less --exec "lessc resources/less/semaphore.less > public/css/semaphore.css" &
- pug -w -P --doctype html resources/pug --out public/html &
2018-03-10 23:34:18 +01:00
build :
2018-03-13 21:57:55 +01:00
desc : Build a full set of release binaries and packages
2018-03-10 23:34:18 +01:00
cmds :
2018-03-14 20:26:52 +01:00
- task : release
2018-03-10 23:34:18 +01:00
build:local :
desc : Build a binary for the current architecture
dir : cli
cmds :
- go build -o ../bin/semaphore
2018-03-14 20:26:52 +01:00
release :
2018-03-13 21:57:55 +01:00
desc : creates a release without performing validations or publishing artifacts
cmds :
- goreleaser --snapshot --rm-dist
2018-03-14 20:26:52 +01:00
release:prod :
2018-03-13 21:57:55 +01:00
cmds :
- goreleaser
2018-03-10 23:34:18 +01:00
test :
desc : Run go code tests
cmds :
- go vet ./...
2018-03-11 01:52:31 +01:00
# 2> /dev/null makes goverage less noisy about pattern matching
# if no tests exist but will still print failing test results
- goverage -v -coverprofile=coverage.out ./... 2> /dev/null
2018-03-10 23:34:18 +01:00
ci:artifacts :
cmds :
2018-03-13 21:57:55 +01:00
- rsync -a bin/ $CIRCLE_ARTIFACTS/