2019-08-05 22:58:24 +02:00
|
|
|
ALL_PKGS := $(shell go list ./...)
|
2019-07-03 01:21:24 +02:00
|
|
|
|
2019-08-02 19:44:32 +02:00
|
|
|
# All source code and documents. Used in spell check.
|
|
|
|
ALL_DOCS := $(shell find . -name '*.md' -type f | sort)
|
|
|
|
|
2019-07-03 01:21:24 +02:00
|
|
|
GOTEST=go test
|
|
|
|
GOTEST_OPT?=-v -race -timeout 30s
|
|
|
|
GOTEST_OPT_WITH_COVERAGE = $(GOTEST_OPT) -coverprofile=coverage.txt -covermode=atomic
|
|
|
|
|
|
|
|
.DEFAULT_GOAL := precommit
|
|
|
|
|
2019-06-19 02:09:49 +02:00
|
|
|
.PHONY: precommit
|
|
|
|
|
|
|
|
TOOLS_DIR := ./.tools
|
|
|
|
|
|
|
|
$(TOOLS_DIR)/golangci-lint: go.mod go.sum tools.go
|
|
|
|
go build -o $(TOOLS_DIR)/golangci-lint github.com/golangci/golangci-lint/cmd/golangci-lint
|
|
|
|
|
2019-08-02 19:44:32 +02:00
|
|
|
$(TOOLS_DIR)/misspell: go.mod go.sum tools.go
|
|
|
|
go build -o $(TOOLS_DIR)/misspell github.com/client9/misspell/cmd/misspell
|
|
|
|
|
2019-08-07 23:33:39 +02:00
|
|
|
precommit: $(TOOLS_DIR)/golangci-lint $(TOOLS_DIR)/misspell
|
2019-08-05 22:58:24 +02:00
|
|
|
$(TOOLS_DIR)/golangci-lint run --fix # TODO: Fix this on windows.
|
|
|
|
$(TOOLS_DIR)/misspell -w $(ALL_DOCS)
|
2019-07-03 01:21:24 +02:00
|
|
|
|
|
|
|
.PHONY: test-with-coverage
|
|
|
|
test-with-coverage:
|
|
|
|
$(GOTEST) $(GOTEST_OPT_WITH_COVERAGE) $(ALL_PKGS)
|
|
|
|
go tool cover -html=coverage.txt -o coverage.html
|
|
|
|
|
|
|
|
.PHONY: circle-ci
|
|
|
|
circle-ci: precommit test-with-coverage test-386
|
|
|
|
|
|
|
|
.PHONY: test
|
|
|
|
test:
|
|
|
|
$(GOTEST) $(GOTEST_OPT) $(ALL_PKGS)
|
|
|
|
|
|
|
|
.PHONY: test-386
|
|
|
|
test-386:
|
|
|
|
GOARCH=386 $(GOTEST) -v -timeout 30s $(ALL_PKGS)
|
|
|
|
|
|
|
|
all-pkgs:
|
|
|
|
@echo $(ALL_PKGS) | tr ' ' '\n' | sort
|
|
|
|
|
2019-08-05 22:58:24 +02:00
|
|
|
all-docs:
|
|
|
|
@echo $(ALL_DOCS) | tr ' ' '\n' | sort
|