forked from openshift/insights-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
131 lines (102 loc) · 3.42 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
# Testing
GO_TEST_FLAGS = $(VERBOSE)
COVER_PROFILE = cover.out
# Build
CLIENTGO_VERSION := $(shell git rev-parse --short=7 HEAD)
CLIENTGO_COMMIT := "v1.0.0+$(shell git rev-parse HEAD)"
export LDFLAGS="-X k8s.io/client-go/pkg/version.gitCommit=${CLIENTGO_COMMIT} \
-X k8s.io/client-go/pkg/version.gitVersion=${CLIENTGO_VERSION}"
# Configuration
CONFIG ?= config/local.yaml
RUN_FLAGS ?= -v4
# Tools
CONTAINER_RUNTIME := $(shell command -v podman 2> /dev/null || echo docker)
GOLANGCI_LINT := $(GOBIN)/golangci-lint
export GO111MODULE=on
export GOFLAGS=-mod=vendor
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: githooks
githooks: ## Configure the repository to use the git hooks
git config core.hooksPath ./.githooks
## --------------------------------------
## Tests
## --------------------------------------
# Run the tests
.PHONY: test
test: unit ## Run all the tests
# Run the unit tests
.PHONY: unit
unit: ## Run the unit tests
go test ./... $(VERBOSE) -coverprofile $(COVER_PROFILE)
.PHONY: unit-cover
unit-cover:
go test -coverprofile=$(COVER_PROFILE) $(GO_TEST_FLAGS) ./...
go tool cover -func=$(COVER_PROFILE)
.PHONE: unit-verbose
unit-verbose:
VERBOSE=-v make unit
## --------------------------------------
## Linting
## --------------------------------------
.PHONY: precommit
precommit: ## Executes the pre-commit hook (check the stashed changes)
./.githooks/pre-commit
.PHONY: lint
lint: $(GOLANGCI_LINT) ## Executes the linting tool (vet, sec, and others)
$(GOLANGCI_LINT) run
$(GOLANGCI_LINT):
./.openshiftci/install-golangci-lint.sh
## --------------------------------------
## Build/Run
## --------------------------------------
.PHONY: run
run: ## Executes the insights operator
go run ./cmd/insights-operator/main.go start \
--config=$(CONFIG) \
$(RUN_FLAGS)
.PHONY: build
build: ## Compiles the insights operator
go build -o ./bin/insights-operator ./cmd/insights-operator
.PHONY: build-debug
build-debug: ## Compiles the insights operator in debug mode
go build $(GO_BUILD_FLAGS) -gcflags="all=-N -l" \
-o ./bin/insights-operator ./cmd/insights-operator
## --------------------------------------
## Container
## --------------------------------------
.PHONY build-debug-container:
build-debug-container: ## Compiles the insights operator and its container image for debug
$(CONTAINER_RUNTIME) build -t insights-operator -f ./Dockerfile.debug ../.
## --------------------------------------
## Tools
## --------------------------------------
.PHONY: docs
docs: ## Generate the documentation
go run ./cmd/gendoc/main.go --out=./docs/gathered-data.md
.PHONY: changelog
changelog: check-github-token ## Updates the changelog entries
go run ./cmd/changelog/main.go $(CHANGELOG_FROM) $(CHANGELOG_UNTIL)
## --------------------------------------
## Go Module
## --------------------------------------
.PHONY: vendor
vendor: ## Runs tiny, vendor and verify the module
go mod tidy
go mod vendor
go mod verify
## --------------------------------------
## Checks (mostly "private" targets)
## --------------------------------------
.PHONY: check-github-token
check-github-token:
ifndef GITHUB_TOKEN
$(error GITHUB_TOKEN is undefined)
endif