-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(op-batcher): migrate build to just
- Loading branch information
Showing
2 changed files
with
33 additions
and
51 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 |
---|---|---|
@@ -1,52 +1,3 @@ | ||
GITCOMMIT ?= $(shell git rev-parse HEAD) | ||
GITDATE ?= $(shell git show -s --format='%ct') | ||
# Find the github tag that points to this commit. If none are found, set the version string to "untagged" | ||
# Prioritizes release tag, if one exists, over tags suffixed with "-rc" | ||
VERSION ?= $(shell tags=$$(git tag --points-at $(GITCOMMIT) | grep '^op-batcher/' | sed 's/op-batcher\///' | sort -V); \ | ||
preferred_tag=$$(echo "$$tags" | grep -v -- '-rc' | tail -n 1); \ | ||
if [ -z "$$preferred_tag" ]; then \ | ||
if [ -z "$$tags" ]; then \ | ||
echo "untagged"; \ | ||
else \ | ||
echo "$$tags" | tail -n 1; \ | ||
fi \ | ||
else \ | ||
echo $$preferred_tag; \ | ||
fi) | ||
DEPRECATED_TARGETS := op-batcher clean test fuzz | ||
|
||
LDFLAGSSTRING +=-X main.GitCommit=$(GITCOMMIT) | ||
LDFLAGSSTRING +=-X main.GitDate=$(GITDATE) | ||
LDFLAGSSTRING +=-X main.Version=$(VERSION) | ||
LDFLAGS := -ldflags "$(LDFLAGSSTRING)" | ||
|
||
# Use the old Apple linker to workaround broken xcode - https://github.com/golang/go/issues/65169 | ||
ifeq ($(shell uname),Darwin) | ||
FUZZLDFLAGS := -ldflags=-extldflags=-Wl,-ld_classic | ||
endif | ||
|
||
op-batcher: | ||
env GO111MODULE=on GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) CGO_ENABLED=0 go build -v $(LDFLAGS) -o ./bin/op-batcher ./cmd | ||
|
||
clean: | ||
rm bin/op-batcher | ||
|
||
test: | ||
go test -v ./... | ||
|
||
fuzz: | ||
printf "%s\n" \ | ||
"go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz FuzzChannelConfig_CheckTimeout ./batcher" \ | ||
"go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz FuzzDurationZero ./batcher" \ | ||
"go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz FuzzDurationTimeoutMaxChannelDuration ./batcher" \ | ||
"go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz FuzzDurationTimeoutZeroMaxChannelDuration ./batcher" \ | ||
"go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz FuzzChannelCloseTimeout ./batcher" \ | ||
"go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz FuzzChannelZeroCloseTimeout ./batcher" \ | ||
"go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz FuzzSeqWindowClose ./batcher" \ | ||
"go test $(FUZZLDFLAGS) -run NOTAREALTEST -v -fuzztime 10s -fuzz FuzzSeqWindowZeroTimeoutClose ./batcher" \ | ||
| parallel -j 8 {} | ||
|
||
.PHONY: \ | ||
op-batcher \ | ||
clean \ | ||
test \ | ||
fuzz | ||
include ../just/deprecated.mk |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import '../just/go.just' | ||
|
||
# Build ldflags string | ||
LDFLAGSSTRING := "-X main.GitCommit=" + GITCOMMIT + " -X main.GitDate=" + GITDATE + " -X main.Version=" + VERSION | ||
LDFLAGS := "-ldflags '" + LDFLAGSSTRING + "'" | ||
|
||
# Build op-batcher binary | ||
op-batcher: | ||
{{GOBUILD}} {{LDFLAGS}} -o ./bin/op-batcher ./cmd | ||
|
||
# Clean build artifacts | ||
clean: | ||
rm -f bin/op-batcher | ||
|
||
# Run tests | ||
test: | ||
{{GOTEST}} ./... | ||
|
||
# Run fuzzing tests | ||
fuzz: | ||
#!/usr/bin/env sh | ||
printf "%s\n" \ | ||
"{{GOFUZZ}} -fuzztime 10s -fuzz FuzzChannelConfig_CheckTimeout ./batcher" \ | ||
"{{GOFUZZ}} -fuzztime 10s -fuzz FuzzDurationZero ./batcher" \ | ||
"{{GOFUZZ}} -fuzztime 10s -fuzz FuzzDurationTimeoutMaxChannelDuration ./batcher" \ | ||
"{{GOFUZZ}} -fuzztime 10s -fuzz FuzzDurationTimeoutZeroMaxChannelDuration ./batcher" \ | ||
"{{GOFUZZ}} -fuzztime 10s -fuzz FuzzChannelCloseTimeout ./batcher" \ | ||
"{{GOFUZZ}} -fuzztime 10s -fuzz FuzzChannelZeroCloseTimeout ./batcher" \ | ||
"{{GOFUZZ}} -fuzztime 10s -fuzz FuzzSeqWindowClose ./batcher" \ | ||
"{{GOFUZZ}} -fuzztime 10s -fuzz FuzzSeqWindowZeroTimeoutClose ./batcher" \ | ||
| parallel -j 8 {} |