-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
81 lines (65 loc) · 1.82 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
PROJECT_NAME := gomock-extra-matcher
PKG := github.com/oxyno-zeta/$(PROJECT_NAME)
# go option
GO ?= go
# Uncomment to enable vendor
GO_VENDOR := # -mod=vendor
# Required for globs to work correctly
SHELL=/usr/bin/env bash
# Version
HAS_GORELEASER := $(shell command -v goreleaser;)
HAS_GIT := $(shell command -v git;)
HAS_GOLANGCI_LINT := $(shell command -v golangci-lint;)
HAS_CURL:=$(shell command -v curl;)
HAS_FIELDALIGNMENT:=$(shell command -v fieldalignment;)
.DEFAULT_GOAL := code/lint
#############
# Build #
#############
.PHONY: code/lint
code/lint: setup/dep/install
golangci-lint run ./...
.PHONY: code/fieldalignment
code/fieldalignment: setup/dep/install
fieldalignment -fix -test=false ./...
#############
# Tests #
#############
.PHONY: test/unit
test/unit: setup/dep/install
$(GO) test $(GO_VENDOR) -v -coverpkg=./... -coverprofile=c.out.tmp ./...
.PHONY: test/coverage
test/coverage:
cat c.out.tmp | grep -v "mock_" > c.out
$(GO) tool cover -html=c.out -o coverage.html
$(GO) tool cover -func c.out
#############
# Setup #
#############
.PHONY: setup/generate
setup/generate:
$(GO) $(GO_VENDOR) generate ./...
.PHONY: setup/dep/install
setup/dep/install:
ifndef HAS_GOLANGCI_LINT
@echo "=> Installing golangci-lint tool"
ifndef HAS_CURL
$(error You must install curl)
endif
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.53.3
endif
ifndef HAS_GIT
$(error You must install Git)
endif
ifndef HAS_FIELDALIGNMENT
@echo "=> Installing fieldalignment tool"
$(GO) install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@v0.23.0
endif
go mod download
go mod tidy
.PHONY: setup/dep/update
setup/dep/update:
$(GO) get -u ./...
.PHONY: setup/dep/vendor
setup/dep/vendor:
$(GO) mod vendor