Created
August 19, 2016 19:24
-
-
Save kavu/05742de22b1adde65851bc087b1bcdcc to your computer and use it in GitHub Desktop.
Nice Go Makefile
This file contains hidden or 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
VERSION := $(shell git describe --tags | sed -e 's/^v//g' | awk -F "-" '{print $$1}') | |
ITERATION := $(shell git describe --tags --long | awk -F "-" '{print $$2}') | |
GO_VERSION=$(shell gobuild -v) | |
GO := $(or $(GOROOT),/usr/lib/go)/bin/go | |
PROCS := $(shell nproc) | |
cores: | |
@echo "cores: $(PROCS)" | |
test: | |
go test -v | |
bench: | |
go test -bench . | |
bench-record: | |
$(GO) test -bench . > "benchmarks/stun-go-$(GO_VERSION).txt" | |
fuzz-prepare-msg: | |
go-fuzz-build -func FuzzMessage -o stun-msg-fuzz.zip github.com/cydev/stun | |
fuzz-prepare-typ: | |
go-fuzz-build -func FuzzType -o stun-typ-fuzz.zip github.com/cydev/stun | |
fuzz-msg: | |
go-fuzz -bin=./stun-msg-fuzz.zip -workdir=examples/stun-msg | |
fuzz-typ: | |
go-fuzz -bin=./stun-typ-fuzz.zip -workdir=examples/stun-typ | |
lint: | |
@echo "linting on $(PROCS) cores" | |
@gometalinter -e "AttrType.+gocyclo" \ | |
-e "_test.go.+(gocyclo|errcheck|dupl)" \ | |
--enable="lll" --line-length=80 \ | |
--enable="gofmt" \ | |
--disable=gotype \ | |
--deadline=300s \ | |
-j $(PROCS) | |
@echo "ok" | |
escape: | |
@echo "Not escapes, except autogenerated:" | |
@go build -gcflags '-m -l' 2>&1 \ | |
| grep -v "<autogenerated>" \ | |
| grep escapes | |
blackbox: | |
@TEST_EXTERNAL=1 go test -run TestClientSend -v | |
format: | |
goimports -w . | |
bench-compare: | |
go test -bench . > bench.go-16 | |
go-tip test -bench . > bench.go-tip | |
@benchcmp bench.go-16 bench.go-tip | |
install: | |
go get -u sourcegraph.com/sqs/goreturns | |
go get -u github.com/alecthomas/gometalinter | |
gometalinter --install --update | |
go get -u github.com/cydev/go-fuzz/go-fuzz-build | |
go get -u github.com/dvyukov/go-fuzz/go-fuzz | |
push: | |
git push origin dev | |
release: | |
@read -p "Enter new release version: " version; \ | |
./extras/scripts/release.sh $$version | |
prepare: | |
go get github.com/mitchellh/gox | |
go get github.com/tools/godep | |
godep restore | |
bindata: | |
go-bindata-assetfs -prefix="extras" extras/web/... | |
mv bindata_assetfs.go bindata.go | |
gofmt -w bindata.go | |
godep save -r ./... | |
package: | |
./extras/scripts/package.sh $(VERSION) $(ITERATION) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment