Skip to content

Commit

Permalink
fix bench ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jimchen committed Aug 22, 2024
1 parent 9aece9c commit 8e408c0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ jobs:
matrix:
os: [ubuntu-latest]
go: ["1.22"]
test-tags: ["-benchmem -bench ."]
test-floder: ["go list ./... | grep benchmarks"]
include:
- os: ubuntu-latest
go-build: ~/.cache/go-build
name: ${{ matrix.os }} @ Go ${{ matrix.go }} ${{ matrix.test-tags }}
runs-on: ${{ matrix.os }}
env:
GO111MODULE: on
TESTTAGS: ${{ matrix.test-tags }}
TESTFOLDER: ${{ matrix.test-floder }}
GOPROXY: https://proxy.golang.org
steps:
- name: Set up Go ${{ matrix.go }}
Expand All @@ -51,4 +47,4 @@ jobs:
${{ runner.os }}-go-
- name: Benchmark
run: make test
run: make bench
25 changes: 24 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ GO_VERSION=$(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
PACKAGES ?= $(shell $(GO) list ./...)
VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /examples/)
GOFILES := $(shell find . -name "*.go")
TESTFOLDER ?= $(shell $(GO) list ./... | grep -v examples)
TESTFOLDER := $(shell $(GO) list ./... | grep -v examples | grep -v benchmarks)
BENCHFOLDER := $(shell $(GO) list ./... | grep benchmarks)
TESTTAGS ?= ""

.PHONY: test
Expand All @@ -30,6 +31,28 @@ test:
fi; \
done

.PHONY: bench
# runs benchmarks.
bench:
for d in $(BENCHFOLDER); do \
$(GO) test -benchmem -bench . -v -covermode=count -coverprofile=profile.out $$d > benchmark.out; \
cat benchmark.out; \
if grep -q "^--- FAIL" benchmark.out; then \
rm tmp.out; \
exit 1; \
elif grep -q "build failed" benchmark.out; then \
rm tmp.out; \
exit 1; \
elif grep -q "setup failed" benchmark.out; then \
rm tmp.out; \
exit 1; \
fi; \
if [ -f profile.out ]; then \
cat profile.out | grep -v "mode:" >> coverage.out; \
rm profile.out; \
fi; \
done

.PHONY: fmt
# Ensure consistent code formatting.
fmt:
Expand Down

0 comments on commit 8e408c0

Please sign in to comment.