-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
186 lines (160 loc) · 4.28 KB
/
Taskfile.yaml
File metadata and controls
186 lines (160 loc) · 4.28 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
version: "3"
vars:
APP: protoc-gen-go-ddl
env:
GOPRIVATE: github.com/taehoio
tasks:
default:
cmds:
- task: install:deps
- task: install:tools
install:prereqs:
desc: Installs prerequisites
cmds:
- brew bundle
sources:
- Brewfile
preconditions:
- sh: commend -v brew
msg: "Please install Homebrew: https://brew.sh/"
install:deps:
desc: Installs dependencies
run: once
cmds:
- cmd: asdf plugin-add golang
ignore_error: true
- cmd: asdf plugin add golangci-lint
ignore_error: true
- asdf install
- asdf current
sources:
- .tool-versions
install:tools:
desc: Installs tools from tools.go
run: once
cmds:
- echo Installing tools from tools.go
- cat tools.go | grep _ | awk -F'/' '{print $NF}' | awk -F'"' '{print "which "$1}' | sh $1 | xargs rm -f
- cat tools.go | grep _ | awk -F'"' '{print $2}' | xargs -tI % go install %
sources:
- tools.go
- go.mod
build:
desc: Builds the application
cmds:
- CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags="-w -s" -o bin/{{.APP}} main.go
build:all:
desc: Builds the application for all platforms
cmds:
- CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s" -o bin/{{.APP}}.linux.amd64 main.go
- CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -installsuffix cgo -ldflags="-w -s" -o bin/{{.APP}}.linux.arm64 main.go
- CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags="-w -s" -o bin/{{.APP}} main.go
run:
desc: Runs the application
cmds:
- go run -v -race main.go
format:
desc: Formats files
deps:
- format:proto
- format:go
format:proto:
desc: Formats proto files
deps:
- install:tools
cmds:
- buf format -w
format:go:
desc: Formats go files
deps:
- install:tools
cmds:
- find . -not -path './gen/*' -not -path './tools.go' -not -name '*_mock.go' -name '*.go' -print0 | xargs -0 -I {} goimports-reviser -rm-unused -format -company-prefixes github.com/taehoio {}
- go mod tidy
lint:
desc: Lints files
deps:
- lint:proto
- lint:go
lint:proto:
desc: Lints proto files
deps:
- install:tools
cmds:
- buf lint protos
lint:go:
desc: Lints go files
deps:
- install:tools
cmds:
- golangci-lint run ./...
- find . -not -path './gen/*' -not -path './tools.go' -not -name '*_mock.go' -name '*.go' -print0 | xargs -0 -I {} goimports-reviser -rm-unused -format -company-prefixes github.com/taehoio -list-diff -set-exit-status {}
- go mod verify
test:
desc: Runs tests
deps:
- install:tools
cmds:
- task: test:unit
test:unit:
desc: Runs unit tests
deps:
- install:tools
cmds:
- gotest -p 1 -race -cover -v ./...
test:coverage:
desc: Runs unit tests with coverage
deps:
- install:tools
cmds:
- gotest -p 1 -race -coverprofile=coverage.out -covermode=atomic -v ./...
test:watch:
desc: Watches and runs tests
deps:
- install:tools
cmds:
- modd
generate:
desc: Generates files
cmds:
- task: generate:proto
- task: generate:testdata
- task: generate:mocks
generate:proto:
desc: Generates proto files
deps:
- install:tools
cmds:
- buf generate protos
install:protoc-gen-marshal-input:
desc: Installs protoc-gen-marshal-input
deps:
- install:tools
cmds:
- rm -f ${GOPATH}/bin/protoc-gen-go-ddl
- go install
- rm -f ${GOPATH}/bin/protoc-gen-marshal-input
- cd cmd/protoc-gen-marshal-input ; go install ; cd -
generate:testdata:
desc: Generates testdata
deps:
- install:protoc-gen-marshal-input
cmds:
- rm -f testdata/marshaled_input.dat
- cd testdata ; buf generate protos --exclude-path "protos/google"; cd -
generate:mocks:
desc: Generates go mocks
deps:
- install:tools
cmds:
- go generate ./...
clean:
desc: Cleans up
cmds:
- rm -rf gen
- rm -rf testdata/gen
diff:
desc: Shows diff
cmds:
- git diff --exit-code
- if [ -n "$(git status --porcelain)" ]; then git status; exit 1; else exit 0; fi