-
Notifications
You must be signed in to change notification settings - Fork 29
/
Makefile
82 lines (60 loc) · 2.04 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
APP = shp
OUTPUT_DIR ?= _output
CMD = ./cmd/$(APP)/...
PKG = ./pkg/...
BIN ?= $(OUTPUT_DIR)/$(APP)
KUBECTL_BIN ?= $(OUTPUT_DIR)/kubectl-$(APP)
GO_FLAGS ?= -mod=vendor
GO_TEST_FLAGS ?= -race -cover
GO_PATH ?= $(shell go env GOPATH)
GO_CACHE ?= $(shell go env GOCACHE)
ARGS ?=
# container registry deployment namespace
REGISTRY_NAMESPACE ?= registry
# hostname and namespace for the end-to-end tests producing container images
OUTPUT_HOSTNAME ?= registry.registry.svc.cluster.local:32222
OUTPUT_NAMESPACE ?= shipwright-io
.EXPORT_ALL_VARIABLES:
.PHONY: $(BIN)
$(BIN):
go build $(GO_FLAGS) -o $(BIN) $(CMD)
build: $(BIN)
install: build
install -m 0755 $(BIN) /usr/local/bin/
# creates a kubectl prefixed shp binary, "kubectl-shp", and when installed under $PATH, will be
# visible as "kubectl shp".
.PHONY: kubectl
kubectl: BIN = $(KUBECTL_BIN)
kubectl: $(BIN)
kubectl-install: BIN = $(KUBECTL_BIN)
kubectl-install: kubectl install
clean:
rm -rf "$(OUTPUT_DIR)"
run:
go run $(GO_FLAGS) $(CMD) $(ARGS)
# runs all tests, unit and end-to-end.
test: test-unit test-e2e
.PHONY: test-unit
test-unit:
go test $(GO_FLAGS) $(GO_TEST_FLAGS) $(CMD) $(PKG) $(ARGS)
# looks for *.bats files in the test/e2e directory and runs them
test-e2e:
./test/e2e/bats/core/bin/bats --recursive test/e2e/*.bats
# runs act, with optional arguments
.PHONY: act
act:
@act --secret="GITHUB_TOKEN=${GITHUB_TOKEN}" $(ARGS)
# Install golangci-lint via: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
.PHONY: sanity-check
sanity-check:
golangci-lint run
# generates the command-line help messages as markdown files, and in order to have a generic ${HOME}
# rendered, it exports a fake home directory ("~"), and preserves the original GOPATH and GOCACHE to avoid
# creating bogus files on the project directory.
.PHONY: generate-docs
generate-docs:
GOPATH="$(GO_PATH)" GOCACHE="$(GO_CACHE)" HOME="~" go run cmd/help/main.go --output-dir=./docs
# checks if the generated documentation files are out of sync.
.PHONY: verify-docs
verify-docs: generate-docs
./hack/verify-docs.sh