-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
81 lines (67 loc) · 1.92 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
77
78
79
80
81
GO ?= go
BUILD_PATH := build
COVERAGE_PATH := $(BUILD_PATH)/coverage
GOLANGCI_LINT := $(BUILD_PATH)/golangci-lint
GO_MODIFF := $(BUILD_PATH)/go-modiff
GO_MODIFF_STATIC := $(BUILD_PATH)/go-modiff.static
GINKGO := $(BUILD_PATH)/ginkgo
define go-build
cd `pwd` && $(GO) build -ldflags '-s -w $(2)' \
-o $(BUILD_PATH)/$(shell basename $(1)) $(1)
@echo > /dev/null
endef
all: $(GO_MODIFF)
.PHONY: clean
clean:
rm -rf $(BUILD_PATH)
.PHONY: codecov
codecov: SHELL := $(shell which bash)
codecov:
bash <(curl -s https://codecov.io/bash) -f $(COVERAGE_PATH)/coverprofile
.PHONY: docs
docs: $(GO_MODIFF)
$(GO_MODIFF) d --markdown > docs/go-modiff.8.md
$(GO_MODIFF) d --man > docs/go-modiff.8
$(GO_MODIFF) f > completions/go-modiff.fish
.PHONY: $(GO_MODIFF)
$(GO_MODIFF):
$(call go-build,./cmd/go-modiff)
.PHONY: $(GO_MODIFF_STATIC)
$(GO_MODIFF_STATIC):
$(call go-build,./cmd/go-modiff,-linkmode external -extldflags "-static -lm")
$(GOLANGCI_LINT):
export \
VERSION=v1.55.2 \
URL=https://raw.githubusercontent.com/golangci/golangci-lint \
BINDIR=$(BUILD_PATH) && \
curl -sfL $$URL/$$VERSION/install.sh | sh -s $$VERSION
$(GINKGO):
$(call go-build,./vendor/github.com/onsi/ginkgo/v2/ginkgo)
.PHONY: lint
lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) linters
GL_DEBUG=gocritic $(GOLANGCI_LINT) run
.PHONY: test
test: $(GINKGO)
rm -rf $(COVERAGE_PATH) && mkdir -p $(COVERAGE_PATH)
$(BUILD_PATH)/ginkgo run $(TESTFLAGS) \
-r -p \
--cover \
--mod vendor \
--randomize-all \
--randomize-suites \
--covermode atomic \
--output-dir $(COVERAGE_PATH) \
--coverprofile coverprofile \
--junit-report junit.xml \
--slow-spec-threshold 60s \
--trace \
--succinct
$(GO) tool cover -html=$(COVERAGE_PATH)/coverprofile -o $(COVERAGE_PATH)/coverage.html
$(GO) tool cover -func=$(COVERAGE_PATH)/coverprofile
.PHONY: vendor
vendor:
export GO111MODULE=on GOSUMDB= && \
$(GO) mod tidy && \
$(GO) mod vendor && \
$(GO) mod verify