diff --git a/.gitignore b/.gitignore index 0cf2903..2fbd0a8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,9 @@ # Knowledge base KB/ .core/ + +# Local Go tooling caches +.cache/ +.gocache/ +.gomodcache/ +.gopath/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..60d426d --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +.PHONY: build vet test cover tidy clean + +override GOCACHE := $(CURDIR)/.cache/go-build +override GOPATH := $(CURDIR)/.cache/go +GO ?= go + +GO_ENV = GOCACHE=$(GOCACHE) GOPATH=$(GOPATH) + +build: + @mkdir -p $(GOCACHE) $(GOPATH) + @$(GO_ENV) $(GO) build ./... + +vet: + @mkdir -p $(GOCACHE) $(GOPATH) + @$(GO_ENV) $(GO) vet ./... + +test: + @mkdir -p $(GOCACHE) $(GOPATH) + @$(GO_ENV) $(GO) test ./... -count=1 -timeout 120s + +cover: + @mkdir -p $(GOCACHE) $(GOPATH) + @$(GO_ENV) $(GO) test -cover ./... + +tidy: + @mkdir -p $(GOCACHE) $(GOPATH) + @$(GO_ENV) $(GO) mod tidy + +clean: + @rm -rf $(CURDIR)/.cache $(CURDIR)/.gocache $(CURDIR)/.gomodcache $(CURDIR)/.gopath diff --git a/README.md b/README.md index bc645e0..7128e2d 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,17 @@ go test -bench=. ./... go build ./... ``` +For repeatable local runs in a clean workspace, the repo also ships a +`Makefile` with the standard workflow targets: + +```bash +make build +make vet +make test +make cover +make tidy +``` + ## Licence European Union Public Licence 1.2 — see [LICENCE](LICENCE) for details.