feat: init taskfile, docker-compose, env
This commit is contained in:
129
Taskfile.go.yaml
Normal file
129
Taskfile.go.yaml
Normal file
@ -0,0 +1,129 @@
|
||||
version: '3'
|
||||
|
||||
vars:
|
||||
GOFUMPT_VER: '{{.GOFUMPT_VER | default "latest"}}'
|
||||
GOIMPORTS_LOCAL: '{{.GOIMPORTS_LOCAL | default nil}}'
|
||||
GOIMPORT_VER: '{{.GOIMPORT_VER | default "latest"}}'
|
||||
GOLANGCI_LINT_VER: '{{.GOLANGCI_LINT_VER | default "latest"}}'
|
||||
GOVULNCHECK_VER: '{{.GOVULNCHECK_VER | default "latest"}}'
|
||||
PROTOLINT_VER: '{{.PROTOLINT_VER | default "latest"}}'
|
||||
STATICCHECK_VER: '{{.STATICCHECK_VER | default "latest"}}'
|
||||
TMP_DIR: '{{.TMP_DIR | default "./tmp"}}'
|
||||
|
||||
tasks:
|
||||
# =======
|
||||
# HELPERS
|
||||
# =======
|
||||
|
||||
lint:
|
||||
desc: golangci-lint + protolint.
|
||||
cmds:
|
||||
- task: govulncheck
|
||||
- task: staticcheck
|
||||
- task: golangci-lint
|
||||
- task: protolint
|
||||
|
||||
cs:
|
||||
desc: fmt + goimports.
|
||||
cmds:
|
||||
- task: fmt
|
||||
- task: goimports
|
||||
|
||||
# ===============
|
||||
# QUALITY CONTROL
|
||||
# ===============
|
||||
|
||||
fmt:
|
||||
desc: format code using gofumpt.
|
||||
cmds:
|
||||
- >-
|
||||
go run mvdan.cc/gofumpt@{{.GOFUMPT_VER}} -l -w .
|
||||
sources:
|
||||
- ./**/*.go
|
||||
|
||||
goimports:
|
||||
desc: format imports using goimports.
|
||||
cmds:
|
||||
- >-
|
||||
go run golang.org/x/tools/cmd/goimports@{{.GOIMPORT_VER}}
|
||||
{{if .GOIMPORTS_LOCAL}} -local="{{.GOIMPORTS_LOCAL}}"{{end}}
|
||||
-w .
|
||||
sources:
|
||||
- ./**/*.go
|
||||
|
||||
tidy:
|
||||
desc: go mod tidy + go mod verify.
|
||||
cmds:
|
||||
- go mod tidy -v
|
||||
- go mod verify
|
||||
sources:
|
||||
- ./**/*.go
|
||||
- go.mod
|
||||
- go.sum
|
||||
|
||||
golangci-lint:
|
||||
desc: golangci-lint.
|
||||
cmds:
|
||||
- go run github.com/golangci/golangci-lint/cmd/golangci-lint@{{.GOLANGCI_LINT_VER}} run -v ./...
|
||||
sources:
|
||||
- ./**/*.go
|
||||
|
||||
govulncheck:
|
||||
desc: govulncheck.
|
||||
cmds:
|
||||
- go run golang.org/x/vuln/cmd/govulncheck@{{.GOVULNCHECK_VER}} ./...
|
||||
sources:
|
||||
- ./**/*.go
|
||||
|
||||
staticcheck:
|
||||
desc: staticcheck.
|
||||
cmds:
|
||||
- go run honnef.co/go/tools/cmd/staticcheck@{{.STATICCHECK_VER}} -checks=all,-ST1000 ./...
|
||||
sources:
|
||||
- ./**/*.go
|
||||
|
||||
protolint:
|
||||
desc: protolint -fix.
|
||||
cmds:
|
||||
- cmd: go run github.com/yoheimuta/protolint/cmd/protolint@{{.PROTOLINT_VER}} lint -fix .
|
||||
ignore_error: true
|
||||
sources: &protolint_sources
|
||||
- ./**/*.proto
|
||||
|
||||
protolint:check:
|
||||
desc: protolint check.
|
||||
cmds:
|
||||
- go run github.com/yoheimuta/protolint/cmd/protolint@{{.PROTOLINT_VER}} lint .
|
||||
sources: *protolint_sources
|
||||
|
||||
# ===========
|
||||
# DEVELOPMENT
|
||||
# ===========
|
||||
|
||||
generate:
|
||||
desc: go generate
|
||||
cmds:
|
||||
- go generate ./...
|
||||
sources:
|
||||
- ./**/*.go
|
||||
|
||||
vendor:
|
||||
desc: go mod vendor.
|
||||
cmds:
|
||||
- go mod vendor -v
|
||||
sources:
|
||||
- go.mod
|
||||
- go.sum
|
||||
generates:
|
||||
- vendor
|
||||
|
||||
test:
|
||||
desc: go tests ./...
|
||||
cmds:
|
||||
- go test -race -buildvcs -coverprofile={{.TMP_DIR}}/coverage.out -vet=off ./...
|
||||
|
||||
test:cover:
|
||||
desc: tests and display coverage.
|
||||
deps: [ test ]
|
||||
cmds:
|
||||
- go tool cover -html={{.TMP_DIR}}/coverage.out
|
Reference in New Issue
Block a user