-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
81 lines (64 loc) · 2.56 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
PREFIX?=$(shell pwd)
NAME := crusoe-csi-driver
PKG := github.com/crusoecloud/crusoe-csi-driver/cmd/$(NAME)
BUILDDIR := ${PREFIX}/dist
# Set any default go build tags
BUILDTAGS :=
GOLANGCI_VERSION = v1.62.0
GO_ACC_VERSION = latest
GOTESTSUM_VERSION = latest
GOCOVER_VERSION = latest
GO_LDFLAGS=-ldflags "-X 'github.com/crusoecloud/crusoe-csi-driver/internal/driver.version=$$CRUSOE_CSI_DRIVER_VERSION' -X 'github.com/crusoecloud/crusoe-csi-driver/internal/driver.name=$$CRUSOE_CSI_DRIVER_NAME'"
.PHONY: run
run:
go run cmd/crusoe-csi-driver/main.go
.PHONY: dev
dev: test build-deps lint ## Runs a build-deps, test, lint
.PHONY: ci
ci: test-ci build-deps lint-ci ## Runs test, build-deps, lint
.PHONY: build-deps
build-deps: ## Install build dependencies
@echo "==> $@"
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_VERSION}
.PHONY: precommit
precommit: ## runs various formatters that will be checked by linter (but can/should be automatic in your editor)
@echo "==> $@"
@go mod tidy
@golangci-lint run --fix ./...
.PHONY: test
test: ## Runs the go tests.
@echo "==> $@"
@go test -tags "$(BUILDTAGS)" -cover -race -v ./...
.PHONY: test-ci
test-ci: ## Runs the go tests with additional options for a CI environment
@echo "==> $@"
@go mod tidy
@git diff --exit-code go.mod go.sum # fail if go.mod is not tidy
@go install github.com/ory/go-acc@${GO_ACC_VERSION}
@go install gotest.tools/gotestsum@${GOTESTSUM_VERSION}
@go install github.com/boumenot/gocover-cobertura@${GOCOVER_VERSION}
@gotestsum --junitfile tests.xml --raw-command -- go-acc -o coverage.out ./... -- -json -tags "$(BUILDTAGS)" -race -v
@go tool cover -func=coverage.out
@gocover-cobertura < coverage.out > coverage.xml
.PHONY: lint
lint: ## Verifies `golangci-lint` passes
@echo "==> $@"
@golangci-lint version
@golangci-lint run ./...
.PHONY: lint-ci
lint-ci: ## Verifies `golangci-lint` passes and outputs in CI-friendly format
@echo "==> $@"
@golangci-lint version
@golangci-lint run ./... --out-format code-climate > golangci-lint.json
.PHONY: build
build: ## Builds the executable and places it in the build dir
@go build -o ${BUILDDIR}/${NAME} ${PKG}
.PHONY: cross
cross: ## Builds the cross compiled executable for use within a container
@GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ${BUILDDIR}/${NAME} ${GO_LDFLAGS} ${PKG}
.PHONY: install
install: ## Builds and installs the executable on PATH
@go install ${PKG}
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'