-
Notifications
You must be signed in to change notification settings - Fork 6
/
common.mk
65 lines (50 loc) · 2.32 KB
/
common.mk
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
REPO_ROOT=$(shell git rev-parse --show-toplevel)
LICENSEI_VERSION = 0.7.0
GOLANGCI_VERSION = 1.51.2
ISTIO_VERSION ?= 1.15.6
.PHONY: fmt
fmt: ## Run go fmt against code
go fmt ./...
.PHONY: vet
vet: ## Run go vet against code
go vet ./...
.PHONY: tidy
tidy: ## Execute go mod tidy
go mod tidy
go mod download all
${REPO_ROOT}/bin/golangci-lint-${GOLANGCI_VERSION}:
@mkdir -p ${REPO_ROOT}/bin
@mkdir -p bin
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s v${GOLANGCI_VERSION}
@mv bin/golangci-lint $@
${REPO_ROOT}/bin/golangci-lint: ${REPO_ROOT}/bin/golangci-lint-${GOLANGCI_VERSION}
@ln -sf golangci-lint-${GOLANGCI_VERSION} ${REPO_ROOT}/bin/golangci-lint
.PHONY: lint
lint: ${REPO_ROOT}/bin/golangci-lint ## Run linter
# "unused" linter is a memory hog, but running it separately keeps it contained (probably because of caching)
${REPO_ROOT}/bin/golangci-lint run --disable=unused -c ${REPO_ROOT}/.golangci.yml --timeout 2m
${REPO_ROOT}/bin/golangci-lint run -c ${REPO_ROOT}/.golangci.yml --timeout 2m
.PHONY: lint-fix
lint-fix: ${REPO_ROOT}/bin/golangci-lint ## Run linter
@${REPO_ROOT}/bin/golangci-lint run -c ${REPO_ROOT}/.golangci.yml --fix --timeout 2m
${REPO_ROOT}/bin/licensei: ${REPO_ROOT}/bin/licensei-${LICENSEI_VERSION}
@ln -sf licensei-${LICENSEI_VERSION} ${REPO_ROOT}/bin/licensei
${REPO_ROOT}/bin/licensei-${LICENSEI_VERSION}:
@mkdir -p ${REPO_ROOT}/bin
@mkdir -p bin
curl -sfL https://raw.githubusercontent.com/goph/licensei/master/install.sh | bash -s v${LICENSEI_VERSION}
mv bin/licensei $@
.PHONY: license-check
license-check: ${REPO_ROOT}/bin/licensei ## Run license check
${REPO_ROOT}/bin/licensei --config ${REPO_ROOT}/.licensei.toml check
${REPO_ROOT}/bin/licensei --config ${REPO_ROOT}/.licensei.toml header
.PHONY: license-cache
license-cache: ${REPO_ROOT}/bin/licensei ## Generate license cache
${REPO_ROOT}/bin/licensei --config ${REPO_ROOT}/.licensei.toml cache
${REPO_ROOT}/bin/istioctl: ${REPO_ROOT}/bin/istioctl-${ISTIO_VERSION}
@ln -sf istioctl-${ISTIO_VERSION} ${REPO_ROOT}/bin/istioctl
${REPO_ROOT}/bin/istioctl-${ISTIO_VERSION}:
ISTIO_VERSION=${ISTIO_VERSION} /bin/bash ${REPO_ROOT}/scripts/getIstioCtl.sh
@ln -sf istioctl-${ISTIO_VERSION} ${REPO_ROOT}/bin/istioctl
.PHONY: install-istioctl
install-istioctl: ${REPO_ROOT}/bin/istioctl ## Install IstioCtl