forked from greenplum-db/gpupgrade-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
218 lines (179 loc) · 6.95 KB
/
Makefile
File metadata and controls
218 lines (179 loc) · 6.95 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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# Copyright (c) 2017-2021 VMware, Inc. or its affiliates
# SPDX-License-Identifier: Apache-2.0
all: build
.DEFAULT_GOAL := all
MODULE_NAME=gpupgrade
LINUX_ENV := env GOOS=linux GOARCH=amd64
MAC_ENV := env GOOS=darwin GOARCH=amd64
# depend-dev will install the necessary Go dependencies for running `go
# generate`. (This recipe does not have to be run in order to build the
# project; only to rebuild generated files.) Note that developers must still
# install the protoc compiler themselves; there is no way to version it from
# within the Go module system.
#
# Though it's a little counter-intuitive, run this recipe AFTER running make for
# the first time, so that Go will have already fetched the packages that are
# pinned in tools.go.
.PHONY: depend-dev
depend-dev: export GOBIN := $(CURDIR)/dev-bin
depend-dev: export GOFLAGS := -mod=readonly # do not update dependencies during installation
depend-dev:
mkdir -p $(GOBIN)
go install github.com/golang/protobuf/protoc-gen-go
go install github.com/golang/mock/mockgen
# NOTE: goimports subsumes the standard formatting rules of gofmt, but gofmt is
# more flexible(custom rules) so we leave it in for this reason.
format:
goimports -l -w agent/ cli/ db/ hub/ integrations/ testutils/ utils/
gofmt -l -w agent/ cli/ db/ hub/ integrations/ testutils/ utils/
.PHONY: check check-go check-bats unit integration test
# check runs all tests against the locally built gpupgrade binaries. Use -k to
# continue after failures.
check: check-go check-bats
check-go check-bats: export PATH := $(CURDIR):$(PATH)
TEST_PACKAGES := ./...
# FIXME go test currently caches integration tests incorrectly, because we do
# not register any dependency on the gpupgrade binary that we rely on for
# testing. For now, disable test caching for the Make recipes with -count=1;
# anyone who would like caching back can always use `go test` directly.
check-go:
go test -count=1 $(TEST_PACKAGES)
check-bats:
bats -r ./test
unit: TEST_PACKAGES := $(shell go list ./... | grep -v integrations$$ )
unit: check-go
integration: TEST_PACKAGES := ./integrations
integration: check-go
test: unit integration
.PHONY: coverage
coverage:
@./scripts/show_coverage.sh
sshd_build:
make -C integrations/sshd
BUILD_ENV = $($(OS)_ENV)
.PHONY: build build_linux build_mac
build:
# For tagging a release see the "Upgrade Release Checklist" document.
$(eval VERSION := $(shell git describe --tags --abbrev=0))
$(eval COMMIT := $(shell git rev-parse --short --verify HEAD))
$(eval RELEASE=Dev Build)
$(eval VERSION_LD_STR := -X 'github.com/greenplum-db/$(MODULE_NAME)/cli/commands.Version=$(VERSION)')
$(eval VERSION_LD_STR += -X 'github.com/greenplum-db/$(MODULE_NAME)/cli/commands.Commit=$(COMMIT)')
$(eval VERSION_LD_STR += -X 'github.com/greenplum-db/$(MODULE_NAME)/cli/commands.Release=$(RELEASE)')
$(eval BUILD_FLAGS = -gcflags="all=-N -l")
$(eval override BUILD_FLAGS += -ldflags "$(VERSION_LD_STR)")
$(BUILD_ENV) go build -o gpupgrade $(BUILD_FLAGS) github.com/greenplum-db/gpupgrade/cmd/gpupgrade
go generate ./cli/bash
build_linux: OS := LINUX
build_mac: OS := MAC
build_linux build_mac: build
BUILD_FLAGS = -gcflags="all=-N -l"
override BUILD_FLAGS += -ldflags "$(VERSION_LD_STR)"
enterprise-tarball: RELEASE=Enterprise
enterprise-tarball: build tarball
oss-tarball: RELEASE=Open Source
oss-tarball: build tarball
TARBALL_NAME=gpupgrade.tar.gz
tarball:
[ ! -d tarball ] && mkdir tarball
# gather files
cp gpupgrade tarball
cp cli/bash/gpupgrade.bash tarball
cp gpupgrade_config tarball
cp open_source_licenses.txt tarball
cp -r data-migration-scripts/ tarball/data-migration-scripts/
# remove test files
rm -r tarball/data-migration-scripts/test
# create tarball
( cd tarball; tar czf ../$(TARBALL_NAME) . )
sha256sum $(TARBALL_NAME) > CHECKSUM
rm -r tarball
enterprise-rpm: RELEASE=Enterprise
enterprise-rpm: NAME=VMware Tanzu Greenplum Upgrade
enterprise-rpm: LICENSE=VMware Software EULA
enterprise-rpm: enterprise-tarball rpm
oss-rpm: RELEASE=Open Source
oss-rpm: NAME=Greenplum Database Upgrade
oss-rpm: LICENSE=Apache 2.0
oss-rpm: oss-tarball rpm
rpm:
[ ! -d rpm ] && mkdir rpm
mkdir -p rpm/rpmbuild/{BUILD,RPMS,SOURCES,SPECS}
cp $(TARBALL_NAME) rpm/rpmbuild/SOURCES
cp gpupgrade.spec rpm/rpmbuild/SPECS/
rpmbuild \
--define "_topdir $${PWD}/rpm/rpmbuild" \
--define "gpupgrade_version $(VERSION)" \
--define "gpupgrade_rpm_release 1" \
--define "release_type $(RELEASE)" \
--define "license $(LICENSE)" \
--define "summary $(NAME)" \
-bb $${PWD}/rpm/rpmbuild/SPECS/gpupgrade.spec
cp rpm/rpmbuild/RPMS/x86_64/gpupgrade-$(VERSION)*.rpm .
rm -r rpm
install:
go install $(BUILD_FLAGS) github.com/greenplum-db/gpupgrade/cmd/gpupgrade
# To lint, you must install golangci-lint via one of the supported methods
# listed at
#
# https://github.com/golangci/golangci-lint#install
#
# DO NOT add the linter to the project dependencies in Gopkg.toml, as much as
# you may want to streamline this installation process, because
# 1. `go get` is an explicitly unsupported installation method for this utility,
# much like it is for gpupgrade itself, and
# 2. adding it as a project dependency opens up the possibility of accidentally
# vendoring GPL'd code.
.PHONY: lint
lint:
golangci-lint run
clean:
# Build artifacts
rm -f gpupgrade
# Test artifacts
rm -rf /tmp/go-build*
rm -rf /tmp/gexec_artifacts*
# Code coverage files
rm -rf /tmp/cover*
rm -rf /tmp/unit*
# Package artifacts
rm -rf tarball
rm -f $(TARBALL_NAME)
rm -f CHECKSUM
rm -rf rpm
rm -f gpupgrade-$(VERSION)*.rpm
# You can override these from the command line.
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
GIT_URI := $(shell git ls-remote --get-url)
ifeq ($(GIT_URI),https://github.com/greenplum-db/gpupgrade)
ifeq ($(BRANCH),master)
PIPELINE_NAME := gpupgrade
FLY_TARGET := prod
endif
endif
# Concourse does not allow "/" in pipeline names
PIPELINE_NAME ?= gpupgrade:$(shell git rev-parse --abbrev-ref HEAD | tr '/' ':')
FLY_TARGET ?= cm
ifeq ($(FLY_TARGET),prod)
TARGET := prod
else
TARGET := dev
endif
.PHONY: set-pipeline expose-pipeline
# TODO: Keep this in sync with the README at github.com/greenplum-db/continuous-integration
set-pipeline:
# Keep pipeline.yml up to date
go generate ./ci
#NOTE-- make sure your gpupgrade-git-remote uses an https style git"
#NOTE-- such as https://github.com/greenplum-db/gpupgrade.git"
fly -t $(FLY_TARGET) set-pipeline -p $(PIPELINE_NAME) \
-c ci/generated/pipeline.yml \
-l ~/workspace/gp-continuous-integration/secrets/gpupgrade.$(TARGET).yml \
-l ~/workspace/gp-continuous-integration/secrets/gpdb_common-ci-secrets.yml \
-l ~/workspace/gp-continuous-integration/secrets/gpdb_master-ci-secrets.prod.yml \
-l ~/workspace/gp-continuous-integration/secrets/ccp_ci_secrets_$(FLY_TARGET).yml \
-l ~/workspace/gp-continuous-integration/secrets/gp-upgrade-packaging.dev.yml \
-v gpupgrade-git-remote=$(GIT_URI) \
-v gpupgrade-git-branch=$(BRANCH)
expose-pipeline:
fly --target $(FLY_TARGET) expose-pipeline --pipeline $(PIPELINE_NAME)