aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorGravatar Abhinav Gupta <mail@abhinavg.net> 2022-12-18 23:01:59 -0800
committerGravatar GitHub <noreply@github.com> 2022-12-18 23:01:59 -0800
commite3604e558f6bd4dccc96b9bd071223fd8506888f (patch)
treed1b7afb258a91f44d4fe532ddc9dd96bd629e67d /Makefile
parentc70dd0aacb63464520aa3fcf01e8fb8b9c9576c7 (diff)
downloadsally-e3604e558f6bd4dccc96b9bd071223fd8506888f.tar.gz
sally-e3604e558f6bd4dccc96b9bd071223fd8506888f.tar.zst
sally-e3604e558f6bd4dccc96b9bd071223fd8506888f.zip
Makefile: Simplify (#62)
This simplifies the Makefile significantly, borrowing patterns we've used in other projects. Namely: - Set GOBIN to a bin subdirectory so that we can `go install` dependencies into it. - Use a shared TEST_FLAGS for `make test` and `make cover`. Without this, we're not running with data race detection in CI. - Build lint step out of separate golint and staticcheck steps. In the future, a gofmt step may also be added. - Move tools dependencies into an unpublished subpackage. Note: I didn't mess with the 'clean' and 'run' targets at the bottom of the file even though they're not necessary to avoid a merge conflict with #60.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile49
1 files changed, 26 insertions, 23 deletions
diff --git a/Makefile b/Makefile
index b938911..4b9b0cd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,39 +1,42 @@
-GOLINT = go run golang.org/x/lint/golint
-STATICCHECK = go run honnef.co/go/tools/cmd/staticcheck
+export GOBIN = $(shell pwd)/bin
+export PATH := $(GOBIN):$(PATH)
-.PHONY: all
-all: test
+GOLINT = bin/golint
+STATICCHECK = bin/staticcheck
-.PHONY: build
-build:
- go build
+TEST_FLAGS ?= -race
-.PHONY: install
-install:
- go install .
+.PHONY: all
+all: lint install test
.PHONY: lint
-lint:
- $(GOLINT) ./...
-
-.PHONY: vet
-vet:
- go vet ./...
+lint: golint staticcheck
.PHONY: staticcheck
-staticcheck:
- $(STATICCHECK) -tests=false ./...
+staticcheck: $(STATICCHECK)
+ $(STATICCHECK) ./...
-.PHONY: pretest
-pretest: lint vet staticcheck
+$(STATICCHECK): tools/go.mod
+ cd tools && go install honnef.co/go/tools/cmd/staticcheck
+
+.PHONY: golint
+golint: $(GOLINT)
+ $(GOLINT) ./...
+
+$(GOLINT): tools/go.mod
+ cd tools && go install golang.org/x/lint/golint
+
+.PHONY: install
+install:
+ go install .
.PHONY: test
-test: pretest
- go test -race ./...
+test:
+ go test $(TEST_FLAGS) ./...
.PHONY: cover
cover:
- go test -coverprofile=cover.out -covermode=atomic -coverpkg=./... ./...
+ go test $(TEST_FLAGS) -coverprofile=cover.out -covermode=atomic -coverpkg=./... ./...
go tool cover -html=cover.out -o cover.html
.PHONY: clean