This repository has been archived by the owner on Feb 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Makefile
174 lines (142 loc) · 6.69 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
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
# --------------------------------------------------------------------
# Copyright (c) 2019, WSO2 Inc. (http://wso2.com) All Rights Reserved.
#
# 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.
# -----------------------------------------------------------------------
PROJECT_ROOT := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
PROJECT_PKG := cellery.io/cellery
GO_BUILD_DIRECTORY := $(PROJECT_ROOT)/components/build
GOFILES = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
GIT_REVISION := $(shell git rev-parse --verify HEAD)
BALLERINA_VERSION ?= 1.0.3
DISTRIBUTION_VERSION ?= master
DISTRIBUTION_ARCHIVE_VERSION ?= master
DISTRIBUTION_ARTIFACTS := https://github.com/wso2/cellery-distribution/archive/$(DISTRIBUTION_ARCHIVE_VERSION).zip
OBSERVABILITY_BUILD ?= lastSuccessfulBuild
OBSERVABILITY_LAST_BUILD := https://wso2.org/jenkins/job/cellery/job/cellery-observability/$(OBSERVABILITY_BUILD)
OBSERVABILITY_ARTIFACTS_PATH := $(OBSERVABILITY_LAST_BUILD)/artifact/components/global/*zip*
OBSERVABILITY_ARTIFACTS := global.zip
OBSERVABILITY_SIDDHI_ARTIFACTS_PATH := $(OBSERVABILITY_LAST_BUILD)/artifact/components/global/core/io.cellery.observability.siddhi.apps/target/
OBSERVABILITY_PORTAL_ARTIFACTS_PATH := $(OBSERVABILITY_LAST_BUILD)/artifact/components/global/portal/io.cellery.observability.ui/target
OBSERVABILITY_SIDDHI_ARTIFACT := global/core/io.cellery.observability.siddhi.apps/target/io.cellery.observability.siddhi.apps-*.zip
OBSERVABILITY_PORTAL_ARTIFACT := global/portal/io.cellery.observability.ui/target/io.cellery.observability.ui-*.zip
DISTRIBUTION_LAST_BUILD := https://wso2.org/jenkins/job/cellery/job/cellery-distribution/lastSuccessfulBuild
DISTRIBUTION_ARTIFACTS_PATH := $(DISTRIBUTION_LAST_BUILD)/artifact
DISTRIBUTION_K8S_ARTIFACT := k8s-artefacts.tar.gz
TELEPRESENCE_VERSION := telepresence-0.101
TELEPRESENCE_URL := https://s3.amazonaws.com/datawire-static-files/telepresence/$(TELEPRESENCE_VERSION).tar.gz
MAIN_PACKAGES := cli
VERSION ?= 0.6.0-SNAPSHOT
INSTALLER_VERSION ?= $(GIT_REVISION)
# Go build time flags
GO_LDFLAGS := -X $(PROJECT_PKG)/components/cli/pkg/version.buildVersion=$(VERSION)
GO_LDFLAGS += -X $(PROJECT_PKG)/components/cli/pkg/version.buildGitRevision=$(GIT_REVISION)
GO_LDFLAGS += -X $(PROJECT_PKG)/components/cli/pkg/version.buildTime=$(shell date +%Y-%m-%dT%H:%M:%S%z)
# Docker info
DOCKER_REPO ?= wso2cellery
DOCKER_IMAGE_TAG ?= $(VERSION)
all: code.format build-lang build-docs-view build-designer build-cli test-cli
.PHONY: install
install: install-lang install-cli install-docs-view
.PHONY: test-cli
test-cli:
go test -race -covermode=atomic -coverprofile=$(PROJECT_ROOT)/coverage.txt ./components/cli/pkg/commands/...
.PHONY: build-lang
build-lang:
cd ${PROJECT_ROOT}/components; \
mvn clean install;
.PHONY: build-cli
build-cli:
go build -o ${GO_BUILD_DIRECTORY}/cellery -ldflags "$(GO_LDFLAGS)" -x ./components/cli/cmd/cellery
.PHONY: build-docs-view
build-docs-view:
cd ${PROJECT_ROOT}/components/docs-view; \
npm ci; \
npm run build
.PHONY: build-designer
build-designer:
cd ${PROJECT_ROOT}/components/designer; \
npm ci; \
npm run build
.PHONY: install-lang
install-lang:
cd ${PROJECT_ROOT}/components; \
mvn clean install -Dmaven.test.skip=true;
.PHONY: install-cli
install-cli: code.format
go build -o ${GO_BUILD_DIRECTORY}/cellery -ldflags "$(GO_LDFLAGS)" -x ./components/cli/cmd/cellery; \
sudo cp ${GO_BUILD_DIRECTORY}/cellery /usr/local/bin; \
.PHONY: copy-k8s-artefacts
copy-k8s-artefacts:
cd ${PROJECT_ROOT}/installers; \
mkdir -p build-artifacts && cd build-artifacts;\
curl -LO --retry 5 $(DISTRIBUTION_ARTIFACTS); \
unzip $(DISTRIBUTION_ARCHIVE_VERSION).zip && mv cellery-distribution-$(DISTRIBUTION_VERSION)/installer/k8s-artefacts .; \
curl --retry 5 $(OBSERVABILITY_ARTIFACTS_PATH)/$(OBSERVABILITY_ARTIFACTS) --output $(OBSERVABILITY_ARTIFACTS); \
unzip $(OBSERVABILITY_ARTIFACTS); \
unzip $(OBSERVABILITY_SIDDHI_ARTIFACT) -d k8s-artefacts/observability/siddhi; \
mkdir -p k8s-artefacts/observability/node-server/config; \
unzip $(OBSERVABILITY_PORTAL_ARTIFACT) && cp config/* k8s-artefacts/observability/node-server/config/
.PHONY: copy-telepresence-artefacts
copy-telepresence-artefacts:
cd ${PROJECT_ROOT}/installers; \
mkdir -p build-artifacts && cd build-artifacts;\
curl -LO --retry 5 $(TELEPRESENCE_URL); \
tar -xvf $(TELEPRESENCE_VERSION).tar.gz
.PHONY: build-ubuntu-installer
build-ubuntu-installer: cleanup-installers copy-k8s-artefacts copy-telepresence-artefacts
cd ${PROJECT_ROOT}/installers/ubuntu-x64; \
mkdir -p files; \
mv ../build-artifacts/k8s-artefacts files/; \
mv ../build-artifacts/$(TELEPRESENCE_VERSION) files/; \
bash build-ubuntu-x64.sh $(INSTALLER_VERSION) $(VERSION) $(BALLERINA_VERSION)
.PHONY: build-mac-installer
build-mac-installer: cleanup-installers copy-k8s-artefacts copy-telepresence-artefacts
cd ${PROJECT_ROOT}/installers/macOS-x64; \
mkdir -p files; \
mv ../build-artifacts/k8s-artefacts files/; \
mv ../build-artifacts/$(TELEPRESENCE_VERSION) files/; \
bash build-macos-x64.sh $(INSTALLER_VERSION) $(VERSION) $(BALLERINA_VERSION); \
cd target/darwinpkg/Library/Cellery && zip -r cellery-$(VERSION).zip .
.PHONY: cleanup-installers
cleanup-installers:
rm -rf ${PROJECT_ROOT}/installers/build-artifacts; \
rm -rf ${PROJECT_ROOT}/installers/macOS-x64/files; \
rm -rf ${PROJECT_ROOT}/installers/macOS-x64/target; \
rm -rf ${PROJECT_ROOT}/installers/ubuntu-x64/files; \
rm -rf ${PROJECT_ROOT}/installers/ubuntu-x64/target
.PHONY: docker
docker:
cd ${PROJECT_ROOT}/installers/docker; \
bash init.sh; \
docker build -t $(DOCKER_REPO)/ballerina-runtime:$(DOCKER_IMAGE_TAG) .
.PHONY: docker-push
docker-push: docker
docker push $(DOCKER_REPO)/ballerina-runtime:$(DOCKER_IMAGE_TAG)
.PHONY: install-docs-view
install-docs-view:
cd ${PROJECT_ROOT}/components/docs-view; \
bash install-dev.sh
.PHONY: code.format
code.format: tools.goimports
@goimports -local $(PROJECT_PKG) -w -l $(GOFILES)
cd ${PROJECT_ROOT}/components/docs-view; \
npm ci; \
npm run lint
.PHONY: tools tools.goimports
tools: tools.goimports
tools.goimports:
@command -v goimports >/dev/null; if [ $$? -ne 0 ]; then \
echo "goimports not found. Running 'go get golang.org/x/tools/cmd/goimports'"; \
go get golang.org/x/tools/cmd/goimports; \
fi;