-
-
Notifications
You must be signed in to change notification settings - Fork 94
/
Taskfile.yaml
207 lines (181 loc) · 5.49 KB
/
Taskfile.yaml
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# https://taskfile.dev
version: "3"
env:
VERBOSE: "false"
BRANCH:
sh: "git rev-parse --abbrev-ref HEAD| cut -d / -f2"
BENCH_RESULTS_DIR: "./benchs"
tasks:
lint:
cmds:
- golangci-lint run --fix --allow-parallel-runners --config ./../../.golangci.yml
tests:
cmds:
- >
go test -failfast -coverpkg ./... -coverprofile coverage.out -covermode atomic ./... |
sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' |
sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/'' |
sed ''/RUN/s//$(printf "\033[34mRUN\033[0m")/''
print:coverage:
cmds:
- go tool cover -html=coverage.out -o coverage.html
- cov-report ./coverage.out
- echo "To open the html coverage file, use one of the following commands:"
- echo "open coverage.html on mac"
- echo "xdg-open coverage.html on linux"
silent: true
libs/sync:
cmds:
- rm -rf ./libs/*
- cp -R ./../../libs/go-libs/* ./libs/
bench:
internal: true
cmds:
- mkdir -p {{.BENCH_RESULTS_DIR}}
- >
go test -run BenchmarkParallelWrites -bench=. {{if eq .VERBOSE "true"}}-v{{end}}
-test.benchmem
-timeout 1h
-memprofile {{.BENCH_RESULTS_DIR}}/{{.BRANCH}}-memprofile-{{if eq .ASYNC "true"}}async{{else}}sync{{end}}.out
-cpuprofile {{.BENCH_RESULTS_DIR}}/{{.BRANCH}}-profile-{{if eq .ASYNC "true"}}async{{else}}sync{{end}}.out
-benchtime={{if .DURATION}}{{.DURATION}}{{else}}15s{{end}}
{{if eq .RACE "true"}}-race{{end}}
-count={{if .COUNT}}{{.COUNT}}{{else}}10{{end}} ./benchmarks | tee {{.BENCH_RESULTS_DIR}}/{{.BRANCH}}-{{if eq .ASYNC "true"}}async{{else}}sync{{end}}.stats
env:
ASYNC: "{{.ASYNC}}"
GOMEMLIMIT: 1GiB
GOMAXPROCS: 2
VERBOSE: false
# GOGC: "1000" # https://dave.cheney.net/tag/gogc
CGO_ENABLED: 0
# GODEBUG: gctrace=1 #,gcpacertrace=1
bench:async:
cmds:
- task: bench
vars:
ASYNC: true
bench:sync:
cmds:
- task: bench
bench:both:
cmds:
- task: bench:sync
- task: bench:async
bench:diff:
internal: true
cmds:
- >
benchstat {{.BENCH_RESULTS_DIR}}/{{if .SOURCE}}{{.SOURCE}}{{else}}main{{end}}-{{if eq .ASYNC "true"}}async{{else}}sync{{end}}.stats
{{.BENCH_RESULTS_DIR}}/{{.BRANCH}}-{{if eq .ASYNC "true"}}async{{else}}sync{{end}}.stats
bench:diff:sync:
cmds:
- task: bench:diff
bench:diff:async:
cmds:
- task: bench:diff
vars:
ASYNC: "true"
bench:diff:both:
cmds:
- task: bench:diff:sync
- task: bench:diff:async
bench:pprof:
internal: true
cmds:
- go tool pprof -http=":" {{.BENCH_RESULTS_DIR}}/{{.BRANCH}}-{{.KIND}}-{{if eq .ASYNC "true"}}async{{else}}sync{{end}}.out
bench:cpu:pprof:
internal: true
cmds:
- task: bench:pprof
vars:
KIND: profile
ASYNC: "{{.ASYNC}}"
bench:mem:pprof:
internal: true
cmds:
- task: bench:pprof
vars:
KIND: memprofile
ASYNC: "{{.ASYNC}}"
bench:cpu:pprof:async:
cmds:
- task: bench:cpu:pprof
vars:
ASYNC: "true"
bench:cpu:pprof:sync:
cmds:
- task: bench:cpu:pprof
vars:
ASYNC: "false"
bench:mem:pprof:async:
cmds:
- task: bench:mem:pprof
vars:
ASYNC: "true"
bench:mem:pprof:sync:
cmds:
- task: bench:mem:pprof
vars:
ASYNC: "false"
sdk:template:
desc: Extract templates
dir: ./sdk
preconditions:
- sh: '[ "{{.CLI_ARGS}}" != "" ]'
msg: Please specify generator as first cli arg (ie "task template -- go")
cmds:
- >
docker run --rm -w /local -v ${PWD}:/local openapitools/openapi-generator-cli:v6.6.0 author
template -g {{.CLI_ARGS}} -o templates/{{.CLI_ARGS}}
sdk:generate:
desc: Generate client code
dir: ./sdk
preconditions:
- sh: '[ "{{.CLI_ARGS}}" != "" ]'
msg: Please specify generator as first cli arg (ie "task generate -- go")
cmds:
- wget https://raw.githubusercontent.com/formancehq/ledger/{{.VERSION}}/pkg/api/controllers/swagger.yaml -O swagger.yaml
- sed -i -e "s/LEDGER_VERSION/{{.VERSION}}/g" swagger.yaml
- >
docker run --rm -w /local -v ${PWD}:/local openapitools/openapi-generator-cli:v6.6.0 generate
-i ./swagger.yaml
-g {{ (split "-" .CLI_ARGS)._0 }}
-c ./configs/{{.CLI_ARGS}}.yaml
-o ./sdks/{{.CLI_ARGS}}
--git-user-id=formancehq
--git-repo-id=formance-sdk-{{.CLI_ARGS}}
-p packageVersion={{.VERSION}}
goreleaser:test:pkg:
desc: Test a package
cmds:
- docker run --platform linux/{{.Platform}} --rm --workdir /tmp -v $PWD/dist:/tmp {{.Image}} sh -c '{{.Cmd}} && goreleaser --version'
goreleaser:test:rpm:
desc: Tests rpm packages
vars:
rpm: "rpm --nodeps -ivh"
cmds:
- task: goreleaser:test:pkg
vars:
Platform: "amd64"
Image: fedora
Cmd: "{{.rpm}} *_linux_amd64.rpm"
- task: goreleaser:test:pkg
vars:
Platform: "arm64"
Image: fedora
Cmd: "{{.rpm}} *_linux_arm64.rpm"
goreleaser:test:deb:
desc: Tests deb packages
vars:
dpkg: "dpkg --ignore-depends=git -i"
cmds:
- task: goreleaser:test:pkg
vars:
Platform: "amd64"
Image: ubuntu
Cmd: "{{.dpkg}} *_linux_amd64.deb"
- task: goreleaser:test:pkg
vars:
Platform: "arm64"
Image: ubuntu
Cmd: "{{.dpkg}} *_linux_arm64.deb"