-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
62 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,5 @@ ledger.test | |
antlr-*-complete.jar | ||
go.work | ||
go.work.sum | ||
|
||
benchs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,60 +2,24 @@ | |
|
||
version: "3" | ||
|
||
vars: | ||
PKG: "./..." | ||
FAILFAST: "-failfast" | ||
TIMEOUT: "10m" | ||
RUN: ".*" | ||
TAGS: "-tags json1,netgo" | ||
BENCH_TIME: "30s" | ||
BENCH_RESULTS_DIR: "/tmp/benchmarks" | ||
BENCH_RESULTS_FILE: "/tmp/benchmarks/ledger.txt" | ||
BENCH_CPU_PROFILE: "/tmp/benchmarks/ledger.cpu.prof" | ||
BENCH_MEM_PROFILE: "/tmp/benchmarks/ledger.mem.prof" | ||
env: | ||
VERBOSE: "false" | ||
BRANCH: | ||
sh: "git rev-parse --abbrev-ref HEAD| cut -d / -f2" | ||
BENCH_RESULTS_DIR: "./benchs" | ||
|
||
tasks: | ||
default: | ||
cmds: | ||
- task: generate | ||
- task: lint | ||
- task: tests:local | ||
|
||
generate: | ||
cmds: | ||
- go generate {{.PKG}} | ||
|
||
lint: | ||
cmds: | ||
- golangci-lint run --fix {{if eq .VERBOSE "true"}}-v{{end}} | ||
|
||
tests: | ||
deps: [postgres] | ||
cmds: | ||
- > | ||
go test {{.TAGS}} {{if eq .VERBOSE "true"}}-v{{end}} -coverpkg {{.PKG}} | ||
-coverprofile coverage.out -covermode atomic {{.PKG}} | ||
env: | ||
STORAGE_POSTGRES_CONN_STRING: "postgresql://ledger:[email protected]/ledger" | ||
|
||
tests:local: | ||
cmds: | ||
- task: tests:local:postgres | ||
|
||
tests:local:postgres: | ||
deps: [postgres] | ||
cmds: | ||
- > | ||
go test {{.TAGS}} {{if eq .VERBOSE "true"}}-v{{end}} {{.FAILFAST}} -coverpkg {{.PKG}} | ||
-coverprofile coverage.out -covermode atomic | ||
-run={{.RUN}} -timeout {{.TIMEOUT}} {{.PKG}} | | ||
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")/'' | ||
- task: print:coverage | ||
env: | ||
STORAGE_POSTGRES_CONN_STRING: "postgresql://ledger:[email protected]/ledger" | ||
print:coverage: | ||
cmds: | ||
|
@@ -67,50 +31,58 @@ tasks: | |
silent: true | ||
|
||
bench: | ||
deps: [postgres] | ||
internal: true | ||
cmds: | ||
- mkdir -p {{.BENCH_RESULTS_DIR}} | ||
- > | ||
go test {{.TAGS}} {{if eq .VERBOSE "true"}}-v{{end}} {{.PKG}} | ||
-run=XXX -bench={{.RUN}} -benchmem -benchtime={{.BENCH_TIME}} -timeout {{.TIMEOUT}} | ||
-cpuprofile {{.BENCH_CPU_PROFILE}} -memprofile {{.BENCH_MEM_PROFILE}} | ||
| tee {{.BENCH_RESULTS_FILE}} | ||
- benchstat {{.BENCH_RESULTS_FILE}} | ||
go test -run BenchmarkParallelWrites -bench=. | ||
-test.benchmem | ||
-timeout 1h | ||
-memprofile {{.BENCH_RESULTS_DIR}}/{{.BRANCH}}-memprofile-{{if eq .ASYNC "true"}}async{{else}}{{end}}.out | ||
-cpuprofile {{.BENCH_RESULTS_DIR}}/{{.BRANCH}}-profile-{{if eq .ASYNC "true"}}async{{else}}sync{{end}}.out | ||
-benchtime={{if .DURATION}}{{.DURATION}}{{else}}15s{{end}} | ||
-count={{if .COUNT}}{{.COUNT}}{{else}}10{{end}} ./pkg/ledger | tee {{.BENCH_RESULTS_DIR}}/{{.BRANCH}}-{{if eq .ASYNC "true"}}async{{else}}sync{{end}}.stats | ||
env: | ||
STORAGE_POSTGRES_CONN_STRING: "postgresql://ledger:[email protected]/ledger" | ||
ASYNC: "{{.ASYNC}}" | ||
GOMEMLIMIT: 1GiB | ||
GOGC: "1000" # https://dave.cheney.net/tag/gogc | ||
|
||
bench:cpu: | ||
bench:async: | ||
cmds: | ||
- go tool pprof -http=":" {{.BENCH_CPU_PROFILE}} | ||
- task: bench | ||
vars: | ||
ASYNC: true | ||
|
||
bench:mem: | ||
bench:sync: | ||
cmds: | ||
- go tool pprof -http=":" {{.BENCH_MEM_PROFILE}} | ||
- task: bench | ||
|
||
install: | ||
deps: | ||
- install:golangci-lint | ||
- install:perf | ||
bench:both: | ||
cmds: | ||
- task: bench:sync | ||
- task: bench:async | ||
|
||
install:golangci-lint: | ||
bench:diff: | ||
internal: true | ||
cmds: | ||
- > | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | | ||
sh -s -- -b $(go env GOPATH)/bin latest | ||
- golangci-lint --version | ||
- > | ||
benchstat {{.BENCH_RESULTS_DIR}}/{{if .SOURCE}}{{.SOURCE}}{{else}}v2{{end}}-{{if eq .ASYNC "true"}}async{{else}}sync{{end}}.stats | ||
{{.BENCH_RESULTS_DIR}}/{{.BRANCH}}-{{if eq .ASYNC "true"}}async{{else}}sync{{end}}.stats | ||
install:perf: | ||
- go install golang.org/x/perf/cmd/...@latest | ||
bench:diff:sync: | ||
cmds: | ||
- task: bench:diff | ||
|
||
postgres: | ||
bench:diff:async: | ||
cmds: | ||
- docker compose up -d postgres | ||
- task: bench:diff | ||
vars: | ||
ASYNC: "true" | ||
|
||
clean: | ||
bench:diff:both: | ||
cmds: | ||
- go clean | ||
- rm -f {{.SERVICE}} coverage.out coverage.html | ||
- docker compose down -v | ||
- task: bench:diff:sync | ||
- task: bench:diff:async | ||
|
||
sdk:template: | ||
desc: Extract templates | ||
|
@@ -142,22 +114,6 @@ tasks: | |
--git-repo-id=formance-sdk-{{.CLI_ARGS}} | ||
-p packageVersion={{.VERSION}} | ||
sdk:test: | ||
desc: Test client code | ||
dir: ./sdk | ||
preconditions: | ||
- sh: '[ "{{.CLI_ARGS}}" != "" ]' | ||
msg: Please specify generator as first cli arg (ie "task test -- go") | ||
- sh: "[[ -e sdks/{{.CLI_ARGS}}/Taskfile.yml ]]" | ||
msg: "Not Taskfile found. You have to create a taskfile in ./sdks/{{.CLI_ARGS}}/ with a 'test' task" | ||
vars: | ||
RANDOM: | ||
sh: "echo $$" | ||
cmds: | ||
- | | ||
cd ./sdks/{{.CLI_ARGS}} | ||
task test | ||
goreleaser:test:pkg: | ||
desc: Test a package | ||
cmds: | ||
|
@@ -194,22 +150,3 @@ tasks: | |
Platform: "arm64" | ||
Image: ubuntu | ||
Cmd: "{{.dpkg}} *_linux_arm64.deb" | ||
|
||
run: | ||
cmds: | ||
- docker compose up -d --remove-orphans | ||
|
||
stop: | ||
cmds: | ||
- docker compose stop | ||
|
||
ps: | ||
cmds: | ||
- docker compose ps | ||
|
||
rm: | ||
deps: [stop] | ||
cmds: | ||
- docker compose rm -f | ||
- docker volume prune -f | ||
- rm -f {{.BENCH_CPU_PROFILE}} {{.BENCH_MEM_PROFILE}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters