forked from howsoai/howso-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·186 lines (151 loc) · 4.8 KB
/
build.sh
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
#!/bin/bash
# Linux build scripts for howso-engine release cycle - build/test/package
#
# usage: ./build.sh build|test|package
#
####
set -e
set -u
# set -x
# Global Versions
amlg_version="0.0.0"
engine_version="0.0.0"
# root directory for git repository.
src_dir=$( cd "$(dirname "${BASH_SOURCE[0]}")"/; pwd -P )
# root directory for build artifacts.
out_dir=${src_dir}/target
pkg_dir=${out_dir}/package
amlg_exe=${src_dir}/target/bin/amalgam-mt
# root directory for release artifacts.
rel_dir=${src_dir}/release
# set a timestamp
timestamp=$(date +%x_%H:%M)
# Get the Platform we are running the build on.
plat=$(uname | tr '[:upper:]' '[:lower:]')
# Get the Platform chipset architecture. 'amd64' or 'arm64'
arch=${ARCH:-$(uname -m | tr '[:upper:]' '[:lower:]')}
if [[ "$arch" = 'x86_64' ]]; then arch="amd64"; fi
build() {
engine_version=${1:-'0.0.0'}
check_amalgam_exe
echo "Building Howso Engine version \"${engine_version}\" with amalgam version \"${amlg_version}\"..."
update_version_file ${engine_version}
cd ${src_dir}
rm -f howso.caml
rm -f trainee_template.caml
rm -f migrations.caml
# make local user dev/engine directory.
mkdir -p ~/.howso/lib/dev/engine
mkdir -p ~/.howso/lib/dev/engine/migrations
# make package output directory.
mkdir -p ${pkg_dir}/
# Create howso artifact:
"${amlg_exe}" deploy_howso.amlg
if [ ! -f ~/.howso/lib/dev/engine/howso.caml ]; then
echo "No caml files built - howso engine build failed"
exit 76
fi
cp -r ~/.howso/lib/dev/engine/* ${pkg_dir}/
}
test() {
engine_version=${1:-'0.0.0'}
echo "Testing Howso Engine version ${engine_version}..."
arm_ver=${2:-''}
if [[ "$arm_ver" == "arm64_8a" ]]; then
amlg_exe=${src_dir}/target/bin/amalgam-st
fi
check_amalgam_exe
update_version_file ${engine_version}
cd ${src_dir}/unit_tests
echo "Running howso-engine unit tests with amalgam version \"${amlg_version}\"..."
"${amlg_exe}" --debug-internal-memory ./ut_comprehensive_unit_test.amlg | tee /tmp/ut_results
reset_version_file
local ut_res=$(cat /tmp/ut_results | grep "PASSED : Total comprehensive test execution time" | wc -l)
if [ $ut_res \< 1 ]; then
cat /tmp/ut_results
exit 81
fi
}
performance_test() {
engine_version=${1:-'0.0.0'}
echo "Performance testing Howso Engine version ${engine_version}..."
arm_ver=${2:-''}
if [[ "$arm_ver" == "arm64_8a" ]]; then
amlg_exe="${src_dir}/target/bin/amalgam-st"
fi
check_amalgam_exe
update_version_file ${engine_version}
echo "Running howso-engine performance tests with amalgam version \"${amlg_version}\"..."
"${amlg_exe}" ./run_performance_tests.amlg | tee /tmp/pt_results
reset_version_file
local pt_res=$(cat /tmp/pt_results | grep "PASSED : Total comprehensive test execution time" | wc -l)
if [ "$pt_res" \< 1 ]; then
cat /tmp/pt_results
exit 81
fi
}
build_test() {
engine_version=${1:-'0.0.0'}
# build, test
build ${engine_version}
test ${engine_version}
reset_version_file
}
build_test_package() {
engine_version=${1:-'0.0.0'}
# build, test, package.
build ${engine_version}
test ${engine_version}
package ${engine_version}
# reset version.json
reset_version_file
}
build_package() {
engine_version=${1:-'0.0.0'}
# build, package.
build ${engine_version}
package ${engine_version}
# reset version.json
reset_version_file
}
update_version_file() {
engine_version=${1:-'0.0.0'}
echo "Updating version.json with: \"version\": \"${engine_version}\", amalgam=\"${amlg_version}\""
cd ${src_dir}
git checkout version.json
temp_file=${src_dir}/version.json.orig
cp ${src_dir}/version.json $temp_file
jq ". | .version=\"${engine_version}\"" ${temp_file} > ${temp_file}.tmp && mv ${temp_file}.tmp ${temp_file}
jq ". | .dependencies.amalgam=\"${amlg_version}\"" ${temp_file} > ${src_dir}/version.json
rm ${temp_file}
cat ${src_dir}/version.json
echo 'Done updating version.json'
}
reset_version_file() {
cd ${src_dir}
git checkout version.json
}
check_amalgam_exe() {
# Check if the amalgam binary exists. If not, warn user to download
# a proper version and locate it at howso-engine/target/bin/amalgam
if [[ ! -x "$amlg_exe" ]]; then
echo "${amlg_exe} does not exist. Download a proper amalgam binary."
exit 146
fi
amlg_version=$("$amlg_exe" --version)
}
package() {
echo "Archiving, Compressing, Encrypting howso directory"
engine_version=${1}
if [ -f ${src_dir}/version.json ]; then
# use jq to replace version and put output into package directory.
jq ". | .version=\"${engine_version}\"" ${src_dir}/version.json > ${pkg_dir}/version.json
fi
cd ${pkg_dir}/
tar -zcvf ${out_dir}/howso-engine-${engine_version}.tar.gz ./
}
# Run the function matching the first cmd line argument - if there are 0 args, then run build.
if [[ $# -eq 0 ]] ; then
build $engine_version
fi
"$@"