From 775bc5caf636f48adb59e045bc4ed6682413e2bd Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Sat, 30 Sep 2017 16:40:39 +0200 Subject: [PATCH] Rudimentary Makefile specifying requirements for a release --- .gitignore | 3 +++ Makefile | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 90c451e..c5d989b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Build +artifacts/ + # Golang vendor/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3558ac7 --- /dev/null +++ b/Makefile @@ -0,0 +1,47 @@ +.PHONY: generate build test vet cover release clean + +ROOT := github.com/zrepl/zrepl +SUBPKGS := cmd logger rpc sshbytestream util + +_TESTPKGS := $(ROOT) $(foreach p,$(SUBPKGS),$(ROOT)/$(p)) + +ARTIFACTDIR := artifacts + +build: generate + go build -o $(ARTIFACTDIR)/zrepl + +generate: + @for pkg in $(_TESTPKGS); do\ + go generate "$$pkg" || exit 1; \ + done; + +test: + @for pkg in $(_TESTPKGS); do \ + echo "Testing $$pkg"; \ + go test "$$pkg" || exit 1; \ + done; + +vet: + @for pkg in $(_TESTPKGS); do \ + echo "Vetting $$pkg"; \ + go vet "$$pkg" || exit 1; \ + done; + +cover: artifacts + @for pkg in $(_TESTPKGS); do \ + profile="$(ARTIFACTDIR)/cover-$$(basename $$pkg).out"; \ + go test -coverprofile "$$profile" $$pkg || exit 1; \ + if [ -f "$$profile" ]; then \ + go tool cover -html="$$profile" -o "$${profile}.html" || exit 2; \ + fi; \ + done; + +artifacts: + mkdir artifacts + +release: generate artifacts vet test + GOOS=linux GOARCH=amd64 go build -o "$(ARTIFACTDIR)/zrepl-linux-amd64" + GOOS=freebsd GOARCH=amd64 go build -o "$(ARTIFACTDIR)/zrepl-freebsd-amd64" + +clean: + rm -rf "$(ARTIFACTDIR)"