forked from aws/amazon-documentdb-odbc-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
404 lines (349 loc) · 14.4 KB
/
linux-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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
name: ODBC Driver for Linux
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
env:
CI_OUTPUT_PATH: "ci-output"
ODBC_LIB_PATH: "${{github.workspace}}/build/odbc/lib"
ODBC_BIN_PATH: "${{github.workspace}}/build/odbc/bin"
ODBC_BUILD_PATH: "${{github.workspace}}/build/odbc/build"
DOCUMENTDB_HOME: "${{github.workspace}}/build/odbc/bin"
DOC_DB_KEYPAIR: ${{secrets.DOC_DB_KEYPAIR}}
DOC_DB_USER_NAME: ${{secrets.DOC_DB_USER_NAME}}
DOC_DB_PASSWORD: ${{secrets.DOC_DB_PASSWORD}}
DOC_DB_USER: ${{secrets.DOC_DB_USER}}
DOC_DB_HOST: ${{secrets.DOC_DB_HOST}}
DOC_DB_LOCAL_PORT: 27019
DOC_DB_REMOTE_PORT: 27017
DOC_DB_PRIV_KEY_FILE: ~/certs/docdb-sshtunnel.pem
DOC_DB_ODBC_INTEGRATION_TEST: 1
DOC_DB_LOG_PATH: "${{github.workspace}}/build/odbc/logs"
DOC_DB_LOG_LEVEL: "debug"
JAVA_HOME: "/usr/lib/jvm/java-17-amazon-corretto/"
jobs:
build-linux64:
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }}
steps:
- uses: actions/checkout@v2
- name: Get Java distribution
run: |
sudo apt-get -y install software-properties-common
wget -O- https://apt.corretto.aws/corretto.key | sudo apt-key add -
sudo apt-add-repository 'deb https://apt.corretto.aws stable main'
sudo apt-get update
sudo apt-get install -y java-17-amazon-corretto-jdk
- name: Get latest version of CMake
uses: lukka/get-cmake@latest
- name: run-cppcheck
run: |
sudo apt install cppcheck
sh run_cppcheck.sh
- name: upload-cppcheck-results
if: failure()
uses: actions/upload-artifact@v2
with:
name: cppcheck-results
path: cppcheck-results.log
- name: Extract key-pair into file
run: |
mkdir ~/certs
echo "${{env.DOC_DB_KEYPAIR}}" > ${{env.DOC_DB_PRIV_KEY_FILE}}
chmod 400 ${{env.DOC_DB_PRIV_KEY_FILE}}
- name: get-dependencies
if: success()
run: |
sudo apt update
sudo apt install libcurl4-openssl-dev libssl-dev uuid-dev zlib1g-dev libpulse-dev linux-headers-$(uname -r) gcc gcc-multilib g++ g++-multilib linux-headers-$(uname -r) build-essential valgrind libboost-all-dev libbson-dev libsasl2-dev lcov
- name: Update environment with JDBC_DRIVER_VERSION
run: |
read -r JDBC_DRIVER_VERSION < ./src/JDBC_DRIVER_VERSION.txt
echo "JDBC_DRIVER_VERSION=$JDBC_DRIVER_VERSION" >> $GITHUB_ENV
- name: Cache DocumentDB JDBC JAR
id: cache-documentdb-jdbc-jar
uses: actions/cache@v3
with:
path: |
cache/jar
key: cache-documentdb-jdbc-jar-${{env.JDBC_DRIVER_VERSION}}
- name: Download DocumentDB JDBC JAR
if: steps.cache-documentdb-jdbc-jar.outputs.cache-hit != 'true'
run: |
mkdir -p cache/jar
cd cache/jar
wget https://github.com/aws/amazon-documentdb-jdbc-driver/releases/download/v${{env.JDBC_DRIVER_VERSION}}/documentdb-jdbc-${{env.JDBC_DRIVER_VERSION}}-all.jar
- name: Install DocumentDB JDBC JAR
run: |
mkdir -p ${{env.ODBC_BIN_PATH}}/libs
cp cache/jar/documentdb-jdbc-${{env.JDBC_DRIVER_VERSION}}-all.jar ${{env.ODBC_BIN_PATH}}/libs
- name: build-and-install-mongocxx
run: |
wget https://github.com/mongodb/mongo-c-driver/releases/download/1.21.1/mongo-c-driver-1.21.1.tar.gz
tar xzf mongo-c-driver-1.21.1.tar.gz
cd mongo-c-driver-1.21.1
mkdir -p cmake-build
cd cmake-build
cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF ..
sudo make install
cd ../..
git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/stable --depth 1
cd mongo-cxx-driver/build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBSONCXX_POLY_USE_MNMLSTC=1 -DCMAKE_INSTALL_PREFIX=/usr/local
sudo make install
- name: install-mongocxx
run: |
cd mongo-c-driver-1.21.1/cmake-build
cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF ..
sudo make
sudo make install
cd ../../
cd mongo-cxx-driver/build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBSONCXX_POLY_USE_MNMLSTC=1 -DCMAKE_INSTALL_PREFIX=/usr/local
sudo make
sudo make install
# TODO enable clang-tidy-check
# https://github.com/aws/amazon-documentdb-odbc-driver/issues/169
# generate compile_commands.json file for clang-tidy-check, requires mongocxx and boost dependencies
# - name: generate-compile-commands-file
# run: |
# cmake "${{github.workspace}}/src" -DCMAKE_EXPORT_COMPILE_COMMANDS=on -DCMAKE_BUILD_TYPE=Release -DCODE_COVERAGE="OFF" -DBUILD_SHARED_LIBS="OFF" -DWITH_TESTS="ON" -DWITH_ODBC="ON"
# - name: clang-tidy-check
# uses: ZedThree/[email protected]
# id: review
# with:
# If there are any comments, fail the check
# - if: steps.review.outputs.total_comments > 0
# run: exit 1
- name: configure-and-build-driver
run: |
chmod +x build_linux_release64_deb.sh
./build_linux_release64_deb.sh
- name: register-odbc-driver
run: |
chmod +r -R ${{env.ODBC_LIB_PATH}}
chmod +x scripts/register_driver_unix.sh
sudo bash scripts/register_driver_unix.sh
- name: set-up-local-mongodb
run: |
docker run --name mongo -e MONGO_INITDB_ROOT_USERNAME=${{env.DOC_DB_USER_NAME}} -e MONGO_INITDB_ROOT_PASSWORD=${{env.DOC_DB_PASSWORD}} -d -p 27017:27017 mongo:latest
chmod +x ./src/odbc-test/scripts/import_test_data.sh
./src/odbc-test/scripts/import_test_data.sh
- name: run-tests
id: runtests
run: |
mkdir -p "${{env.DOC_DB_LOG_PATH}}"
ssh -f -N -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ${{env.DOC_DB_PRIV_KEY_FILE}} -L${{env.DOC_DB_LOCAL_PORT}}:${{secrets.DOC_DB_HOST}}:${{env.DOC_DB_REMOTE_PORT}} ${{secrets.DOC_DB_USER}}
./build/odbc/bin/documentdb-odbc-tests --catch_system_errors=false
- name: upload-test-report
if: always()
uses: EnricoMi/publish-unit-test-result-action/[email protected]
with:
check_name: "Ubuntu 20.04 Build Unit Test Results Check"
comment_title: "Ubuntu 20.04 Build Unit Test Results"
files: ./odbc_test_result.xml
- name: upload-test-file
if: always() && (steps.runtests.outcome == 'failure')
uses: actions/upload-artifact@v2
with:
name: odbc-test-results
path: |
./odbc_test_result.xml
./build/odbc/logs/docdb_odbc_*.log
build-linux64-debug:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Get Java distribution
run: |
sudo apt-get -y install software-properties-common
wget -O- https://apt.corretto.aws/corretto.key | sudo apt-key add -
sudo apt-add-repository 'deb https://apt.corretto.aws stable main'
sudo apt-get update
sudo apt-get install -y java-17-amazon-corretto-jdk
pip install gcovr
- name: Get latest version of CMake
uses: lukka/get-cmake@latest
- name: run-cppcheck
run: |
sudo apt install cppcheck
sh run_cppcheck.sh
- name: upload-cppcheck-results
if: failure()
uses: actions/upload-artifact@v2
with:
name: cppcheck-results
path: cppcheck-results.log
- name: Extract key-pair into file
run: |
mkdir ~/certs
echo "${{env.DOC_DB_KEYPAIR}}" > ${{env.DOC_DB_PRIV_KEY_FILE}}
chmod 400 ${{env.DOC_DB_PRIV_KEY_FILE}}
- name: get-dependencies
if: success()
run: |
sudo apt update
sudo apt install libcurl4-openssl-dev libssl-dev uuid-dev zlib1g-dev libpulse-dev linux-headers-$(uname -r) gcc gcc-multilib g++ g++-multilib linux-headers-$(uname -r) build-essential valgrind libboost-all-dev libbson-dev libsasl2-dev lcov
- name: Update environment with JDBC_DRIVER_VERSION
run: |
read -r JDBC_DRIVER_VERSION < ./src/JDBC_DRIVER_VERSION.txt
echo "JDBC_DRIVER_VERSION=$JDBC_DRIVER_VERSION" >> $GITHUB_ENV
- name: Cache DocumentDB JDBC JAR
id: cache-documentdb-jdbc-jar
uses: actions/cache@v3
with:
path: |
cache/jar
key: cache-documentdb-jdbc-jar-${{env.JDBC_DRIVER_VERSION}}
- name: Download DocumentDB JDBC JAR
if: steps.cache-documentdb-jdbc-jar.outputs.cache-hit != 'true'
run: |
mkdir -p cache/jar
cd cache/jar
wget https://github.com/aws/amazon-documentdb-jdbc-driver/releases/download/v${{env.JDBC_DRIVER_VERSION}}/documentdb-jdbc-${{env.JDBC_DRIVER_VERSION}}-all.jar
- name: Install DocumentDB JDBC JAR
run: |
mkdir -p ${{env.ODBC_BIN_PATH}}/libs
cp cache/jar/documentdb-jdbc-${{env.JDBC_DRIVER_VERSION}}-all.jar ${{env.ODBC_BIN_PATH}}/libs
- name: build-and-install-mongocxx
run: |
wget https://github.com/mongodb/mongo-c-driver/releases/download/1.21.1/mongo-c-driver-1.21.1.tar.gz
tar xzf mongo-c-driver-1.21.1.tar.gz
cd mongo-c-driver-1.21.1
mkdir -p cmake-build
cd cmake-build
cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF ..
sudo make install
cd ../..
git clone https://github.com/mongodb/mongo-cxx-driver.git --branch releases/stable --depth 1
cd mongo-cxx-driver/build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBSONCXX_POLY_USE_MNMLSTC=1 -DCMAKE_INSTALL_PREFIX=/usr/local
sudo make install
- name: install-mongocxx
run: |
cd mongo-c-driver-1.21.1/cmake-build
cmake -DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF ..
sudo make
sudo make install
cd ../../
cd mongo-cxx-driver/build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBSONCXX_POLY_USE_MNMLSTC=1 -DCMAKE_INSTALL_PREFIX=/usr/local
sudo make
sudo make install
# TODO enable clang-tidy-check
# https://github.com/aws/amazon-documentdb-odbc-driver/issues/169
# generate compile_commands.json file for clang-tidy-check, requires mongocxx and boost dependencies
# - name: generate-compile-commands-file
# run: |
# cmake "${{github.workspace}}/src" -DCMAKE_EXPORT_COMPILE_COMMANDS=on -DCMAKE_BUILD_TYPE=Release -DCODE_COVERAGE="OFF" -DBUILD_SHARED_LIBS="OFF" -DWITH_TESTS="ON" -DWITH_CORE="OFF" -DWITH_ODBC="ON"
# - name: clang-tidy-check
# uses: ZedThree/[email protected]
# id: review
# with:
# If there are any comments, fail the check
# - if: steps.review.outputs.total_comments > 0
# run: exit 1
- name: configure-and-build-driver
run: |
chmod +x build_linux_debug64.sh
./build_linux_debug64.sh
- name: register-odbc-driver
run: |
chmod +r -R ${{env.ODBC_LIB_PATH}}
chmod +x scripts/register_driver_unix.sh
sudo bash scripts/register_driver_unix.sh
- name: set-up-local-mongodb
run: |
docker run --name mongo -e MONGO_INITDB_ROOT_USERNAME=${{env.DOC_DB_USER_NAME}} -e MONGO_INITDB_ROOT_PASSWORD=${{env.DOC_DB_PASSWORD}} -d -p 27017:27017 mongo:latest
chmod +x ./src/odbc-test/scripts/import_test_data.sh
./src/odbc-test/scripts/import_test_data.sh
- name: run-tests
id: runtests
run: |
mkdir -p "${{env.DOC_DB_LOG_PATH}}"
ssh -f -N -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ${{env.DOC_DB_PRIV_KEY_FILE}} -L${{env.DOC_DB_LOCAL_PORT}}:${{secrets.DOC_DB_HOST}}:${{env.DOC_DB_REMOTE_PORT}} ${{secrets.DOC_DB_USER}}
./build/odbc/bin/documentdb-odbc-tests --catch_system_errors=false
gcovr --exclude-directories cmake-build64/odbc-test/CMakeFiles/documentdb-odbc-tests.dir$ --cobertura --output coverage.cobertura.xml
- name: Update Repository Before Commit Badge
run: |
git pull
- name: Code Coverage Badge
uses: irongut/[email protected]
with:
filename: coverage.cobertura.xml
badge: true
format: text
indicators: true
output: both
- name: Extract Code Coverage Badge
run: |
COVERAGE_BADGE=$(head -1 code-coverage-results.txt )
COVERAGE_BADGE="${COVERAGE_BADGE/'Code%20Coverage'/'Linux%20Code%20Coverage'}"
curl $COVERAGE_BADGE > .github/badges/coverage_badge_linux.svg
- name: Commit Coverage Badge
if: github.event_name == 'pull_request'
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_options: '--allow-empty --no-verify'
commit_message: Commit Code Coverage Badge
file_pattern: '*.svg'
skip_fetch: true
skip_dirty_check: true
- name: Code Coverage Summary Report
uses: irongut/[email protected]
with:
filename: coverage.cobertura.xml
badge: true
format: markdown
indicators: true
output: both
- name: Add Header for Code Coverage Summary Report
run: |
echo "## Ubuntu 20.04 Debug Build Unit Test Results Check" > coverage-cobertura.md
cat code-coverage-results.md >> coverage-cobertura.md
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
header: linux
recreate: true
path: coverage-cobertura.md
- name: upload-test-report
if: always()
uses: EnricoMi/publish-unit-test-result-action/[email protected]
with:
check_name: "Ubuntu 20.04 Debug Build Unit Test Results Check"
comment_title: "Ubuntu 20.04 Debug Build Unit Test Results"
files: ./odbc_test_result.xml
- name: upload-test-file
if: always() && (steps.runtests.outcome == 'failure')
uses: actions/upload-artifact@v3
with:
name: odbc-test-results-linux-debug
path: |
./odbc_test_result.xml
./build/odbc/logs/docdb_odbc_*.log
- name: upload-coverage
if: always()
uses: actions/upload-artifact@v3
with:
name: code-coverage-Linux
path: cmake-build64/ccov/all-merged
build-linux-docker-image:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: build-image
run: |
cd docker/linux-environment
docker build -t documentdb-dev-linux .
# TODO Linux build enhacements
# https://github.com/aws/amazon-documentdb-odbc-driver/issues/170