forked from RedHatInsights/insights-content-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
127 lines (92 loc) · 3.37 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
SHELL := /bin/bash
.PHONY: default clean build fmt lint vet cyclo ineffassign shellcheck errcheck goconst gosec abcgo json-check style run test cover license openapi-check before_commit help godoc install_docgo install_addlicense
SOURCES:=$(shell find . -name '*.go')
BINARY:=insights-content-service
DOCFILES:=$(addprefix docs/packages/, $(addsuffix .html, $(basename ${SOURCES})))
default: build
clean: ## Run go clean
@go clean
rm -f rest-api-tests
build: ${BINARY} ## Build binary containing service executable
build-cover: ${SOURCES} ## Build binary with code coverage detection support
./build.sh -cover
${BINARY}: ${SOURCES}
./build.sh
checker/checker: checker/main.go
cd checker
go build
cd ..
fmt: ## Run go fmt -w for all sources
@echo "Running go formatting"
./gofmt.sh
lint: ## Run golint
@echo "Running go lint"
./golint.sh
vet: ## Run go vet. Report likely mistakes in source code
@echo "Running go vet"
./govet.sh
cyclo: ## Run gocyclo
@echo "Running gocyclo"
./gocyclo.sh
ineffassign: ## Run ineffassign checker
@echo "Running ineffassign checker"
./ineffassign.sh
shellcheck: ## Run shellcheck
shellcheck --exclude=SC1090,SC2086,SC2034,SC1091 $(shell find . -name "*.sh")
errcheck: ## Run errcheck
@echo "Running errcheck"
./goerrcheck.sh
goconst: ## Run goconst checker
@echo "Running goconst checker"
./goconst.sh
gosec: ## Run gosec checker
@echo "Running gosec checker"
./gosec.sh
abcgo: ## Run ABC metrics checker
@echo "Run ABC metrics checker"
./abcgo.sh
json-check: ## Check all JSONs for basic syntax
@echo "Run JSON checker"
python3 utils/json_check.py
openapi-check:
./check_openapi.sh
style: fmt vet lint cyclo shellcheck errcheck goconst gosec ineffassign abcgo ## Run all the formatting related commands (fmt, vet, lint, cyclo) + check shell scripts
run: clean build ## Build the project and executes the binary
./insights-content-service
test: clean build ## Run the unit tests
@go test -coverprofile coverage.out $(shell go list ./... | grep -v tests)
cover: test ## Generate HTML pages with code coverage
@go tool cover -html=coverage.out
coverage: ## Display code coverage on terminal
@go tool cover -func=coverage.out
integration_tests: ## Run all integration tests
@echo "Running all integration tests"
@./test.sh
license: install_addlicense
addlicense -c "Red Hat, Inc" -l "apache" -v ./
before_commit: style test openapi-check license
./check_coverage.sh
help: ## Show this help screen
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
@echo ''
@echo 'Available targets are:'
@echo ''
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
@echo ''
function_list: ${BINARY} ## List all functions in generated binary file
go tool objdump ${BINARY} | grep ^TEXT | sed "s/^TEXT\s//g"
docs/packages/%.html: %.go
mkdir -p $(dir $@)
docgo -outdir $(dir $@) $^
addlicense -c "Red Hat, Inc" -l "apache" -v $@
godoc: export GO111MODULE=off
godoc: install_docgo install_addlicense ${DOCFILES} docs/sources.md
docs/sources.md: docs/sources.tmpl.md ${DOCFILES}
./gen_sources_md.sh
install_docgo: export GO111MODULE=off
install_docgo:
[[ `command -v docgo` ]] || GO111MODULE=off go get -u github.com/dhconnelly/docgo
install_docgo: export GO111MODULE=off
install_addlicense:
[[ `command -v addlicense` ]] || GO111MODULE=off go get -u github.com/google/addlicense