-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (51 loc) · 1.6 KB
/
Copy pathMakefile
File metadata and controls
67 lines (51 loc) · 1.6 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
GO ?= go
COVERAGE_THRESHOLD ?= 95
GOFMT_TARGETS := cmd internal
MAIN_PKG := ./cmd/git-real
CACHE_DIR ?= $(CURDIR)/.cache
export GOCACHE ?= $(CACHE_DIR)/go-build
export GOMODCACHE ?= $(CACHE_DIR)/gomod
export GOPATH ?= $(CACHE_DIR)/gopath
export XDG_CACHE_HOME ?= $(CACHE_DIR)/xdg
# Reproducible-build inputs. Override on the command line for releases:
# make build VERSION=v1.2.3 COMMIT=$(git rev-parse HEAD) DATE=$(git log -1 --format=%cI)
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null || echo none)
DATE ?= $(shell git log -1 --format=%cI 2>/dev/null || echo unknown)
LDFLAGS := -s -w \
-X main.version=$(VERSION) \
-X main.commit=$(COMMIT) \
-X main.date=$(DATE)
.PHONY: build fmt fmt-check lint typecheck deadcode test test-race coverage vuln actionlint check
build:
$(GO) build -trimpath -buildvcs=true -ldflags='$(LDFLAGS)' -o git-real $(MAIN_PKG)
fmt:
$(GO) fmt ./...
fmt-check:
files="$$(find $(GOFMT_TARGETS) -name '*.go' -print)"; \
if [ -z "$$files" ]; then \
exit 0; \
fi; \
unformatted="$$(gofmt -l $$files)"; \
if [ -n "$$unformatted" ]; then \
printf '%s\n' "$$unformatted"; \
exit 1; \
fi
lint:
$(GO) vet ./...
$(GO) tool staticcheck ./...
typecheck:
$(GO) test -run '^$$' ./...
deadcode:
$(GO) tool deadcode $(MAIN_PKG)
test:
$(GO) test ./...
test-race:
$(GO) test -race -shuffle=on ./...
coverage:
COVERAGE_THRESHOLD=$(COVERAGE_THRESHOLD) bash ./scripts/check-coverage.sh
vuln:
$(GO) tool govulncheck ./...
actionlint:
$(GO) tool actionlint
check: fmt-check lint typecheck deadcode coverage