forked from 4paradigm/OpenMLDB
-
Notifications
You must be signed in to change notification settings - Fork 0
309 lines (282 loc) · 12 KB
/
other-os-build.yml
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# OpenMLDB build on other os, only trigger by dispatch event and only upload artifacts, not release.
# You should download artifacts manually. And we won't do test in this workflow.
name: Other OS Build
on:
workflow_dispatch:
inputs:
OS:
description: 'os name: centos6, macos11, macos10'
required: true
default: 'centos6'
JAVA_SDK:
description: 'java sdk enable: ON, OFF'
required: true
default: 'ON'
PYTHON_SDK:
description: 'python sdk enable: ON, OFF'
required: true
default: 'ON'
REF:
description: 'The branch, tag or SHA to checkout, otherwise use the branch'
required: false
default: ''
ZETASQL_LIB_URL:
description: 'zetasql lib url, default is built by src, if you want to use prebuilt, set it. Only for centos6'
required: false
default: ''
env:
NPROC: 2 # default Parallel build number for GitHub's Linux runner
EXAMPLES_ENABLE: OFF # turn off hybridse's example code
HYBRIDSE_TESTING_ENABLE: OFF # turn off hybridse's test code
jobs:
centos6: # glibc version is 2.12, glibcxx version is 3.4.13
if: ${{ github.event.inputs.OS == 'centos6' }}
runs-on: ubuntu-latest
env:
OS: linux
SQL_JAVASDK_ENABLE: ${{ github.event.inputs.JAVA_SDK }}
SQL_PYSDK_ENABLE: ${{ github.event.inputs.PYTHON_SDK }} # python whl will be built when make, no prerequirement
ZETASQL_LIB_URL: ${{ github.event.inputs.ZETASQL_LIB_URL }}
TESTING_ENABLE: OFF
NPROC: 8
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.REF }}
submodules: true
- name: prepare release
run: |
VERSION="snapshot"
# if not tag, return error, just ignore it to use snapshot as the version
TAG=$(git tag -l | grep $(git describe HEAD)) || true
if [[ "${TAG}" == "v"* ]]; then
VERSION=${TAG#v}
bash steps/prepare_release.sh "$VERSION"
bash java/prepare_release.sh "$VERSION"
fi
echo "OPENMLDB_PREFIX=openmldb-$VERSION-${{ env.OS }}" >> $GITHUB_ENV
- name: Cache thirdparty
id: deps-cache
uses: actions/cache@v3
with:
path: |
.deps/
key: centos6-thirdparty-${{ hashFiles('third-party/**/CMakeLists.txt', 'third-party/**/*.cmake', 'third-party/**/*.sh') }}
# use docker in a step, not in a job, cuz we want use higher version actions(cache/upload...), centos6's nodejs is too old
# use raw cmake to build main, avoid thirdparty build again and parallel limit
# thirdparty -j8 is ok
# build -j2 is ok, >=4 will oom
# No space left on device when java sdk on, python sdk is small, rm /depends 400M, not enough,
# so we disable java when build binary(+python) and then build java without binary build(target sql_javasdk_package, build/ cost ~6.2G, java/ cost ~4.6G)
# P.S. we can package only openmldb-native, but it's better to build the whole, to avoid code error
# if you want to download other jars, upload them
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
- uses: addnab/docker-run-action@v3
with:
image: ghcr.io/4paradigm/centos6_gcc7_hybridsql
options: -v ${{ github.workspace }}:/root/OpenMLDB -e USE_DEPS_CACHE=${{ steps.deps-cache.outputs.cache-hit }} -e OPENMLDB_PREFIX=${{ env.OPENMLDB_PREFIX }} -e SQL_PYSDK_ENABLE=${{ env.SQL_PYSDK_ENABLE }} -e SQL_JAVASDK_ENABLE=${{ env.SQL_JAVASDK_ENABLE }} -e ZETASQL_LIB_URL=${{ env.ZETASQL_LIB_URL }}
shell: bash
run: |
cd /root/OpenMLDB
# centos6_build.sh won't try build zetasql when cache hit(USE_DEPS_CACHE==true)
IN_WORKFLOW=true bash steps/centos6_build.sh
# bazel bin
export PATH=$PATH:`pwd`
source /opt/rh/devtoolset-8/enable
if [[ "${USE_DEPS_CACHE}" != "true" ]]; then
echo "build thirdparty, configure in centos6_build, make opt is better than nproc"
cmake --build $(pwd)/.deps
# 5.8G ./.deps, avail 8G
rm -rf .deps/build # GitHub runner disk space is limited
fi
if [[ "${ZETASQL_LIB_URL}" != "" ]]; then
echo "replace zetasql lib by ${ZETASQL_LIB_URL}"
curl -SLo .deps/usr/lib/libzetasql.a ${ZETASQL_LIB_URL}
fi
echo "build openmldb"
# 1.4G ./.deps, avail 13G
# will failed if openmldb_sdk is on
cmake -S . -B `pwd`/build -DCMAKE_PREFIX_PATH=`pwd`/.deps/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DSQL_PYSDK_ENABLE=${SQL_PYSDK_ENABLE} -DSQL_JAVASDK_ENABLE=OFF \
-DTESTING_ENABLE=OFF -DCMAKE_INSTALL_PREFIX=${OPENMLDB_PREFIX} \
-DHYBRIDSE_TESTING_ENABLE=OFF -DEXAMPLES_ENABLE=OFF -DEXAMPLES_TESTING_ENABLE=OFF
# target openmldb 6.7G ./build(no py/java), avail 5.2G
# openmldb+cp_python_sdk_so 7.7G ./build(has py), python just ~180M
# target 'install' cost more, preinstall/fast won't build all, so use install/fast if needed
# or https://cmake.org/cmake/help/latest/variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY.html
cmake --build build --target openmldb cp_python_sdk_so -- -j2
du -h --max-depth=1
df -h
# if target above cost too much disk, make java build failed, try to rm build cache
# don't rm cache now cuz build java from emtpy will cost 20min
# rm build/hybridse build/src -rf
if [[ "${SQL_JAVASDK_ENABLE}" == "ON" ]]; then
echo "build java sdk"
cmake -S . -B `pwd`/build -DCMAKE_PREFIX_PATH=`pwd`/.deps/usr -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DSQL_PYSDK_ENABLE=OFF -DSQL_JAVASDK_ENABLE=ON \
-DTESTING_ENABLE=OFF -DCMAKE_INSTALL_PREFIX=${OPENMLDB_PREFIX} \
-DHYBRIDSE_TESTING_ENABLE=OFF -DEXAMPLES_ENABLE=OFF -DEXAMPLES_TESTING_ENABLE=OFF
# if build the whole java, 7.6G ./build, 5.7G ./java, avail 331M
# so split it and build native only
# 7.6G ./build, 1.8G ./java, avail 5.2G
cmake --build build --target cp_native_so -- -j2
du -h --max-depth=1
df -h
rm build/hybridse build/src -rf
cd java
./mvnw -pl openmldb-native clean package -DskipTests=true -Dscalatest.skip=true -Dwagon.skip=true -Dmaven.test.skip=true --batch-mode
fi
rm build/hybridse build/src -rf
du -h --max-depth=1
df -h
# - name: tar thirdparty
# run: |
# cd .deps
# tar czf usr.tar.gz usr/
- name: upload built thirdparty
uses: actions/upload-artifact@v2
with:
path: .deps/usr/lib/libzetasql.a
name: built-thirdparty
- name: upload binary
uses: actions/upload-artifact@v2
with:
path: build/bin/openmldb
name: binary
- name: upload java native
if: ${{ env.SQL_JAVASDK_ENABLE == 'ON' }}
uses: actions/upload-artifact@v2
with:
name: native-jar
path: java/openmldb-native/target/openmldb-native-*.jar
- name: upload python whl
if: ${{ env.SQL_PYSDK_ENABLE == 'ON' }}
uses: actions/upload-artifact@v2
with:
name: python-whl
path: |
python/openmldb_sdk/dist/openmldb*.whl
# TODO(hw): upload cxx sdk
# macos no need to build thirdparty, but binary/os needs to be built on each os
macos-11:
if: ${{ github.event.inputs.OS == 'macos11' }}
runs-on: macos-11
env:
OS: darwin
# if macos, set VARIANT_TYPE=macos
VARIANT_TYPE: macos
SQL_JAVASDK_ENABLE: ${{ github.event.inputs.JAVA_SDK }}
SQL_PYSDK_ENABLE: ${{ github.event.inputs.PYTHON_SDK }} # python whl will be built when make, no prerequirement
TESTING_ENABLE: OFF
ARCH: x86_64
NPROC: 3
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.REF }}
submodules: true
# it's ok to prepare version even java sdk disabled
- name: prepare release
run: |
VERSION="snapshot"
# use repo ref not event ref
TAG=$(git tag -l | grep $(git describe HEAD)) || true
if [[ "${TAG}" == "v"* ]]; then
VERSION=${TAG#v}
bash steps/prepare_release.sh "$VERSION"
bash java/prepare_release.sh "$VERSION"
fi
echo "OPENMLDB_PREFIX=openmldb-$VERSION-${{ env.OS }}" >> $GITHUB_ENV
- name: build
run: |
make build CMAKE_INSTALL_PREFIX=${{ env.OPENMLDB_PREFIX }}
# GitHub runner disk space is limited
# delete thirdparty build directory($ROOT/.deps/) to save disk space
# make thirdpartybuild-clean
- name: install
run: |
make install
- name: package
run: |
tar czf ${{ env.OPENMLDB_PREFIX }}.tar.gz ${{ env.OPENMLDB_PREFIX }}/
- name: upload binary
uses: actions/upload-artifact@v2
with:
path: openmldb-*.tar.gz
name: binary-package
- name: upload java native
if: ${{ env.SQL_JAVASDK_ENABLE == 'ON' }}
uses: actions/upload-artifact@v2
with:
name: native-jar
path: java/openmldb-native/target/openmldb-native-*.jar
- name: upload python whl
if: ${{ env.SQL_PYSDK_ENABLE == 'ON' }}
uses: actions/upload-artifact@v2
with:
name: python-whl
path: |
python/openmldb_sdk/dist/openmldb*.whl
macos-10:
if: ${{ github.event.inputs.OS == 'macos10' }}
runs-on: macos-11
env:
OS: darwin
# if macos, set VARIANT_TYPE=macos
VARIANT_TYPE: macos
SQL_JAVASDK_ENABLE: ${{ github.event.inputs.JAVA_SDK }}
SQL_PYSDK_ENABLE: ${{ github.event.inputs.PYTHON_SDK }} # python whl will be built when make, no prerequirement
TESTING_ENABLE: OFF
ARCH: x86_64
NPROC: 3
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.REF }}
submodules: true
# ref https://github.com/actions/runner-images/blob/main/images/macos/macos-11-Readme.md macOS 10.15 macosx10.15 11.7 | macOS 11.1 macosx11.1 12.4
- name: xcode select
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '11.7'
# it's ok to prepare version even java sdk disabled
- name: prepare release
run: |
VERSION="snapshot"
TAG=$(git tag -l | grep $(git describe HEAD)) || true
if [[ "${TAG}" == "v"* ]]; then
VERSION=${TAG#v}
bash steps/prepare_release.sh "$VERSION"
bash java/prepare_release.sh "$VERSION"
fi
echo "OPENMLDB_PREFIX=openmldb-$VERSION-${{ env.OS }}" >> $GITHUB_ENV
- name: build
run: |
make build CMAKE_INSTALL_PREFIX=${{ env.OPENMLDB_PREFIX }}
# GitHub runner disk space is limited
# delete thirdparty build directory($ROOT/.deps/) to save disk space
# make thirdpartybuild-clean
- name: install
run: |
make install
- name: package
run: |
tar czf ${{ env.OPENMLDB_PREFIX }}.tar.gz ${{ env.OPENMLDB_PREFIX }}/
- name: upload binary
uses: actions/upload-artifact@v2
with:
path: openmldb-*.tar.gz
name: binary-package
- name: upload java native
if: ${{ env.SQL_JAVASDK_ENABLE == 'ON' }}
uses: actions/upload-artifact@v2
with:
name: native-jar
path: java/openmldb-native/target/openmldb-native-*.jar
- name: upload python whl
if: ${{ env.SQL_PYSDK_ENABLE == 'ON' }}
uses: actions/upload-artifact@v2
with:
name: python-whl
path: |
python/openmldb_sdk/dist/openmldb*.whl