-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
113 lines (97 loc) · 2.8 KB
/
Taskfile.yml
File metadata and controls
113 lines (97 loc) · 2.8 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# https://taskfile.dev
version: '3'
tasks:
setup:
desc: Setup linter, formatter, etc. for local testing and CI
cmds:
- task: brew-install-go
- task: brew-install-jq
- task: install-changie
- task: install-gofumpt
- task: install-golangci-lint
lint:
desc: Formatting and linting
cmds:
- test -z "$(gofumpt -d -e . | tee /dev/stderr)"
- golangci-lint run --timeout 5m
fix:
desc: Fix formatting and linting
cmds:
- gofumpt -w .
- go mod tidy
- golangci-lint run --timeout 5m --fix
deps:
desc: Update dependencies
cmds:
- go get -u
- go mod tidy
test:
desc: Run tests
dir: "{{.SRC_DIR}}"
cmds:
- go test -race -coverprofile=coverage.txt -covermode=atomic -v ./... {{ .CLI_ARGS }}
silent: true
ci:
desc: Workflow to run in CI
deps: [setup]
cmds:
- task: lint
- task: test
build:
cmds:
- go build . {{ .CLI_ARGS }}
run:
cmds:
- go run main.go {{ .CLI_ARGS }}
brew-install-go:
internal: false
platforms: [darwin]
cmds: ["which go > /dev/null || brew install go"]
preconditions:
- sh: 'which brew'
msg: '"brew" needed to install "go"- see https://brew.sh'
brew-install-jq:
internal: false
platforms: [darwin]
cmds: ["which jq > /dev/null || brew install jq"]
preconditions:
- sh: 'which brew'
msg: '"brew" needed to install "jq"- see https://brew.sh'
go-install-tool:
desc: go install '{{.GO_TOOL}}' and set GOBIN if not set
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]
install-changie:
desc: go install "changie"
internal: true
cmds:
- task: go-install-tool
vars: { GO_TOOL: "changie", GO_TOOL_PATH: "github.com/miniscruff/changie@latest" }
install-delve:
desc: go install "dlv"
internal: true
cmds:
- task: go-install-tool
vars: { GO_TOOL: "dlv", GO_TOOL_PATH: "github.com/go-delve/delve/cmd/dlv@latest" }
install-gofumpt:
desc: go install "gofumpt"
internal: true
cmds:
- task: go-install-tool
vars: { GO_TOOL: "gofumpt", GO_TOOL_PATH: "mvdan.cc/gofumpt@latest" }
install-golangci-lint:
desc: go install "golangci-lint"
internal: true
cmds:
- task: go-install-tool
vars: { GO_TOOL: "golangci-lint", GO_TOOL_PATH: "github.com/golangci/golangci-lint/cmd/golangci-lint@latest" }