forked from openshift/osdctl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (64 loc) · 2.51 KB
/
Makefile
File metadata and controls
84 lines (64 loc) · 2.51 KB
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
BUILDFLAGS ?=
unexport GOFLAGS
# Add OSDCTL `./bin/` dir to path for goreleaser
# This will look for goreleaser first in the local bin dir
# but otherwise can be installed elsewhere on developers machines
BASE_DIR=$(shell pwd)
export PATH:=$(BASE_DIR)/bin:$(PATH)
SHELL := /bin/bash
.DEFAULT_GOAL := all
.PHONY: help
help:
@echo "================================================"
@echo " osdctl Makefile Help "
@echo "================================================"
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
all: format mod build test lint verify-docs
format: vet mod fmt mockgen ci-build ## Runs vet, mod, fmt, mockgen & ci-build targets
fmt: ## format go code
@echo "gofmt"
@gofmt -w -s .
@git diff --exit-code .
OS := $(shell go env GOOS | sed 's/[a-z]/\U&/')
ARCH := $(shell go env GOARCH)
.PHONY: download-goreleaser
download-goreleaser: ## Download goreleaser binary
GOBIN=${BASE_DIR}/bin/ go install github.com/goreleaser/goreleaser/v2@v2.11.2
# Update documentation as a part of every release
.PHONY: generate-docs
generate-docs: ## Generate docs
@go run utils/docgen/main.go --cmd-path=./cmd --docs-dir=./docs
# Verify documents using PROW as a part of every PR raised for osdctl
.PHONY: verify-docs
verify-docs:
./scripts/verify-docs.sh
# CI build containers don't include goreleaser by default,
# so they need to get it first, and then run the build
.PHONY: ci-build
ci-build: download-goreleaser build ## Build for CI environment
SINGLE_TARGET ?= false
# Need to use --snapshot here because goreleaser
# requires more git info than what is provided in Prow's clone.
# Snapshot allows the build without validation of the
# repository itself
build: ## Compile osdctl
goreleaser build --clean --snapshot --single-target=${SINGLE_TARGET}
release: ## Create a release
goreleaser release --clean
install: ## Install osdctl to GOPATH/bin
goreleaser build --single-target -o "$(shell go env GOPATH)/bin/osdctl" --snapshot --clean
vet: ## Run go vet
go vet ${BUILDFLAGS} ./...
mod: ## Tidy go modules
go mod tidy
@git diff --exit-code -- go.mod
mockgen: ensure-mockgen ## Generate mocks
go generate ${BUILDFLAGS} ./...
@git diff --exit-code -- ./pkg/provider/aws/mock
ensure-mockgen: ## Install mockgen dependency
GOBIN=${BASE_DIR}/bin/ go install go.uber.org/mock/mockgen@v0.5.0
test: ## Run tests
go test ${BUILDFLAGS} ./... -covermode=atomic -coverpkg=./...
lint: ## Run linter
golangci-lint run