-
Notifications
You must be signed in to change notification settings - Fork 112
/
Makefile
65 lines (48 loc) · 1.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
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
all: format mod build test lint
format: vet mod fmt mockgen ci-build
fmt:
@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:
GOBIN=${BASE_DIR}/bin/ go install github.com/goreleaser/[email protected]
# 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
SINGLE_TARGET ?= false
# Need to use --snapshot here because the goReleaser
# requires more git info that is provided in Prow's clone.
# Snapshot allows the build without validation of the
# repository itself
build:
goreleaser build --clean --snapshot --single-target=${SINGLE_TARGET}
release:
goreleaser release --clean
install:
goreleaser build --single-target -o "$(shell go env GOPATH)/bin/osdctl" --snapshot --clean
vet:
go vet ${BUILDFLAGS} ./...
mod:
go mod tidy
@git diff --exit-code -- go.mod
mockgen: ensure-mockgen
go generate ${BUILDFLAGS} ./...
@git diff --exit-code -- ./pkg/provider/aws/mock
ensure-mockgen:
GOBIN=${BASE_DIR}/bin/ go install go.uber.org/mock/[email protected]
test:
go test ${BUILDFLAGS} ./... -covermode=atomic -coverpkg=./...
lint:
golangci-lint run