-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
177 lines (138 loc) · 5.38 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
175
176
177
.EXPORT_ALL_VARIABLES:
REPO ?= op-worker
# distro for package building (oneof: xenial, bionic, centos-7-x86_64)
DISTRIBUTION ?= none
export DISTRIBUTION
RELEASE ?= 1802
PKG_REVISION ?= $(shell git describe --tags --always)
PKG_VERSION ?= $(shell git describe --tags --always | tr - .)
PKG_ID = op-worker-$(PKG_VERSION)
PKG_BUILD = 1
BASE_DIR = $(shell pwd)
ERLANG_BIN = $(shell dirname $(shell which erl))
REBAR ?= $(BASE_DIR)/rebar3
BUILD_DIR = _build
LIB_DIR = $(BUILD_DIR)/default/lib
REL_DIR = $(BUILD_DIR)/default/rel
PKG_VARS_CONFIG = pkg.vars.config
OVERLAY_VARS ?= --overlay_vars=rel/vars.config
TEMPLATE_SCRIPT := ./rel/overlay.escript
GIT_URL := $(shell git config --get remote.origin.url | sed -e 's/\(\/[^/]*\)$$//g')
GIT_URL := $(shell if [ "${GIT_URL}" = "file:/" ]; then echo 'ssh://git@git.onedata.org:7999/vfs'; else echo ${GIT_URL}; fi)
ONEDATA_GIT_URL := $(shell if [ "${ONEDATA_GIT_URL}" = "" ]; then echo ${GIT_URL}; else echo ${ONEDATA_GIT_URL}; fi)
export ONEDATA_GIT_URL
BUILD_VERSION := $(subst $(shell git describe --tags --abbrev=0)-,,$(shell git describe --tags --long))
.PHONY: deps package test
all: test_rel
##
## Rebar targets
##
get-deps:
$(REBAR) get-deps
upgrade:
$(REBAR) upgrade --all
compile:
$(REBAR) compile
inject-gui:
$(LIB_DIR)/gui/pull-gui.sh gui-image.conf
submodules-in-deps: get-deps
make -C _build/default/lib/helpers submodules
## Generates a production release
generate: submodules-in-deps template inject-gui
$(REBAR) release $(OVERLAY_VARS)
clean: relclean pkgclean
$(REBAR) clean
clean_all: clean distclean
rm -rf $(BUILD_DIR)
rm -rf test_distributed/logs/*
rm -rf priv/*
rm -rf rebar.lock
distclean:
$(REBAR) clean --all
.PHONY: template
template:
sed "s/{build_version, \".*\"}/{build_version, \"${BUILD_VERSION}\"}/" ./rel/vars.config.template > ./rel/vars.config
$(TEMPLATE_SCRIPT) rel/vars.config ./rel/files/vm.args.template
$(TEMPLATE_SCRIPT) rel/vars.config ./rel/files/autogenerated.vm.args.template
##
## Submodules
##
submodules:
git submodule sync --recursive ${submodule}
git submodule update --init --recursive ${submodule}
##
## Release targets
##
rel: generate
test_rel: generate cm_rel
cm_rel:
make -C $(LIB_DIR)/cluster_manager/ submodules
mkdir -p cluster_manager/bamboos/gen_dev
cp -rf $(LIB_DIR)/cluster_manager/bamboos/gen_dev cluster_manager/bamboos
printf "\n{base_dir, \"$(BASE_DIR)/cluster_manager/_build\"}." >> $(LIB_DIR)/cluster_manager/rebar.config
make -C $(LIB_DIR)/cluster_manager/ rel
sed -i "s@{base_dir, \"$(PWD)/cluster_manager/_build\"}\.@@" $(LIB_DIR)/cluster_manager/rebar.config
relclean:
rm -rf $(REL_DIR)/test_cluster
rm -rf $(REL_DIR)/op_worker
rm -rf cluster_manager/$(REL_DIR)/cluster_manager
##
## Testing targets
##
eunit:
$(REBAR) do eunit skip_deps=true --suite=${SUITES}
## Rename all tests in order to remove duplicated names (add _(++i) suffix to each test)
@for tout in `find test -name "TEST-*.xml"`; do awk '/testcase/{gsub("_[0-9]+\"", "_" ++i "\"")}1' $$tout > $$tout.tmp; mv $$tout.tmp $$tout; done
eunit-with-cover:
$(REBAR) do eunit skip_deps=true --suite=${SUITES}, cover
## Rename all tests in order to remove duplicated names (add _(++i) suffix to each test)
@for tout in `find test -name "TEST-*.xml"`; do awk '/testcase/{gsub("_[0-9]+\"", "_" ++i "\"")}1' $$tout > $$tout.tmp; mv $$tout.tmp $$tout; done
coverage:
## Set on_bamboo=true so that coverage.escript will collect coverdata from all ct_logs directories
$(BASE_DIR)/bamboos/docker/coverage.escript $(BASE_DIR) $(on_bamboo)
##
## Dialyzer targets local
##
# Dialyzes the project.
dialyzer:
@./bamboos/scripts/run-with-surefire-report.py \
--test-name Dialyze \
--report-path test/dialyzer_results/TEST-dialyzer.xml \
$(REBAR) dialyzer
##
## Packaging targets
##
check_distribution:
ifeq ($(DISTRIBUTION), none)
@echo "Please provide package distribution. Oneof: 'xenial', 'bionic', 'centos-7-x86_64'"
@exit 1
else
@echo "Building package for distribution $(DISTRIBUTION)"
endif
package/$(PKG_ID).tar.gz:
mkdir -p package
rm -rf package/$(PKG_ID)
git archive --format=tar --prefix=$(PKG_ID)/ $(PKG_REVISION) | (cd package && tar -xf -)
git submodule foreach --recursive "git archive --prefix=$(PKG_ID)/\$$path/ \$$sha1 | (cd \$$toplevel/package && tar -xf -)"
${MAKE} -C package/$(PKG_ID) get-deps submodules-in-deps inject-gui
for dep in package/$(PKG_ID) package/$(PKG_ID)/$(LIB_DIR)/*; do \
echo "Processing dependency: `basename $${dep}`"; \
vsn=`git --git-dir=$${dep}/.git describe --tags 2>/dev/null`; \
mkdir -p $${dep}/priv; \
echo "$${vsn}" > $${dep}/priv/vsn.git; \
sed -i'' "s/{vsn,\\s*git}/{vsn, \"$${vsn}\"}/" $${dep}/src/*.app.src 2>/dev/null || true; \
done
tar -C package -czf package/$(PKG_ID).tar.gz $(PKG_ID)
dist: package/$(PKG_ID).tar.gz
cp package/$(PKG_ID).tar.gz .
package: check_distribution package/$(PKG_ID).tar.gz
${MAKE} -C package -f $(PKG_ID)/node_package/Makefile
pkgclean:
rm -rf package
codetag-tracker:
@./bamboos/scripts/run-with-surefire-report.py \
--test-name CodetagTracker \
--report-path test/codetag_tracker_results/TEST-codetag_tracker.xml \
./bamboos/scripts/codetag-tracker.sh --branch=${BRANCH} \
--excluded-dirs=node_package,gpb,helpers,gen_server_mock,rrdtool,rtransfer_link,locks,codetag_tracker_results \
--excluded-files=qos_expression_parser.erl