From 88043c67070fbc8676b4fb95a5bfa84f5eb2b04e Mon Sep 17 00:00:00 2001 From: Maik Nijhuis <maik.nijhuis@triopsys.nl> Date: Wed, 19 Oct 2022 12:32:41 +0200 Subject: [PATCH] Misc improvements and fixes --- .gitignore | 1 + .gitlab-ci.common.yml | 6 ++---- .gitlab-ci.yml | 24 +++++++++++++++++------- CMakeLists.txt | 1 + test/CMakeLists.txt | 5 ++--- test/{hello.cpp => thello.cpp} | 0 6 files changed, 23 insertions(+), 14 deletions(-) rename test/{hello.cpp => thello.cpp} (100%) diff --git a/.gitignore b/.gitignore index 567609b..6f31401 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ build/ +.vscode/ diff --git a/.gitlab-ci.common.yml b/.gitlab-ci.common.yml index 37762af..8249462 100644 --- a/.gitlab-ci.common.yml +++ b/.gitlab-ci.common.yml @@ -40,13 +40,11 @@ build-docker-ubuntu-22.04: stage: prepare needs: ["versioning"] image: docker:latest + before_script: + - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY script: - | if ! docker manifest inspect $BASE_IMAGE > /dev/null || [ "$BUILD_DOCKER_IMAGE" = "1" ]; then docker build --tag $BASE_IMAGE -f ci/ubuntu_22_04-base . docker push $BASE_IMAGE fi - before_script: - - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY - - diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4b85ed6..ba89283 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,7 @@ include: .gitlab-ci.common.yml -lint: +format: stage: linting needs: ["versioning", "build-docker-ubuntu-22.04"] image: $BASE_IMAGE @@ -13,13 +13,20 @@ lint: - git diff > format.patch # Fail when the patch is not empy (note ! can't be used directly.) - (! grep -q '^--- a' format.patch) + artifacts: + when: on_failure + paths: + - format.patch + +tidy: + stage: linting + needs: ["versioning", "build-docker-ubuntu-22.04"] + image: $BASE_IMAGE + script: - mkdir build - cd build - cmake -DCMAKE_CXX_CLANG_TIDY=clang-tidy -G Ninja .. - ninja - artifacts: - paths: - - format.patch test: stage: test @@ -28,7 +35,7 @@ test: script: - mkdir build - cd build - - cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTINDBUILD_TESTSG=ON -DCMAKE_CXX_FLAGS="-coverage" -DCMAKE_EXE_LINKER_FLAGS="-coverage" -G Ninja .. + - cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON -DCMAKE_CXX_FLAGS="-coverage" -DCMAKE_EXE_LINKER_FLAGS="-coverage" -G Ninja .. - ninja - ctest --output-on-failure |& tee ctest.out - mkdir coverage @@ -57,10 +64,13 @@ build: pages: stage: pages - needs: ["versioning", "build-docker-ubuntu-22.04"] + needs: ["versioning", "test"] image: $BASE_IMAGE script: - - mkdir build + # Generate documentation. - cd build - cmake -DBUILD_DOCUMENTATION=ON -G Ninja .. - ninja sphinx + # Extract HTML coverage report. + - tar xfz coverage.tar.gz + # TODO: Add an index page with links to the documentation and coverage. diff --git a/CMakeLists.txt b/CMakeLists.txt index b03a811..128da29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ option(BUILD_TESTING "Build the test suite" OFF) option(BUILD_DOCUMENTATION "Build the documentation" OFF) add_subdirectory(src) + if(BUILD_TESTING) include(CTest) add_subdirectory(test) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9496c79..7275590 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,11 +6,10 @@ find_package( COMPONENTS unit_test_framework REQUIRED) -add_executable(unittests main.cpp hello.cpp) +add_executable(unittests main.cpp thello.cpp) target_link_libraries(unittests PRIVATE hello Boost::unit_test_framework) add_test( NAME unittests - COMMAND unittests -f JUNIT -k unittests.xml - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIRECTORY}") + COMMAND unittests -f JUNIT -k unittests.xml) diff --git a/test/hello.cpp b/test/thello.cpp similarity index 100% rename from test/hello.cpp rename to test/thello.cpp -- GitLab