-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathTaskfile.yml
55 lines (47 loc) · 1.44 KB
/
Taskfile.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# https://taskfile.dev/
version: '3'
tasks:
ci:
desc: Workflow to run in CI
deps: [setup]
cmds:
- task: lint
- task: test
lint:
desc: Formatting and linting
cmds:
- test -z "$(gofumpt -d -e . | tee /dev/stderr)"
- golangci-lint run
fix:
desc: Fix formatting and linting
cmds:
- gofumpt -w .
- go mod tidy
- golangci-lint run --fix
setup:
desc: Setup linter, formatter, etc. for local testing and CI
cmds:
- task: install-go-tool
vars: { GO_TOOL: "gofumpt", GO_TOOL_PATH: "mvdan.cc/gofumpt@latest" }
- task: install-go-tool
vars: { GO_TOOL: "golangci-lint", GO_TOOL_PATH: "github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1" }
test:
desc: Run tests
cmds:
- go test -race -coverprofile=coverage.out -covermode=atomic -v ./... {{ .CLI_ARGS }}
- grep -v "/enum.go" coverage.out > coverage.txt
silent: true
# internal (not directly called) tasks
install-go-tool:
internal: true
silent: true
vars:
IS_TOOL_INSTALLED:
sh: which {{.GO_TOOL}} > /dev/null || echo "1"
cmds:
- test -z "{{.IS_TOOL_INSTALLED}}" || echo "Installing {{.GO_TOOL}}..."
- test -z "{{.IS_TOOL_INSTALLED}}" || go install {{.GO_TOOL_PATH}}
- test -n $(go env GOBIN) || go env -w GOBIN=$(go env GOPATH)/bin
- echo " '{{.GO_TOOL}}' is installed."
requires:
vars: [GO_TOOL, GO_TOOL_PATH]