mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-24 22:06:43 +01:00
266 lines
7.9 KiB
YAML
266 lines
7.9 KiB
YAML
# 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`
|
|
version: '2'
|
|
|
|
tasks:
|
|
all:
|
|
desc: Install, Compile, Test and Build Semaphore for local architecture
|
|
cmds:
|
|
- task: deps
|
|
- task: compile
|
|
- task: test
|
|
- task: build:local
|
|
|
|
deps:
|
|
desc: Install all dependencies
|
|
cmds:
|
|
- task: deps:tools
|
|
- task: deps:be
|
|
- task: deps:fe
|
|
|
|
deps:be:
|
|
desc: Vendor application dependencies
|
|
cmds:
|
|
- dep ensure -vendor-only
|
|
|
|
deps:fe:
|
|
desc: Installs npm requirements for front end from package.json
|
|
dir: web
|
|
cmds:
|
|
- npm i -g less pug-cli
|
|
- npm install
|
|
|
|
deps:tools:
|
|
desc: Installs tools needed
|
|
dir: web
|
|
vars:
|
|
GORELEASER_VERSION: "0.62.5"
|
|
cmds:
|
|
- npm install -g nodemon
|
|
- go get -u github.com/golang/dep/cmd/dep
|
|
- go get github.com/cespare/reflex || true
|
|
- go get -u github.com/gobuffalo/packr/...
|
|
- go get -u github.com/haya14busa/goverage
|
|
- '{{ 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 }}'
|
|
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
|
|
dir: web
|
|
sources:
|
|
- resources/css/semaphore.less
|
|
- resources/html/*.pug
|
|
- resources/html/**/*.pug
|
|
generates:
|
|
- public/css/semaphore.css
|
|
- public/html/*.html
|
|
- public/html/**/*.html
|
|
- bundle.json
|
|
cmds:
|
|
- 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
|
|
|
|
compile:be:
|
|
desc: Runs Packr for static assets
|
|
sources:
|
|
- web/public/*
|
|
- db/migrations/*
|
|
generates:
|
|
- db/db-packr.go
|
|
- api/api-packr.go
|
|
cmds:
|
|
- packr
|
|
- 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
|
|
|
|
watch:
|
|
desc: Watch fe and be file changes and rebuild
|
|
dir: web/resources
|
|
cmds:
|
|
- task: watch:fe
|
|
- task: watch:be
|
|
|
|
watch:be:
|
|
cmds:
|
|
- 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'
|
|
|
|
watch:fe:
|
|
dir: web
|
|
cmds:
|
|
- nodemon -w js -i bundle.js -e js bundler.js &
|
|
- 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 &
|
|
|
|
build:
|
|
desc: Build a full set of release binaries and packages
|
|
cmds:
|
|
- task: release
|
|
|
|
build:local:
|
|
desc: Build a binary for the current architecture
|
|
dir: cli
|
|
cmds:
|
|
- go build -o ../bin/semaphore
|
|
|
|
release:
|
|
desc: creates a release without performing validations or publishing artifacts
|
|
cmds:
|
|
- goreleaser --snapshot --rm-dist
|
|
|
|
release:prod:
|
|
cmds:
|
|
- goreleaser
|
|
|
|
test:
|
|
desc: Run go code tests
|
|
cmds:
|
|
- go vet ./...
|
|
# 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
|
|
|
|
ci:artifacts:
|
|
cmds:
|
|
- rsync -a bin/ $CIRCLE_ARTIFACTS/
|
|
|
|
# docker(-compose) commands
|
|
dc:dev:
|
|
desc: build and start a development stack using docker-compose
|
|
cmds:
|
|
- task: docker
|
|
vars:
|
|
context: dev
|
|
args: build semaphore_dev
|
|
compose: true
|
|
- task: dc:up
|
|
vars:
|
|
context: dev
|
|
|
|
# convenience function to build and start a production like stack
|
|
dc:prod:
|
|
desc: build and start a production like stack using docker-compose
|
|
cmds:
|
|
- task: docker
|
|
vars:
|
|
context: prod
|
|
args: build semaphore
|
|
compose: true
|
|
- task: dc:up
|
|
vars:
|
|
context: prod
|
|
|
|
dc:up:
|
|
desc: start a docker-compose instance, requires context
|
|
cmds:
|
|
- task: docker
|
|
vars:
|
|
compose: true
|
|
args: up --abort-on-container-exit
|
|
context: "{{ .context }}"
|
|
|
|
dc:build:
|
|
desc: build a set of docker-compose containers, requires context
|
|
cmds:
|
|
- task: docker
|
|
vars:
|
|
compose: true
|
|
args: build
|
|
context: "{{ .context }}"
|
|
|
|
dc:down:
|
|
desc: down a docker-compose instance, requires context
|
|
cmds:
|
|
- task: docker
|
|
vars:
|
|
compose: true
|
|
args: down
|
|
context: "{{ .context }}"
|
|
|
|
dc:stop:
|
|
desc: stop a docker-compose instance, requires context
|
|
cmds:
|
|
- task: docker
|
|
vars:
|
|
compose: true
|
|
args: stop
|
|
context: "{{ .context }}"
|
|
|
|
docker:build:
|
|
desc: Build an image for Semaphore, requires context
|
|
vars:
|
|
tag: "{{ if .tag }}{{ .tag }}{{ else }}latest{{ end }}"
|
|
cmds:
|
|
- task: docker
|
|
vars:
|
|
context: "{{ .context }}"
|
|
action: build
|
|
tag: "{{ .tag }}"
|
|
args: -t castawaylabs/semaphore:{{ .tag }} .
|
|
|
|
deps:docker:
|
|
desc: Install docker testing dependencies. These must be installed explicitly and are not included in the general deps task.
|
|
status:
|
|
- test -f /usr/local/bin/goss
|
|
- test -f /usr/local/bin/dgoss
|
|
- test -f /usr/local/bin/hadolint
|
|
cmds:
|
|
- sudo curl -L https://github.com/aelsabbahy/goss/releases/download/v0.3.5/goss-linux-amd64 -o /usr/local/bin/goss
|
|
- sudo chmod +rx /usr/local/bin/goss
|
|
- sudo curl -L https://raw.githubusercontent.com/aelsabbahy/goss/v0.3.5/extras/dgoss/dgoss -o /usr/local/bin/dgoss
|
|
- sudo chmod +rx /usr/local/bin/dgoss
|
|
- sudo curl -L https://github.com/hadolint/hadolint/releases/download/v1.5.0/hadolint-Linux-x86_64 -o /usr/local/bin/hadolint
|
|
- sudo chmod +rx /usr/local/bin/hadolint
|
|
|
|
docker:test:
|
|
desc: Test docker containers by building them, running tests and deleting
|
|
deps: ['deps:docker']
|
|
cmds:
|
|
- task: docker:lint
|
|
vars:
|
|
context: "{{ .context }}"
|
|
- task: docker:build
|
|
vars:
|
|
tag: "{{ .context }}-test"
|
|
- task: docker:goss
|
|
- docker rmi "castawaylabs/semaphore:{{ .context }}-test"
|
|
|
|
docker:goss:
|
|
dir: "deployment/docker/{{ .context}}"
|
|
deps: ['deps:docker']
|
|
cmds:
|
|
- GOSS_FILES_STRATEGY='cp' dgoss run -it "castawaylabs/semaphore:{{ .context }}-test"
|
|
|
|
docker:lint:
|
|
desc: hadolint a dockerfile. Ignores version pinning warning
|
|
dir: "deployment/docker/{{ .context}}"
|
|
cmds:
|
|
- hadolint Dockerfile --ignore DL3018
|
|
|
|
# templated command to reduce code duplication
|
|
docker:
|
|
vars:
|
|
docker_root: deployment/docker/
|
|
cmds:
|
|
- docker{{ if .compose }}-compose{{ end }} {{ if .action }}{{ .action }}{{ end }} -f {{ .docker_root }}{{ .context }}/{{ if .compose }}docker-compose.yml{{ else }}Dockerfile{{ end }} {{if .args }}{{ .args }}{{ end }}
|