-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
167 lines (130 loc) · 5.15 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
.EXPORT_ALL_VARIABLES:
REPO ?= oz_worker
# distro for package building (oneof: xenial, bionic, centos-7-x86_64)
DISTRIBUTION ?= none
export DISTRIBUTION
PKG_REVISION ?= $(shell git describe --tags --always)
PKG_VERSION ?= $(shell git describe --tags --always | tr - .)
PKG_ID = oz_worker-$(PKG_VERSION)
PKG_BUILD = 1
BASE_DIR = $(shell pwd)
ERLANG_BIN = $(shell dirname $(shell which erl))
REBAR ?= $(BASE_DIR)/rebar3
LIB_DIR = _build/default/lib
REL_DIRS = _build/default/rel
PKG_VARS_CONFIG = pkg.vars.config
OVERLAY_VARS ?= --overlay_vars=rel/vars.config
TEMPLATE_SCRIPT := ./rel/overlay.escript
DOCKER_REG_USER ?= ""
DOCKER_REG_PASSWORD ?= ""
DOCKER_REG_EMAIL ?= ""
BASE_DIR = $(shell pwd)
GIT_URL := $(shell git config --get remote.origin.url | sed -e 's/\(\/[^/]*\)$$//g')
GIT_URL := $(shell if [ "${GIT_URL}" = "file:/" ]; then echo 'ssh://[email protected]: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: test deps upgrade generate package
all: test_rel
##
## Rebar targets
##
get-deps:
$(REBAR) get-deps
upgrade:
$(REBAR) upgrade --all
compile:
$(REBAR) compile
inject-gui: get-deps
$(LIB_DIR)/gui/pull-gui.sh gui-image.conf --target-path _build/default/lib/ozw_gui_static.tar.gz
$(LIB_DIR)/gui/pull-gui.sh default-harvester-gui-image.conf --target-path _build/default/lib/hrv_gui_static.tar.gz
## Generates a production release
generate: template inject-gui
$(REBAR) release $(OVERLAY_VARS)
clean:
$(REBAR) clean
distclean: clean
$(REBAR) clean --all
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: rel cm_rel
cm_rel:
mkdir -p cluster_manager/bamboos/gen_dev
make -C $(LIB_DIR)/cluster_manager/ submodules
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 _build/rel/oz_worker
rm -rf cluster_manager/_build/rel/cluster_manager
##
## Testing
##
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:
$(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 "git archive --prefix=$(PKG_ID)/\$$path/ \$$sha1 | (cd \$$toplevel/package && tar -xf -)"
${MAKE} -C package/$(PKG_ID) get-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,locks,codetag_tracker_results,dialyzer_results