Skip to content

Commit

Permalink
ci(bench): Add benchmark-action (#2283)
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Henderson <[email protected]>
  • Loading branch information
hairyhenderson authored Dec 14, 2024
1 parent f4d9693 commit 66fd58b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: go benchmarks
on:
push:
branches:
- main
pull_request:

jobs:
benchmark:
name: benchmark regression check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Run benchmark
run: make bench.txt
- name: Download previous benchmark data
uses: actions/cache@v4
with:
path: ./cache
key: ${{ runner.os }}-benchmark
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
tool: 'go'
output-file-path: bench.txt
external-data-json-path: ./cache/benchmark-data.json
fail-on-alert: true
comment-on-alert: true
comment-always: true
github-token: ${{ secrets.GITHUB_TOKEN }}
alert-threshold: "200%"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ report.xml
*.out
.netlify
docs/.hugo_build.lock
bench.txt
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ test:
$(GO) test -race -coverprofile=c.out ./...
endif

bench.txt: go.mod go.sum $(GO_FILES)
$(GO) test -benchmem -run=xxx -bench . ./... | tee $@

.SECONDEXPANSION:
testbin/%.test.exe: $$(shell $$(GO) list -f '{{.Dir}}' $$(subst testbin/,,$$(subst .test.exe,,$$@)))
@GOOS=windows GOARCH=amd64 $(GO) test -c -o $@ $<
Expand Down

0 comments on commit 66fd58b

Please sign in to comment.