forked from openshift/rosa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
147 lines (122 loc) · 4.57 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#
# Copyright (c) 2020 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include .bingo/Variables.mk
.DEFAULT_GOAL := rosa
# Ensure go modules are enabled:
export GO111MODULE=on
export GOPROXY=https://proxy.golang.org
# Disable CGO so that we always generate static binaries:
export CGO_ENABLED=0
# Unset GOFLAG for CI and ensure we've got nothing accidently set
unexport GOFLAGS
.PHONY: rosa
rosa:
go build -ldflags="-X github.com/openshift/rosa/pkg/info.Build=$(shell git rev-parse --short HEAD)" ./cmd/rosa
.PHONY: test
test:
go test $(shell go list ./... | grep -v /tests/)
.PHONY: coverage
coverage:
go test -coverprofile=cover.out -covermode=atomic -p 4 $(shell go list ./... | grep -v /tests/)
.PHONY: install
install:
go install ./cmd/rosa
.PHONY: fmt
fmt: fmt-imports
gofmt -s -l -w cmd pkg tests
.PHONY: fmt-imports
fmt-imports: $(GCI)
find . -name '*.go' -not -path './vendor/*' | xargs $(GCI) write -s standard -s default -s "prefix(k8s)" -s "prefix(sigs.k8s)" -s "prefix(github.com)" -s "prefix(gitlab)" -s "prefix(github.com/openshift/rosa)" --custom-order --skip-generated
.PHONY: lint
lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run --timeout 5m0s ./...
.PHONY: commits/check
commits/check:
@./hack/commit-msg-verify.sh
.PHONY: diff
diff:
git diff --exit-code
.PHONY: verify
verify: fmt
go mod tidy
go mod vendor
$(MAKE) diff
.PHONY: clean
clean:
rm -rf \
./cover.out \
rosa \
rosa-darwin-amd64 \
rosa-darwin-arm64 \
rosa-linux-amd64 \
rosa-linux-arm64 \
rosa-windows-amd64.exe \
*.sha256 \
$(NULL)
.PHONY: generate
generate: $(GO_BINDATA) mocks
$(GO_BINDATA) -nometadata -nocompress -pkg assets -o ./assets/bindata.go ./templates/...
go generate ./...
.PHONY: codecov
codecov: coverage
@./hack/codecov.sh
mocks: $(MOCKGEN)
$(MOCKGEN) -source=pkg/aws/api_interface/iam_api_client.go -package=mocks -destination=pkg/aws/mocks/iam_api_client_mock.go
$(MOCKGEN) -source=pkg/aws/api_interface/organizations_api_client.go -package=mocks -destination=pkg/aws/mocks/organizations_api_client_mock.go
$(MOCKGEN) -source=pkg/aws/api_interface/sts_api_client.go -package=mocks -destination=pkg/aws/mocks/sts_api_client_mock.go
$(MOCKGEN) -source=pkg/aws/api_interface/cloudformation_api_client.go -package=mocks -destination=pkg/aws/mocks/cloudformation_api_client_mock.go
$(MOCKGEN) -source=pkg/aws/api_interface/servicequotas_api_client.go -package=mocks -destination=pkg/aws/mocks/servicequotas_api_client_mock.go
$(MOCKGEN) -source=pkg/aws/api_interface/ec2_api_client.go -package=mocks -destination=pkg/aws/mocks/ec2_api_client_mock.go
$(MOCKGEN) -source=pkg/aws/api_interface/s3_api_client.go -package=mocks -destination=pkg/aws/mocks/s3_api_client_mock.go
$(MOCKGEN) -source=pkg/aws/api_interface/secretsmanager_api_client.go -package=mocks -destination=pkg/aws/mocks/secretsmanager_api_client_mock.go
.PHONY: e2e_test
e2e_test: install
ginkgo run \
--label-filter $(LabelFilter)\
--timeout 5h \
-r \
--focus-file tests/e2e/.* \
$(NULL)
# verifies changes to .goreleaser.yaml
.PHONY: check-release-config
check-release-config:
$(GORELEASER) check
# builds a snap shot release in /dist
.PHONY: local-release
local-release:
$(GORELEASER) release --snapshot --clean
# builds and publishes a pre-release of changes from the last release tag
.PHONY: pre-release
prerelease:
$(GORELEASER) release --clean
# builds and publishes a latest release from tag set as env-ver GORELEASER_PREVIOUS_TAG
# leave GORELEASER_PREVIOUS_TAG empty to build from last release tag
.PHONY: release
release:
@if [ -n "$(GORELEASER_PREVIOUS_TAG)" ]; then \
read -p "GORELEASER_PREVIOUS_TAG is set to '$(GORELEASER_PREVIOUS_TAG)'. Is this the correct tag for the last release? (y/N) " confirm; \
if [ "$$confirm" != "y" ]; then \
echo "Aborting release."; \
exit 1; \
fi \
else \
read -p "GORELEASER_PREVIOUS_TAG is not set. Do you want to proceed with building and publishing the release from the last release tag? (y/N) " confirm; \
if [ "$$confirm" != "y" ]; then \
echo "Aborting release."; \
exit 1; \
fi \
fi; \
$(GORELEASER) release --snapshot --clean