-
-
Notifications
You must be signed in to change notification settings - Fork 42
/
Taskfile.yml
146 lines (126 loc) · 3.28 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
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
version: "3"
silent: true
tasks:
default:
desc: "Show available tasks"
cmds:
- task --list-all
pre-commit:
desc: "Run tests, linter and build examples"
cmds:
- go mod tidy
- task: generate
- task: lint
- task: test
- task: build:lib
- task: build:examples
lint:
desc: "Run golangci-lint"
deps: [ install:lint ]
cmds:
- golangci-lint run
lint:list:
desc: "Run golangci-lint linters (print enabled & disabled linters)"
deps: [ install:lint ]
cmds:
- golangci-lint linters
test:
desc: "Run tests"
cmds:
- mkdir -p bin
- |
go test -coverprofile bin/cover.out \
$(go list ./... | grep -v /examples | grep -v /internal | grep -v /mock)
sources:
- ./**/*.go
- go.mod
- go.sum
generates:
- bin/cover.out
test:all-tags:
desc: "Run tests for all tags"
cmds:
- mkdir -p bin
- |
go test -coverprofile bin/cover.out \
$(go list ./... | grep -v /examples | grep -v /internal | grep -v /mock)
- |
go test -tags sonic -coverprofile bin/cover-sonic.out \
$(go list ./... | grep -v /examples | grep -v /internal | grep -v /mock)
- |
go test -tags stdjson -coverprofile bin/cover-stdjson.out \
$(go list ./... | grep -v /examples | grep -v /internal | grep -v /mock)
sources:
- ./**/*.go
- go.mod
- go.sum
generates:
- bin/cover.out
- bin/cover-sonic.out
- bin/cover-stdjson.out
test:cover:
desc: "Run tests & show coverage"
deps:
- test
cmds:
- go tool cover -func bin/cover.out
test:race:
desc: "Run tests with a race flag"
cmds:
- go test -race -count=8 -failfast $(go list ./... | grep -v /examples | grep -v /internal | grep -v /mock)
test:bench:
desc: "Run benchmarks"
cmds:
- go test -bench=. -benchtime=10s -benchmem
build:lib:
desc: "Build library"
cmds:
- go build -o ./bin ./...
build:examples:
desc: "Build examples"
dir: ./examples
cmds:
- go build -o ../bin/ ./...
update:dependencies:
desc: "Update dependencies"
cmds:
- go mod tidy
- go list -f "{{"{{if not (or .Main .Indirect)}}{{.Path}}{{end}}"}}" -m all | xargs go get
- go mod tidy
generate:
desc: "Generate (used for mock generation)"
deps: [ install:mock ]
cmds:
- go generate ./...
generator:
desc: "Run specific generation"
dir: ./internal/generator
cmds:
- go run . {{.CLI_ARGS}}
generator:all:
desc: "Run all generators"
cmds:
- task: generator
vars:
CLI_ARGS: types types-tests types-setters types-setters-tests methods methods-tests methods-setters methods-setters-tests
generator:clean-up:
desc: "Remove generated files"
cmds:
- rm *.generated
install:
desc: "Install all tools"
deps:
- install:lint
- install:mock
install:lint:
desc: "Install golangci-lint"
cmds:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
status:
- command -v golangci-lint
install:mock:
desc: "Install mockgen"
cmds:
- go install go.uber.org/mock/mockgen@latest
status:
- command -v mockgen