forked from Checkmarx/kics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring Makefile (Checkmarx#2238)
- Loading branch information
1 parent
8408e7f
commit 9c8af30
Showing
10 changed files
with
1,323 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,92 @@ | ||
######################## | ||
# GNU Makefile # | ||
# Golang SDK required # | ||
######################## | ||
.DEFAULT_GOAL := help | ||
GOLINT := golangci-lint | ||
IMAGE_TAG := $(shell git rev-parse HEAD) | ||
|
||
.PHONY: dep | ||
dep: # Download required dependencies | ||
.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 | ||
go mod download | ||
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: dep # Lint the files | ||
lint: ## Lint the files | ||
lint: mod-tidy | ||
$(call print-target) | ||
$(GOLINT) run -c .golangci.yml | ||
|
||
.PHONY: gen | ||
gen: | ||
go get -u github.com/mailru/easyjson/... | ||
easyjson pkg/model/model.go | ||
.PHONY: build | ||
build: ## go build | ||
build: lint generate | ||
$(call print-target) | ||
go build -o bin/ -ldflags "-X github.com/Checkmarx/kics/internal/constants.Version=${IMAGE_TAG}" ./... | ||
@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: dep # Run unit tests | ||
test-short: # Run sanity unit tests | ||
test-short: generate | ||
$(call print-target) | ||
go test -short ./... | ||
|
||
.PHONY: dockerise | ||
dockerise: | ||
docker build --build-arg GIT_USER=$(GITHUB_USER) --build-arg GIT_TOKEN=$(GITHUB_TOKEN) -t "kics:${IMAGE_TAG}" . | ||
.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 -t "kics:${IMAGE_TAG}" . | ||
|
||
.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}' | ||
|
||
.PHONY: mock | ||
mock: | ||
mockgen -package mock -source pkg/engine/source/source.go > pkg/engine/mock/source.go | ||
define print-target | ||
@printf "Executing target: \033[36m$@\033[0m\n" | ||
endef |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module github.com/Checkmarx/kics/tools | ||
|
||
go 1.16 | ||
|
||
require ( | ||
github.com/golangci/golangci-lint v1.37.1 | ||
github.com/goreleaser/goreleaser v0.159.0 | ||
) |
Oops, something went wrong.