From 221cf13bfc33607d13e021d7e503a5bceabd1b6a Mon Sep 17 00:00:00 2001 From: Viktor Kopp Date: Mon, 16 Sep 2024 21:26:44 +0200 Subject: [PATCH 1/3] Build unit tests on CI Signed-off-by: Viktor Kopp --- qdlt/CMakeLists.txt | 1 + qdlt/tests/CMakeLists.txt | 5 +++++ scripts/linux/install.sh | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/qdlt/CMakeLists.txt b/qdlt/CMakeLists.txt index 4ee1e017..80fa297d 100644 --- a/qdlt/CMakeLists.txt +++ b/qdlt/CMakeLists.txt @@ -123,6 +123,7 @@ endforeach() find_package(GTest) # configure unit tests only if gtest found on the system if (GTest_FOUND) + message(STATUS "Tests enabled") enable_testing() add_subdirectory(tests) endif() diff --git a/qdlt/tests/CMakeLists.txt b/qdlt/tests/CMakeLists.txt index 13b400a4..beccd1f3 100644 --- a/qdlt/tests/CMakeLists.txt +++ b/qdlt/tests/CMakeLists.txt @@ -8,3 +8,8 @@ target_link_libraries( qdlt ) +add_test( + NAME test_tools + COMMAND $ +) + diff --git a/scripts/linux/install.sh b/scripts/linux/install.sh index dc6c2e1d..6bff11ea 100755 --- a/scripts/linux/install.sh +++ b/scripts/linux/install.sh @@ -23,7 +23,7 @@ sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt update sudo apt install -y git cmake build-essential ninja-build \ qt515declarative qt515serialport qt515charts-no-lgpl qt515svg \ - libgtk2.0-dev libgl-dev gcc-11 g++-11 + libgtk2.0-dev libgl-dev gcc-11 g++-11 libgtest-dev sudo update-alternatives --remove-all cpp sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-11 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-11 --slave /usr/bin/cpp cpp /usr/bin/cpp-11 From d492945a3cbedebfc8fc8bb20d14a98926df21fd Mon Sep 17 00:00:00 2001 From: Viktor Kopp Date: Mon, 16 Sep 2024 21:31:14 +0200 Subject: [PATCH 2/3] Run tests upon Linux build on CI Signed-off-by: Viktor Kopp --- .github/workflows/BuildPR.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/BuildPR.yml b/.github/workflows/BuildPR.yml index c5b1e0de..d399e8ef 100644 --- a/.github/workflows/BuildPR.yml +++ b/.github/workflows/BuildPR.yml @@ -124,6 +124,8 @@ jobs: run: scripts/linux/install.sh - name: Build project run: scripts/linux/build.sh + - name: Run tests + run: ctest --test-dir build/qdlt - name: Make artifact executable run: chmod -R +x build/dist - name: Archive artifact From 9a6484bf272c4da791c7bed9068f24db5f84e982 Mon Sep 17 00:00:00 2001 From: Viktor Kopp Date: Mon, 16 Sep 2024 21:51:08 +0200 Subject: [PATCH 3/3] Accelerate linux build Signed-off-by: Viktor Kopp --- scripts/linux/build.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/linux/build.sh b/scripts/linux/build.sh index 42ce0dca..3c36089b 100755 --- a/scripts/linux/build.sh +++ b/scripts/linux/build.sh @@ -9,6 +9,9 @@ BUILD_DIR="${SRC_DIR}/build" INSTALL_DIR="${BUILD_DIR}/install" APP_DIR_NAME="DLTViewer" +NPROC=$(nproc) +echo Nb of cpus: ${NPROC} + rm -rf "${APP_DIR_NAME}" rm -rf "${SRC_DIR}/build" mkdir -p "${BUILD_DIR}" @@ -16,7 +19,7 @@ cd "${BUILD_DIR}" echo Build with QMake qmake ../BuildDltViewer.pro -make +make -j ${NPROC} echo Cleanup rm -rf "${INSTALL_DIR}" @@ -37,7 +40,7 @@ cmake -G Ninja \ -DDLT_RESOURCE_INSTALLATION_PATH="${APP_DIR_NAME}/usr/share" \ -DDLT_PLUGIN_INSTALLATION_PATH="${APP_DIR_NAME}/usr/bin/plugins" \ "${SRC_DIR}" -cmake --build "${BUILD_DIR}" -v +cmake --build "${BUILD_DIR}" -j ${NPROC} -v # External CPack generator calls "cmake --install" and "linuxdeploy" #