-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
377 lines (312 loc) · 10.1 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
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
version: '3'
dotenv: [ '.env' ]
env:
GOFMT: gofumpt
tasks:
build:
ignore_error: true
cmds:
- go build ./examples/...
- go build ./pkg/...
- go build ./internal/...
- go build ./tools/...
release:
cmd: goreleaser release --clean --skip-publish --skip-validate
assets:
cmd: git submodule update --init --recursive
am-dbg:
silent: false
cmds:
- go run ./tools/cmd/am-dbg {{.CLI_ARGS}}
am-dbg-asset:
desc: Start am-dbg with an asset dump file
silent: false
cmds:
- go run ./tools/cmd/am-dbg
--import-data assets/asyncmachine-go/am-dbg-exports/pubsub-sim.gob.br
--select-machine sim-p0
--select-transition 20
-l -1
{{.CLI_ARGS}}
am-dbg-ssh:
silent: false
desc: Run am-dbg-ssh with sample data on localhost:4444
cmds:
- go run ./tools/cmd/am-dbg-ssh
--import-data assets/asyncmachine-go/am-dbg-exports/pubsub-sim.gob.br
--select-machine sim-p0
--select-transition 20
{{.CLI_ARGS}}
am-dbg-ssh-connect:
silent: false
desc: Connect to a running am-dbg-ssh at localhost:4444
cmds:
- ssh localhost -p 4444 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
am-dbg-dump:
desc: Start am-dbg with a recent dump file
silent: false
cmds:
- go run ./tools/cmd/am-dbg
--import-data am-dbg-dump.gob.br
{{.CLI_ARGS}}
am-dbg-dbg:
desc: Start am-dbg on port 9913, so it can debug other instances via --am-dbg-addr
cmds:
- go run ./tools/cmd/am-dbg
--listen-on localhost:9913
--select-connected
{{.CLI_ARGS}}
# --log-file am-dbg-dbg.log
# --log-level 2
am-dbg-worker:
desc: Run am-dbg as an RPC worker, optionally starting the dbg RPC server via -server-addr
silent: false
cmds:
- go run ./internal/testing/cmd/am-dbg-worker
-server-addr=localhost:53470
-worker-addr=localhost:53480
test:
env:
AM_TEST_RUNNER: 1
desc: Run all local tests
cmds:
- task: clean
- go test ./... {{.CLI_ARGS}}
test-count:
env:
AM_TEST_RUNNER: 1
cmd: task --silent test -- -v | grep -o "PASS:" | wc -l > tests.txt
test-count-pkg:
env:
AM_TEST_RUNNER: 1
cmds:
- task: clean
- go test ./pkg/... -v | grep -o "PASS:" | wc -l > tests-pkg.txt
test-coverage:
cmds:
- task test -- -coverprofile=coverage.txt -covermode=atomic >
coverage.sum.txt
- go tool cover -func=coverage.txt | grep total | awk '{print $3}' >
coverage.sum.txt
test-coverage-pkg:
env:
AM_TEST_RUNNER: 1
cmds:
- task: clean
- go test ./pkg/... -coverprofile=coverage-pkg.txt -covermode=atomic
- go tool cover -func=coverage-pkg.txt | grep total | awk '{print $3}' >
coverage-pkg.sum.txt
test-series:
env:
AM_TEST_RUNNER: 1
desc: Run all local tests in a series
cmds:
- task: clean
- go test -p 1 ./... {{.CLI_ARGS}}
test-race:
env:
AM_TEST_RUNNER: 1
AM_DETECT_EVAL: 1
desc: Run all local tests with -race
cmds:
- task: clean
- go test -v -race ./... {{.CLI_ARGS}}
test-debugger:
desc: Run local am-dbg integration tests
cmds:
- task: clean
- go test
./tools/debugger/test {{.CLI_ARGS}}
test-debugger-remote:
dotenv:
- config/env/tests-remote.env
desc: Run remote am-dbg integration tests against a running worker (see task am-dbg-worker)
cmds:
- task: clean
- go test -tags test_worker
./tools/debugger/test/remote {{.CLI_ARGS}}
precommit:
cmd: .git/hooks/pre-commit
clean:
cmd: go clean -testcache
cloc-go:
cmd: gocloc --output-type json . |
jq '.languages[] | select(.name == "Go").code' |
go run ./scripts/compact_number
cloc-go-pkg:
cmd: gocloc --output-type json pkg |
jq '.languages[] | select(.name == "Go").code' |
go run ./scripts/compact_number
cloc:
cmds:
- printf "\n----- pkg/machine\n\n"
- gocloc pkg/machine --not-match=_test\.go
- gocloc pkg/machine --match=_test\.go
- printf "\n----- pkg/rpc\n\n"
- gocloc pkg/rpc --not-match=_test\.go
- gocloc pkg/rpc --match=_test\.go
- printf "\n----- pkg/node\n\n"
- gocloc pkg/node --not-match=_test\.go
- gocloc pkg/node --match=_test\.go
- printf "\n----- pkg/telemetry\n\n"
- gocloc pkg/telemetry --not-match=_test\.go
- gocloc pkg/telemetry --match=_test\.go
- printf "\n----- pkg/history\n\n"
- gocloc pkg/history --not-match=_test\.go
- gocloc pkg/history --match=_test\.go
- printf "\n----- tools/debugger\n\n"
- gocloc tools/debugger --not-match=_test\.go
- gocloc tools/debugger --match=_test\.go
- printf "\n----- tools/generator\n\n"
- gocloc tools/generator --not-match=_test\.go
- printf "\n----- examples\n\n"
- gocloc examples
- printf "\n----- docs\n\n"
- gocloc --include-lang=md docs
format:
cmds:
- $GOFMT -w examples/*/*.go
- $GOFMT -w pkg/**/*.go
- $GOFMT -w tools/**/*.go
- goimports -w -local "github.com/pancsta/asyncmachine-go" pkg/**/*.go
- goimports -w -local "github.com/pancsta/asyncmachine-go" tools/**/*.go
lint:
cmds:
- task: lint-go
- task: lint-md
# https://github.com/markdownlint/markdownlint/issues/136
- |
if grep -q "]()" docs/*.md; then
echo "Error: Empty links" >&2
exit 1
fi
- task: check-fmt
lint-go:
cmds:
- $(go env GOPATH)/bin/golangci-lint run --fix
lint-md:
cmds:
- mdl -g -c config/mdlrc .
check-fmt:
silent: false
cmds:
- test -z "$($GOFMT -l examples/**/*.go)"
- test -z "$($GOFMT -l pkg/**/*.go)"
- test -z "$($GOFMT -l tools/**/*.go)"
- test -z "$(goimports -l -local "github.com/pancsta/asyncmachine-go" pkg/**/*.go)"
- test -z "$(goimports -l -local "github.com/pancsta/asyncmachine-go" tools/**/*.go)"
gen-changelog:
cmds:
- gem install github_changelog_generator
- github_changelog_generator --token $GITHUB_TOKEN
- head -n -4 CHANGELOG.md > CHANGELOG-tmp.md
- mv CHANGELOG-tmp.md CHANGELOG.md
install-deps:
cmds:
- go mod tidy
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.62.0
- go install mvdan.cc/gofumpt@latest
- go install golang.org/x/tools/cmd/goimports@latest
- go install github.com/mattn/goreman@latest
- go install github.com/itchyny/gojq/cmd/gojq@latest
# TODO switch to nodejs md linter
- gem install mdl
- go install github.com/hhatto/gocloc/cmd/gocloc@latest
install-deps-video:
cmds:
- npm install -g terminalizer
am-gen-states:
desc: Generate a states file in ROOT DIR for provided state names, eg "task am-gen-states -- -s Foo,Bar -n MyMach"
cmds:
- go run ./tools/cmd/am-gen states-file {{.CLI_ARGS}}
am-gen-grafana:
desc: Generate a Grafana dashboard, eg "task am-gen-grafana -- --ids mymach,rm-mymach --name mymach --source my-service"
cmds:
- go run ./tools/cmd/am-gen grafana {{.CLI_ARGS}}
video-gif:
env:
DISPLAY: :0
cmds:
- terminalizer render assets/asyncmachine-go/video.cast.yml -o assets/asyncmachine-go/video.gif
- convert assets/asyncmachine-go/video.gif -delete 0 assets/asyncmachine-go/video.gif
- magick assets/asyncmachine-go/video.gif -layers optimize assets/asyncmachine-go/video.gif
video-gif-quick:
desc: Render a low quality video gif
env:
DISPLAY: :0
cmds:
- terminalizer render assets/asyncmachine-go/video.cast.yml -o assets/asyncmachine-go/video.gif -q 15
- convert assets/asyncmachine-go/video.gif -delete 0 assets/asyncmachine-go/video.gif
video:
desc: Record a video
cmds:
- terminalizer record
--config config/terminalizer.yml assets/asyncmachine-go/video.cast
--skip-sharing
# delete first 1 record (each has 2 lines)
- sed -i '/^records:/{n;N;d;}' assets/asyncmachine-go/video.cast.yml
video-run:
cmds:
- go run ./internal/cmd/am-dbg-video
video-all:
desc: Create assets/asyncmachine-go/video.gif using internal/cmd/video
cmds:
- task: video
- task: video-gif
godoc:
cmds:
- godoc -http=:6060
gen-manual-pdf:
cmds:
- pandoc -f markdown-implicit_figures docs/manual.md -o assets/asyncmachine-go/manual.pdf
prof-cpu-img:
cmds:
- go tool pprof -png cpu.prof > cpu.light.png
- magick cpu.light.png
-channel RGB -negate cpu.dark.png
prof-mem-img:
cmds:
- go tool pprof -png mem.prof > mem.light.png
- magick mem.light.png
-channel RGB -negate mem.dark.png
prof-mem:
cmds:
- curl -s http://localhost:6060/debug/pprof/heap > mem.prof
- task: prof-mem-img
prof-trace:
requires:
vars: [ SEC ]
cmds:
- curl -s http://localhost:6060/debug/pprof/trace?seconds={{.SEC}} > trace.out
- go tool trace -http=:42419 trace.out
benchmark-grpc-build:
dir: examples/benchmark_grpc
cmd: protoc --go_out=. --go_opt=paths=source_relative
--go-grpc_out=. --go-grpc_opt=paths=source_relative
proto/worker.proto
benchmark-grpc:
dir: examples/benchmark_grpc
cmds:
- echo "Running 10_000 server events"
- go test -bench=. -benchtime=10000x -v
website:
dir: website
cmd: npm run preview
website-build:
dir: website
cmd: npm run build
website-serve:
dir: website
cmds:
- task: website-build
- cd build && simple-http-server -p 5000 -i
web-metrics:
cmds:
- docker-compose -f deploy/web-metrics/docker-compose.yml up -d --force-recreate
- |
echo Grafana: http://localhost:3000
echo Jaeger: http://localhost:16686
web-metrics-clean:
cmd: docker-compose -f deploy/web-metrics/docker-compose.yml down -v
gen-grafana-tree-state-source:
cmd: ./examples/tree_state_source/gen-grafana.sh