Skip to content

Commit 8b58fe9

Browse files
committed
Added a GitLab pipeline
improved build.sh a bit improved test discovery renamed build.sh to buildAndTest.sh because it contains a command to run tests made all the libs SHARED
1 parent df14c3a commit 8b58fe9

File tree

7 files changed

+115
-30
lines changed

7 files changed

+115
-30
lines changed

.ci/installDependencies.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apt-get update
2+
apt-get -y install apt-transport-https lsb-release
3+
curl -o public.gpg https://kolanich.gitlab.io/CMake_deb_packages_CI/public.gpg
4+
apt-key add public.gpg
5+
echo deb [arch=amd64,signed-by=0e94c991ee6dfe96affa14a8a059ada6ca7b4a3f] https://kolanich.gitlab.io/CMake_deb_packages_CI/repo $(lsb_release -sc) contrib >> /etc/apt/sources.list.d/vanilla_CMake_KOLANICH.list
6+
apt-get update
7+
apt-get -y install vanilla-cmake ninja-build

.gitlab-ci.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
image: gcc:latest
2+
3+
stages:
4+
- dependencies
5+
- build
6+
- test
7+
- tooling
8+
9+
build:
10+
tags:
11+
- shared
12+
stage: build
13+
variables:
14+
GIT_DEPTH: "1"
15+
16+
before_script:
17+
- . ./.ci/installDependencies.sh
18+
19+
script:
20+
- . ./buildAndTest.sh
21+
- hardening-check -c *.so SQLiteCpp
22+
23+
artifacts:
24+
paths:
25+
- build/*.so
26+
- build/*.dll
27+
- build/*.a
28+
- build/CMakeCache.txt
29+
30+
checks:
31+
stage: tooling
32+
tags:
33+
- shared
34+
image: docker:latest
35+
variables:
36+
DOCKER_DRIVER: overlay2
37+
allow_failure: true
38+
services:
39+
- docker:dind
40+
script:
41+
- docker run --env SAST_CONFIDENCE_LEVEL=5 --volume "$PWD:/code" --volume /var/run/docker.sock:/var/run/docker.sock "registry.gitlab.com/gitlab-org/security-products/sast:latest" /app/bin/run /code
42+
- docker run --env SOURCE_CODE="$PWD" --env CODECLIMATE_VERSION="latest" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock "registry.gitlab.com/gitlab-org/security-products/codequality:latest" /code
43+
#- docker run --env DEP_SCAN_DISABLE_REMOTE_CHECKS="${DEP_SCAN_DISABLE_REMOTE_CHECKS:-false}" --volume "$PWD:/code" --volume /var/run/docker.sock:/var/run/docker.sock "registry.gitlab.com/gitlab-org/security-products/dependency-scanning:latest" /code
44+
45+
artifacts:
46+
reports:
47+
codequality: gl-code-quality-report.json
48+
sast: gl-sast-report.json
49+
#dependency_scanning: gl-dependency-scanning-report.json
50+
51+
pages:
52+
stage: tooling
53+
tags:
54+
- shared
55+
image: alpine:latest
56+
allow_failure: true
57+
before_script:
58+
- apk update
59+
- apk add doxygen
60+
- apk add ttf-freefont graphviz
61+
script:
62+
- doxygen ./Doxyfile
63+
- mv ./docs/html ./public
64+
artifacts:
65+
paths:
66+
- public
67+
only:
68+
- master

CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ source_group(doc FILES ${SQLITECPP_DOC})
167167
set(SQLITECPP_SCRIPT
168168
.travis.yml
169169
appveyor.yml
170-
build.bat
171-
build.sh
170+
buildAndTest.bat
171+
buildAndTest.sh
172172
cpplint.py
173173
Doxyfile
174174
FindSQLiteCpp.cmake
@@ -182,7 +182,7 @@ option(SQLITECPP_INTERNAL_SQLITE "Add the internal SQLite3 source to the project
182182
if (SQLITECPP_INTERNAL_SQLITE)
183183
# build the SQLite3 C library (for ease of use/compatibility) versus Linux sqlite3-dev package
184184
downloadSQLiteIfNeeded(SQLite3)
185-
add_library(SQLite3 "${SQLite3_AMALGAMATION_SOURCE_DIR}/sqlite3.c")
185+
add_library(SQLite3 SHARED "${SQLite3_AMALGAMATION_SOURCE_DIR}/sqlite3.c")
186186
target_include_directories(SQLite3 PRIVATE "${SQLite3_AMALGAMATION_SOURCE_DIR}")
187187
if (UNIX)
188188
target_link_libraries(SQLite3 pthread)
@@ -194,7 +194,7 @@ if (SQLITECPP_INTERNAL_SQLITE)
194194
endif (SQLITECPP_INTERNAL_SQLITE)
195195

196196
# add sources of the wrapper as a "SQLiteCpp" static library
197-
add_library(SQLiteCpp ${SQLITECPP_SRC} ${SQLITECPP_INC} ${SQLITECPP_DOC} ${SQLITECPP_SCRIPT})
197+
add_library(SQLiteCpp SHARED ${SQLITECPP_SRC} ${SQLITECPP_INC} ${SQLITECPP_DOC} ${SQLITECPP_SCRIPT})
198198
# make the sqlite3 library part of the interface of the SQLiteCpp wrapper itself (the client app does not need to link to sqlite3)
199199
# PR https://github.com/SRombauts/SQLiteCpp/pull/111 "linked SQLiteCpp to sqlite3" commented out since it breaks install step from PR #118
200200
target_include_directories(SQLiteCpp PRIVATE
@@ -332,7 +332,6 @@ if (SQLITECPP_BUILD_TESTS)
332332

333333
# add the unit test executable
334334
add_executable(SQLiteCpp_tests ${SQLITECPP_TESTS})
335-
target_link_libraries(SQLiteCpp_tests gtest_main SQLiteCpp SQLite3)
336335
target_include_directories(SQLiteCpp_tests PRIVATE "${GTEST_INCLUDE_DIR}" "${SQLite3_AMALGAMATION_SOURCE_DIR}")
337336
target_link_libraries(SQLiteCpp_tests "${GTEST_LIBRARY}" "${GTEST_MAIN_LIBRARY}" SQLiteCpp SQLite3)
338337
harden(SQLiteCpp_tests)
@@ -346,7 +345,7 @@ if (SQLITECPP_BUILD_TESTS)
346345
enable_testing()
347346

348347
# does the tests pass?
349-
add_test(UnitTests SQLiteCpp_tests)
348+
gtest_discover_tests(SQLiteCpp_tests) # calls in own process every case, no way to disable, so don't use it, call the executable directly if you want a report file: it will contain only 1 test
350349

351350
if (SQLITECPP_BUILD_EXAMPLES)
352351
# does the example1 runs successfully?

build.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.
File renamed without changes.

buildAndTest.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/sh
2+
# Copyright (c) 2012-2019 Sébastien Rombauts ([email protected])
3+
#
4+
# Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
5+
# or copy at http://opensource.org/licenses/MIT)
6+
7+
# exit on firts error
8+
set -e
9+
10+
mkdir -p build
11+
cd build
12+
13+
cat >> ./CMakeCache.txt <<EOF
14+
CMAKE_BUILD_TYPE:STRING=Release
15+
CMAKE_VERBOSE_MAKEFILE:BOOL=ON
16+
BUILD_SHARED_LIBS:BOOL=ON
17+
SQLITECPP_BUILD_EXAMPLES:BOOL=ON
18+
SQLITECPP_BUILD_TESTS:BOOL=OFF
19+
SQLITECPP_RUN_CPPLINT:BOOL=OFF
20+
SQLITECPP_USE_GCOV:BOOL=OFF
21+
EOF
22+
23+
ninjaPath=$(which name_of_executable)
24+
if [ -x "$ninjaPath" ] ; then
25+
cmake -G Ninja ..
26+
else
27+
cmake -G "Unix Makefiles" ..
28+
fi
29+
cmake --build .
30+
31+
# Build and run unit-tests (ie 'make test')
32+
ctest --output-on-failure
33+

tests/Database_test.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ TEST(Database, execException) {
283283
// TODO: test Database::createFunction()
284284
// TODO: test Database::loadExtension()
285285

286-
#ifdef SQLITE_HAS_CODEC
287286
TEST(Database, encryptAndDecrypt) {
287+
#ifdef SQLITE_HAS_CODEC
288288
remove("test.db3");
289289
{
290290
// Try to open the non-existing database
@@ -326,9 +326,7 @@ TEST(Database, encryptAndDecrypt) {
326326
EXPECT_TRUE(db.tableExists("test"));
327327
} // Close DB test.db3
328328
remove("test.db3");
329-
}
330329
#else // SQLITE_HAS_CODEC
331-
TEST(Database, encryptAndDecrypt) {
332330
remove("test.db3");
333331
{
334332
// Try to open the non-existing database
@@ -349,5 +347,5 @@ TEST(Database, encryptAndDecrypt) {
349347
EXPECT_THROW(db.rekey("123secret"), SQLite::Exception);
350348
} // Close DB test.db3
351349
remove("test.db3");
350+
#endif // SQLITE_HAS_CODEC
352351
}
353-
#endif // SQLITE_HAS_CODEC

0 commit comments

Comments
 (0)