-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
76 lines (57 loc) · 1.89 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
include .bingo/Variables.mk
TARGET = bin/stentor
SOURCES := $(shell find . -name '*.go' -a -not -name '*_test.go')
# commands
TESTER = tools/gotestsum
# variables
BUILDDATE := $(shell date +%Y-%m-%d)
COMMIT := $(shell git rev-parse HEAD)
RELEASEFLAGS = $(if $(filter false,$(DRYRUN)),,--snapshot) --rm-dist
REPORTDIR = reports
STENTORFLAGS = $(if $(filter false,$(DRYRUN)),-release)
TESTFLAGS = -cover -covermode=atomic
# output controls
override Q = $(if $(filter 1,$(V)),,@)
override M = ▶
.DEFAULT_GOAL := all
.PHONY: all
all: lint build test
.PHONY: build
build: $(TARGET)
.PHONY: changelog
changelog: $(TARGET) | $(GOTAGGER) ; $(info $(M) generating changelog)
$Q $(TARGET) $(STENTORFLAGS) $(shell $(GOTAGGER)) $(shell git tag --list --sort=-version:refname | head -n1)
.PHONY: clean
clean:
$Q $(RM) -r bin/ dist/ reports/
.PHONY: dist
dist: | $(GORELEASER) ; $(info $(M) building dist…)
$(GORELEASER) release $(RELEASEFLAGS)
.PHONY: fmt format ; $(info $(M) formatting…)
fmt format: LINTERFLAGS += --fix
fmt format: lint | $(GOLANGCI_LINT)
.PHONY: lint
lint: | $(GOLANGCI_LINT) ; $(info $(M) linting…)
$Q $(GOLANGCI_LINT) run $(LINTERFLAGS)
.PHONY: test tests
test tests: | $(GOTESTSUM) ; $(info $(M) running tests…)
$Q $(GOTESTSUM) $(TESTERFLAGS) -- $(TESTFLAGS) ./...
.PHONY: test-report
test-report: TESTERFLAGS += --junitfile reports/junit.xml
test-report: TESTFLAGS += -coverprofile=reports/cover.out
test-report: $(REPORTDIR)
test-report: test
.PHONY: test-watch
test-watch: TESTERFLAGS += --watch
test-watch: test
.PHONY: show
show:
@echo $(VALUE)=$($(VALUE))
.PHONY: version
version: | $(GOTAGGER)
@$(GOTAGGER)
.PHONY: FORCE
$(TARGET): FORCE | $(GOTAGGER); $(info $(M) building $(TARGET)…)
$Q go build -o $@ -mod=readonly -ldflags "-X main.buildDate=$(BUILDDATE) -X main.commit=$(COMMIT) -X main.version=$$($(GOTAGGER))" ./cmd/stentor/
$(REPORTDIR):
@mkdir -p $@