# this is a taskfile and is used with the dev tool named task # you can install this tool with the following command: # env GO111MODULE=on go get -u github.com/go-task/task/v3/cmd/task # if you want to use it in a CI build script chain you can just use # this # GO111MODULE=on go get -u github.com/go-task/task/v3/cmd/task --- version: '3' vars: VERSION: 1.0.0 EXE: beaver{{exeExt}} OUTPUT: "build/{{.EXE}}" GOLANGCI_LINT_VERSION: v1.44.0 GOLANGCI_LINT_BASE: tools/bin/golangci-lint GOLANGCI_LINT_BIN: "{{.GOLANGCI_LINT_BASE}}-{{.GOLANGCI_LINT_VERSION}}" GOLANGCI_LINT_ARGS: tasks: default: cmds: - task: build build: desc: build golang project cmds: - mkdir -p build - | go build \ -ldflags "-X orus.io/cloudcrane/beaver/lib.version={{ .VERSION }}" \ -o {{.OUTPUT}} \ main.go generates: - "{{.OUTPUT}}" fetch-golangci-lint: desc: fetch golangci-lint tool cmds: - mkdir -p tools/bin - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b tools/bin {{.GOLANGCI_LINT_VERSION}} - mv {{.GOLANGCI_LINT_BASE}} {{.GOLANGCI_LINT_BIN}} status: - test -x {{.GOLANGCI_LINT_BIN}} generates: - "{{.GOLANGCI_LINT_BIN}}" lint: desc: lint our golang code to make sure we catch as much errors as possible deps: [fetch-golangci-lint] cmds: - "{{.GOLANGCI_LINT_BIN}} run {{.GOLANGCI_LINT_ARGS}}" test: desc: Run the tests deps: [] cmds: - go test ./... cover: desc: Run tests with coverage deps: [] cmds: - go test -p 1 -covermode=count -coverpkg=./... -coverprofile .cover.cov ./... - go tool cover -func=.cover.cov generates: - .cover.cov cover-html: desc: Creates an html report from the last cover run deps: [] cmds: - go tool cover -html=.cover.cov -o coverage.html generates: - coverage.html