forked from Ericsson/CodeCompass
-
Notifications
You must be signed in to change notification settings - Fork 2
441 lines (375 loc) · 16.9 KB
/
ci.yml
File metadata and controls
441 lines (375 loc) · 16.9 KB
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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
name: Build project
on: [push, pull_request, workflow_dispatch]
env:
BUILD_TYPE: Debug
jobs:
build:
strategy:
matrix:
db: [postgresql, sqlite3]
os: [ubuntu-20.04, ubuntu-18.04]
fail-fast: false
runs-on: ${{ matrix.os }}
# Service containers to run with `runner-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps:
- uses: actions/checkout@v2
- name: Update apt-get
run: sudo apt-get update
# Ubuntu 18.04 commands
- name: Install required packages Ubuntu 18
if: ${{ matrix.os == 'ubuntu-18.04' }}
run: >
sudo apt-get install -y git cmake make g++ gcc-7-plugin-dev libboost-all-dev
llvm-10-dev clang-10 libclang-10-dev default-jdk libssl1.0-dev libgraphviz-dev
libmagic-dev libgit2-dev ctags libgtest-dev npm libldap2-dev
- name: Install Postgresql Ubuntu 18
if: ${{ matrix.os == 'ubuntu-18.04' && matrix.db == 'postgresql' }}
run: sudo apt-get install postgresql-server-dev-10
- name: Install SQLite3 Ubuntu 18
if: ${{ matrix.os == 'ubuntu-18.04' && matrix.db == 'sqlite3' }}
run: sudo apt-get install libsqlite3-dev
- name: Cache Thrift Ubuntu 18
id: thrift-cache
if: ${{ matrix.os == 'ubuntu-18.04' }}
uses: actions/cache@v2
with:
path: ~/thrift_install
key: ${{ matrix.db }}-thrift-v2
- name: Install Thrift
if: ${{ matrix.os == 'ubuntu-18.04' && steps.thrift-cache.outputs.cache-hit != 'true' }}
run: >
cd $HOME
wget -O thrift-0.13.0.tar.gz
"http://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=thrift/0.13.0/thrift-0.13.0.tar.gz"
tar -xvf ./thrift-0.13.0.tar.gz
cd thrift-0.13.0
./configure --prefix=$HOME/thrift_install --without-python --enable-libtool-lock
--enable-tutorial=no --enable-tests=no --with-libevent --with-zlib --without-nodejs
--without-lua --without-ruby --without-csharp --without-erlang --without-perl
--without-php --without-php_extension --without-dart --without-haskell --without-go
--without-rs --without-haxe --without-dotnetcore --without-d --without-qt4 --without-qt5
--without-java --without-swift
make install -j $(nproc)
- name: Cache ODB Ubuntu 18
id: odb-cache
if: ${{ matrix.os == 'ubuntu-18.04' }}
uses: actions/cache@v2
with:
path: ~/odb_install
key: ${{ matrix.db }}-odb-v2
- name: Install ODB
if: ${{ matrix.os == 'ubuntu-18.04' && steps.odb-cache.outputs.cache-hit != 'true' }}
run: |
cd $HOME
mkdir /tmp/build2src
cd /tmp/build2src
curl -sSfO https://download.build2.org/0.14.0/build2-install-0.14.0.sh
sh build2-install-0.14.0.sh --yes --trust yes "$HOME/build2_install/"
export PATH=$PATH:$HOME/build2_install/bin/
mkdir /tmp/odb_build
cd /tmp/odb_build
bpkg create --quiet --jobs $(nproc) cc config.cxx=g++ config.cc.coptions=-O3 config.bin.rpath="$HOME/odb_install/lib" config.install.root="$HOME/odb_install" config.install.sudo=sudo
bpkg add https://pkg.cppget.org/1/beta --trust-yes
bpkg fetch --trust-yes
bpkg build odb --yes
bpkg build libodb --yes
bpkg build libodb-sqlite --yes
bpkg build libodb-pgsql --yes
bpkg install --all --recursive
- name: Export environment variables Ubuntu 18
if: ${{ matrix.os == 'ubuntu-18.04' }}
run: |
ls $HOME/odb_install/bin
ls $HOME/thrift_install/bin
echo "CMAKE_PREFIX_PATH=$HOME/thrift_install:$HOME/odb_install:$CMAKE_PREFIX_PATH" >> $GITHUB_ENV
echo "PATH=$HOME/thrift_install/bin:$HOME/odb_install/bin:$PATH" >> $GITHUB_ENV
# Ubuntu 20.04 commands
- name: Install required packages Ubuntu 20
if: ${{ matrix.os == 'ubuntu-20.04' }}
run: >
sudo apt-get install -y git cmake make g++ libboost-all-dev llvm-10-dev clang-10
libclang-10-dev odb libodb-dev thrift-compiler libthrift-dev default-jdk libssl-dev
libgraphviz-dev libmagic-dev libgit2-dev ctags libgtest-dev npm libldap2-dev
- name: Install Postgresql Ubuntu 20
if: ${{ matrix.os == 'ubuntu-20.04' && matrix.db == 'postgresql' }}
run: sudo apt-get install libodb-pgsql-dev postgresql-server-dev-12
- name: Install SQLite3 Ubuntu 20
if: ${{ matrix.os == 'ubuntu-20.04' && matrix.db == 'sqlite3' }}
run: sudo apt-get install libodb-sqlite-dev libsqlite3-dev
# Common commands
- name: Install GoogleTest
run: |
echo $PATH
cd $HOME
mkdir gtest
cp -R /usr/src/googletest/* ./gtest
cd gtest
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/gtest-install
make install -j $(nproc)
echo "GTEST_ROOT=$HOME/gtest-install" >> $GITHUB_ENV
- name: Configure CMake
working-directory: ${{github.workspace}}
run: cmake -E make_directory ${{github.workspace}}/build
- name: Run CMake (Postgresql)
if: ${{ matrix.db == 'postgresql' }}
working-directory: ${{github.workspace}}/build
run: >
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=1
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/${{ matrix.os }}/${{ matrix.db }}/install
-DDATABASE=pgsql
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
-DLLVM_DIR=/usr/lib/llvm-10/cmake
-DClang_DIR=/usr/lib/cmake/clang-10
-DTEST_DB="pgsql:host=localhost;username=postgres;password=postgres;port=5432;database=cc_test"
- name: Run CMake (SQLite3)
if: ${{ matrix.db == 'sqlite3' }}
working-directory: ${{github.workspace}}/build
run: >
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=1
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/${{ matrix.os }}/${{ matrix.db }}/install
-DDATABASE=sqlite -DCMAKE_BUILD_TYPE=$BUILD_TYPE
-DLLVM_DIR=/usr/lib/llvm-10/cmake
-DClang_DIR=/usr/lib/cmake/clang-10
-DTEST_DB="sqlite:database=$HOME/mydatabase.sqlite"
- name: Build
working-directory: ${{github.workspace}}/build
run: make -j $(nproc)
- name: Install
working-directory: ${{github.workspace}}/build
run: make install
- name: Run tests
working-directory: ${{github.workspace}}/build
run: make test ARGS=-V
- name: Archive CodeCompass binaries
uses: actions/upload-artifact@v2
with:
name: codecompass-${{ matrix.os }}-${{ matrix.db }}-bin
path: ${{github.workspace}}/${{ matrix.os }}/${{ matrix.db }}/install
- name: Archive CodeCompass compile-time source files
uses: actions/upload-artifact@v2
with:
name: codecompass-${{ matrix.os }}-${{ matrix.db }}-compiletime
path: |
${{github.workspace}}/build/**/*.c
${{github.workspace}}/build/**/*.h
${{github.workspace}}/build/**/*.cpp
${{github.workspace}}/build/**/*.hpp
${{github.workspace}}/build/**/*.cxx
${{github.workspace}}/build/**/*.hxx
${{github.workspace}}/build/**/*.ixx
${{github.workspace}}/build/**/*.js
${{github.workspace}}/build/**/compile_commands.json
parse:
needs: build
strategy:
matrix:
db: [ postgresql, sqlite3 ]
os: [ ubuntu-20.04, ubuntu-18.04 ]
fail-fast: false
runs-on: ${{ matrix.os }}
# Service containers to run with `runner-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps:
- uses: actions/checkout@v2
- name: Update apt-get
run: sudo apt-get update
# Ubuntu 18.04 commands
- name: Install required packages Ubuntu 18
if: ${{ matrix.os == 'ubuntu-18.04' }}
run: >
sudo apt-get install -y git cmake make g++ gcc-7-plugin-dev libgraphviz-dev
libboost-filesystem-dev libboost-log-dev libboost-program-options-dev
llvm-10-dev clang-10 libclang-10-dev default-jre libssl1.0-dev libmagic-dev
libgit2-dev ctags libgtest-dev libldap-2.4-2
- name: Install Postgresql Ubuntu 18
if: ${{ matrix.os == 'ubuntu-18.04' && matrix.db == 'postgresql' }}
run: sudo apt-get install postgresql-server-dev-10
- name: Install SQLite3 Ubuntu 18
if: ${{ matrix.os == 'ubuntu-18.04' && matrix.db == 'sqlite3' }}
run: sudo apt-get install libsqlite3-dev
- name: Cache ODB Ubuntu 18
id: odb-cache
if: ${{ matrix.os == 'ubuntu-18.04' }}
uses: actions/cache@v2
with:
path: ~/odb_install
key: ${{ matrix.db }}-odb-v2
- name: Cache Thrift Ubuntu 18
id: thrift-cache
if: ${{ matrix.os == 'ubuntu-18.04' }}
uses: actions/cache@v2
with:
path: ~/thrift_install
key: ${{ matrix.db }}-thrift-v2
- name: Export environment variables Ubuntu 18
if: ${{ matrix.os == 'ubuntu-18.04' }}
run: |
echo "LD_LIBRARY_PATH=$HOME/thrift_install/lib:$HOME/odb_install/lib:$CMAKE_PREFIX_PATH" >> $GITHUB_ENV
echo "PATH=$HOME/thrift_install/bin:$HOME/odb_install/bin:$PATH" >> $GITHUB_ENV
# Ubuntu 20.04 commands
- name: Install required packages Ubuntu 20
if: ${{ matrix.os == 'ubuntu-20.04' }}
run: >
sudo apt-get install -y git cmake make g++ libboost-filesystem-dev
libboost-log-dev libboost-program-options-dev llvm-10-dev clang-10
libclang-10-dev libgraphviz-dev libgtest-dev odb libodb-dev
libthrift-dev default-jre libssl1.1 libmagic-dev libgit2-dev ctags
libldap-2.4-2
- name: Install Postgresql Ubuntu 20
if: ${{ matrix.os == 'ubuntu-20.04' && matrix.db == 'postgresql' }}
run: sudo apt-get install libodb-pgsql-dev postgresql-server-dev-12
- name: Install SQLite3 Ubuntu 20
if: ${{ matrix.os == 'ubuntu-20.04' && matrix.db == 'sqlite3' }}
run: sudo apt-get install libodb-sqlite-dev libsqlite3-dev
# Common commands
- name: Download CodeCompass binaries
uses: actions/download-artifact@v2
with:
name: codecompass-${{ matrix.os }}-${{ matrix.db }}-bin
path: ${{github.workspace}}/install
- name: Download CodeCompass compile-time source files
uses: actions/download-artifact@v2
with:
name: codecompass-${{ matrix.os }}-${{ matrix.db }}-compiletime
path: ${{github.workspace}}/build
- name: Add execute right to parser and move source files
run: |
chmod +x ${{github.workspace}}/install/bin/CodeCompass_parser
# Parsing with Postgresql
- name: Parse TinyXML Postgresql
if: ${{ matrix.db == 'postgresql' }}
run: |
cd $HOME
git clone https://github.com/leethomason/tinyxml2
mkdir build_tinyxml2 && cd build_tinyxml2
cmake $HOME/tinyxml2 -DCMAKE_EXPORT_COMPILE_COMMANDS=1
make -j $(nproc)
cd ${{github.workspace}}/install/bin
./CodeCompass_parser -d "pgsql:host=localhost;port=5432;user=postgres;password=postgres;database=tinyxml2" -w $HOME/ws_pgsql/ -n TinyXML2 -i $HOME/tinyxml2 -i $HOME/build_tinyxml2/compile_commands.json -j $(nproc)
- name: Parse CodeCompass Postgresql
if: ${{ matrix.db == 'postgresql' }}
run: >
${{github.workspace}}/install/bin/CodeCompass_parser
-d "pgsql:host=localhost;port=5432;user=postgres;password=postgres;database=codecompass"
-w $HOME/ws_pgsql/
-n "CodeCompass"
-i ${{github.workspace}}
-i ${{github.workspace}}/build/compile_commands.json
-j $(nproc)
- name: Parse Xerces-C Postgresql
if: ${{ matrix.db == 'postgresql' }}
run: |
cd $HOME
git clone https://github.com/apache/xerces-c/
mkdir build_xerces-c && cd build_xerces-c
cmake $HOME/xerces-c -DCMAKE_EXPORT_COMPILE_COMMANDS=1
make -j $(nproc)
cd ${{github.workspace}}/install/bin
./CodeCompass_parser -d "pgsql:host=localhost;port=5432;user=postgres;password=postgres;database=xerces_c" -w $HOME/ws_pgsql/ -n "Xerces-C" -i $HOME/xerces-c -i $HOME/build_xerces-c/compile_commands.json -j $(nproc)
# Parsing with SQLite3
- name: Parse TinyXML Sqlite3
if: ${{ matrix.db == 'sqlite3' }}
run: |
cd $HOME
git clone https://github.com/leethomason/tinyxml2
mkdir build_tinyxml2 && cd build_tinyxml2
cmake $HOME/tinyxml2 -DCMAKE_EXPORT_COMPILE_COMMANDS=1
make -j $(nproc)
cd ${{github.workspace}}/install/bin
./CodeCompass_parser -d "sqlite:database=$HOME/tinyxml2.sqlite" -w $HOME/ws_pgsql/ -n TinyXML2 -i $HOME/tinyxml2 -i $HOME/build_tinyxml2/compile_commands.json -j $(nproc)
- name: Parse CodeCompass SQLite3
if: ${{ matrix.db == 'sqlite3' }}
run: >
${{github.workspace}}/install/bin/CodeCompass_parser
-d "sqlite:database=$HOME/codecompass.sqlite"
-w $HOME/ws_pgsql/
-n "CodeCompass"
-i ${{github.workspace}}
-i ${{github.workspace}}/build/compile_commands.json
-j $(nproc)
- name: Parse Xerces-C SQLite3
if: ${{ matrix.db == 'sqlite3' }}
run: |
cd $HOME
git clone https://github.com/apache/xerces-c/
mkdir build_xerces-c && cd build_xerces-c
cmake $HOME/xerces-c -DCMAKE_EXPORT_COMPILE_COMMANDS=1
make -j $(nproc)
cd ${{github.workspace}}/install/bin
./CodeCompass_parser -d "sqlite:database=$HOME/xerces.sqlite" -w $HOME/ws_pgsql/ -n "Xerces-C" -i $HOME/xerces-c -i $HOME/build_xerces-c/compile_commands.json -j $(nproc)
docker:
needs: parse
if: ${{ github.repository == 'Ericsson/CodeCompass' && github.ref == 'refs/heads/master' }}
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build images
id: docker_build
run: |
docker build -t codecompass:dev -t modelcpp/codecompass:dev --file docker/dev/Dockerfile .
docker build -t codecompass:runtime -t modelcpp/codecompass:runtime-sqlite --file docker/runtime/Dockerfile --no-cache --build-arg CC_DATABASE=sqlite .
docker build -t codecompass:web -t modelcpp/codecompass:web-sqlite --file docker/web/Dockerfile --no-cache .
docker build -t codecompass:runtime -t modelcpp/codecompass:runtime-pgsql --file docker/runtime/Dockerfile --no-cache --build-arg CC_DATABASE=pgsql .
docker build -t codecompass:web -t modelcpp/codecompass:web-pgsql --file docker/web/Dockerfile --no-cache .
docker tag modelcpp/codecompass:runtime-pgsql modelcpp/codecompass:latest
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Push images
run: |
docker push modelcpp/codecompass:dev
docker push modelcpp/codecompass:runtime-sqlite
docker push modelcpp/codecompass:runtime-pgsql
docker push modelcpp/codecompass:web-sqlite
docker push modelcpp/codecompass:web-pgsql
docker push modelcpp/codecompass:latest
tarball:
needs: parse
if: ${{ github.repository == 'Ericsson/CodeCompass' && github.ref == 'refs/heads/master' }}
runs-on: ubuntu-20.04
steps:
- name: Update apt-get
run: sudo apt-get update
- name: Install curl
run: sudo apt-get install curl
- name: Trigget GitLab CI
run: curl -X POST -F token=${{ secrets.GITLAB_TRIGGER_TOKEN }} -F ref=master https://gitlab.inf.elte.hu/api/v4/projects/85/trigger/pipeline