This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
51 lines (38 loc) · 1.54 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
.DEFAULT_GOAL := test
GO ?= go
GO_FILES := $(shell find -iname '*.go')
GO_PACKAGES := $(shell $(GO) list ./... | paste -s -d ',')
.PHONY: help
help: ## Show this help.
@awk -F ':|##' '/^[^\t].+?:.*?##/ {\
printf "\033[36m%-30s\033[0m %s\n", $$1, $$NF \
}' $(MAKEFILE_LIST)
# ----------------------------------------------------------------------------
# Tools
# ----------------------------------------------------------------------------
TOOLS_GO := tools.go
TOOLS_DIR := .tools
TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
$(TOOLS_BIN_DIR)/toolmgr:
GOBIN=$(abspath ./$(TOOLS_BIN_DIR)) $(GO) install github.com/fhofherr/toolmgr
$(TOOLS_BIN_DIR)/%: $(TOOLS_GO) | $(TOOLS_BIN_DIR)/toolmgr
$(TOOLS_BIN_DIR)/toolmgr -bin-dir $(TOOLS_BIN_DIR) -tools-go $<
.PRECIOUS: $(TOOLS_BIN_DIR)/%
# ----------------------------------------------------------------------------
# Tests
# ----------------------------------------------------------------------------
PRE_COMMIT ?= pre-commit
.PHONY: lint
lint: $(TOOLS_BIN_DIR)/revive ## Run linter on all files.
$(PRE_COMMIT) run --all-files
.PHONY: test
test: .coverage.out ## Run all tests
.PHONY: coverage-html
coverage-html: .coverage.out ## Show HTML coverage report
$(GO) tool cover -html=$<
.PHONY: coveralls
coveralls: .coverage.out $(TOOLS_BIN_DIR)/goveralls ## Send coverage data to coveralls.
$(TOOLS_BIN_DIR)/goveralls -coverprofile=$< -service=github -reponame=fhofherr/golf
.coverage.out: $(GO_FILES)
@$(GO) test -race -coverpkg=$(GO_PACKAGES) -covermode=atomic -coverprofile=$@ ./...
@$(GO) tool cover -func=$@ | tail -n1