-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
83 lines (66 loc) · 2.27 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
BINARY = allowed-signatures
VET_REPORT = vet.report
TEST_REPORT = tests.xml
GITHUB_TOKEN?= "TBD"
SOURCE ?= $(shell pwd)
VERSION?="0.0.1"
COMMIT=$(shell git rev-parse HEAD)
GO=go
GOLINT=golangci-lint
GORELEASER=goreleaser
ifeq ($(DOCKER), true)
GO=docker run --rm --volume $(shell pwd):/app --workdir /app golang:latest go
GOLINT=docker run --rm --volume $(shell pwd):/app --workdir /app golangci/golangci-lint:latest golangci-lint
GORELEASER=docker run --rm --privileged \
--volume $(shell pwd):/go/src/github.com/frankywahl/allowed-signers \
--volume /var/run/docker.sock:/var/run/docker.sock \
--workdir /go/src/github.com/frankywahl/allowed-signers \
--env GITHUB_TOKEN=${GITHUB_TOKEN} \
--env SOURCE=${SOURCE} \
goreleaser/goreleaser
endif
.PHONY: default
default: help
%-docker: ## Run a make command using docker
@DOCKER=true $(MAKE) $*
.PHONY: build
build: ## Build will create a binary for this system. Similar to `go build`, but uses goreleaser.
$(GORELEASER) build --snapshot --clean --single-target
.PHONY: clean
clean: ## Clean all dependencies
-rm -f ${TEST_REPORT}
-rm -f ${VET_REPORT}
.PHONY: coverage
coverage: ## Run coverage analysis with go cover
$(GO) test -race -v -count=1 -coverprofile=cover.out ./...
$(GO) tool cover -html=cover.out
.PHONY: fmt
fmt: ## Run fmt on go files
$(GO) fmt $$($(GO) list ./... | grep -v /vendor/) ;
.PHONY: gorelease
gorelease: ## Create a fake release. Use Github Actions for a real release
$(GORELEASER) release --clean --snapshot
.PHONY: help
help: ## Show this help
@echo "Usage: make <target>"
@echo
@echo "Targets:"
@grep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?\#\# "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
.PHONY: install
install: ## Install the binary on the machine
$(GO) build ${LDFLAGS} -o ${GOPATH}/bin/${BINARY} *.go
.PHONY: lint
lint: ## Lint the files
$(GOLINT) run --config .github/golangci.yml --verbose
.PHONY: test
test: ## Run the test suite
$(GO) test -v --race -count=1 ./... 2>&1 | tee ${TEST_REPORT} ;
.PHONY: vendor
vendor: ## Vendor dependencies locally
$(GO) mod vendor
.PHONY: vet
vet: ## Run vet on go files
$(GO) vet ./... > ${VET_REPORT} 2>&1 ;
.PHONY: vulncheck
vulncheck: ## Run vulnerability scanner check
$(GO) run golang.org/x/vuln/cmd/govulncheck ./...