forked from Checkmarx/kics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
99 lines (83 loc) · 2.53 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
########################
# GNU Makefile #
# Golang SDK required #
########################
.DEFAULT_GOAL := help
GOLINT := golangci-lint
COMMIT := $(shell git rev-parse HEAD)
VERSION := snapshot-$(shell echo ${COMMIT} | cut -c1-8)
IMAGE_TAG := dev
.PHONY: clean
clean: ## remove files created during build
$(call print-target)
rm -rf dist
rm -rf bin
rm -rf vendor
rm -f coverage.*
.PHONY: mod-tidy
mod-tidy: ## go mod tidy - download and cleanup modules
$(call print-target)
go mod tidy
cd tools && go mod tidy
.PHONY: vendor
vendor: ## go mod vendor - download vendor modules
$(call print-target)
go mod vendor
.PHONY: install
install: ## go install tools
$(call print-target)
cd tools && go install $(shell cd tools && go list -f '{{ join .Imports " " }}' -tags=tools)
.PHONY: lint
lint: ## Lint the files
lint: mod-tidy
$(call print-target)
$(GOLINT) run -c .golangci.yml
.PHONY: build
build: ## go build
build: lint generate
$(call print-target)
go build -o bin/ -ldflags "-X github.com/Checkmarx/kics/internal/constants.Version=${VERSION} -X github.com/Checkmarx/kics/internal/constants.SCMCommit=${COMMIT}" ./...
@mv bin/console bin/kics
.PHONY: go-clean
go-clean: ## Go clean build, test and modules caches
$(call print-target)
go clean -r -i -cache -testcache -modcache
.PHONY: generate
generate: mod-tidy ## go generate
$(call print-target)
go generate ./...
.PHONY: test
test-short: # Run sanity unit tests
test-short: generate
$(call print-target)
go test -short ./...
.PHONY: test
test: ## Run tests with race detector and code covarage
test: generate
$(call print-target)
go test -race -covermode=atomic -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
.PHONY: cover
cover: ## generate coverage report
cover: test
$(call print-target)
go tool cover -html=coverage.out -o coverage.html
.PHONY: docker
docker: ## build docker image
$(call print-target)
docker build --build-arg VERSION=${VERSION} --build-arg COMMIT=${COMMIT} -t "kics:${IMAGE_TAG}" .
.PHONY: docker-compose
dkr-compose: ## build docker image and runs docker-compose up
$(call print-target)
VERSION=${VERSION} COMMIT=${COMMIT} IMAGE_TAG=${IMAGE_TAG} docker-compose up --build
.PHONY: release
release: ## goreleaser --rm-dist
release: install
$(call print-target)
goreleaser --rm-dist
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
define print-target
@printf "Executing target: \033[36m$@\033[0m\n"
endef