-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (80 loc) · 2.31 KB
/
Makefile
File metadata and controls
99 lines (80 loc) · 2.31 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# commands
GO = go
GOBUILD = $(GO) build
GOBIN = $(CURDIR)/build/tools
# variables
BUILDDATE := $(shell date +%Y-%m-%d)
COMMIT := $(shell git rev-parse HEAD)
GOOS := $(shell $(GO) env GOOS)
VERSION := $(shell $(GO) run ./cmd/gotagger)
$(if $(VERSION),,$(error failed to determine version))
# directories
REPORTDIR = build/reports
# flags
BUILDFLAGS = -v -ldflags '-X main.AppVersion=$(VERSION) -X main.Commit=$(COMMIT) -X main.BuildDate=$(BUILDDATE)'
COVERFLAGS = -covermode $(COVERMODE) -coverprofile $(COVEROUT)
COVERMODE = atomic
COVEROUT = $(REPORTDIR)/coverage.out
COVERXML = $(REPORTDIR)/coverage.xml
LINTFLAGS =
REPORTFLAGS = --jsonfile $(REPORTJSON) --junitfile $(REPORTXML)
REPORTJSON = $(REPORTDIR)/go-test.json
REPORTXML = $(REPORTDIR)/go-test.xml
TESTFLAGS = --format=$(TESTFORMAT) -- -timeout $(TIMEOUT) $(COVERFLAGS)
TESTFORMAT = short
TIMEOUT = 60s
# conditional flags
ifeq ($(DRY_RUN),false)
STENTORFLAGS = -release
else
STENTORFLAGS =
endif
TARGET = build/$(GOOS)/gotagger
# recipes
.PHONY: all
all: lint build test
include .bingo/Variables.mk
.PHONY: build
build:
$(GOBUILD) $(BUILDFLAGS) -o $(TARGET) ./cmd/gotagger/main.go
.PHONY: changelog
changelog: | $(STENTOR)
$(STENTOR) $(STENTORFLAGS) $(VERSION) "$$(git tag --list --sort=version:refname | tail -n1)"
.PHONY: clean
clean:
$(RM) $(TARGET)
$(RM) -r $(REPORTDIR)/ dist/
.PHONY: distclean
distclean: clean
$(RM) -r build/
.PHONY: format
format: LINTFLAGS += --fix
format: lint
.PHONY: lint
lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run $(LINTFLAGS)
.PHONY: report
report: TESTFLAGS := $(REPORTFLAGS) $(TESTFLAGS)
report: test | $(GOCOVER_COBERTURA)
$(GOCOVER_COBERTURA) <$(COVEROUT) >$(COVERXML)
.PHONY: test tests
test tests: | $(GOTESTSUM) $(REPORTDIR)
$(GOTESTSUM) $(TESTFLAGS) ./...
.PHONY: version
version:
@echo $(VERSION)
$(REPORTDIR):
@mkdir -p $@
.PHONY: help
help:
@printf "Available targets:\
\n all lint, build, and test code\
\n build builds gotagger exectuable\
\n changelog run stentor to show changelog entry\
\n clean removes generated files\
\n distclean reset's workspace to original state\
\n format format source code\
\n lint run GOLANGCI_LINTs on source code\
\n report generate test and coverage reports\
\n test run tests\
"