From bb6f7ca00f36d9a70824d29d7798f33615c6684e Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Tue, 16 Apr 2024 12:23:51 +0100 Subject: [PATCH] Move Catch2 from git submodule to CMake fetch --- .github/workflows/action.yml | 30 ++++++++++++++++++++---------- .gitmodules | 4 ---- CMakeLists.txt | 1 + cmake/Catch2.cmake | 11 +++++++++++ cmake/MarketCov.cmake | 2 +- tests/CMakeLists.txt | 1 - third_party/catch2 | 1 - 7 files changed, 33 insertions(+), 17 deletions(-) delete mode 100644 .gitmodules create mode 100644 cmake/Catch2.cmake delete mode 160000 third_party/catch2 diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml index 63ef194..5a56b5e 100644 --- a/.github/workflows/action.yml +++ b/.github/workflows/action.yml @@ -14,11 +14,11 @@ jobs: runs-on: ubuntu-latest env: build_dir: .build + steps: - name: checkout - uses: actions/checkout@v3 - with: - submodules: true + uses: actions/checkout@v4 + - name: configure shell: bash run: | @@ -29,6 +29,7 @@ jobs: -DCMAKE_C_COMPILER=gcc \ -DCMAKE_CXX_COMPILER=g++ \ .. + - name: build all targets shell: bash run: | @@ -36,8 +37,9 @@ jobs: cmake --build . --target all popd mv ${build_dir}/tests/tests ./tests-${{ matrix.configuration }} + - name: upload tests binary - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: tests-${{ matrix.configuration }} path: tests-${{ matrix.configuration }} @@ -55,17 +57,20 @@ jobs: runs-on: ubuntu-latest env: build_dir: .build + steps: - name: download tests binary - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: tests-${{ matrix.configuration }} + - name: prepare tests location shell: bash run: | mkdir ${build_dir} mv ./tests-${{ matrix.configuration }} ${build_dir}/tests chmod 755 ${build_dir}/tests + - name: run tests shell: bash run: | @@ -82,14 +87,15 @@ jobs: runs-on: ubuntu-latest env: build_dir: .build + steps: - name: checkout - uses: actions/checkout@v3 - with: - submodules: true + uses: actions/checkout@v4 + - name: install gcovr shell: bash run: pip install "gcovr>=7,<8" + - name: configure shell: bash run: | @@ -102,11 +108,13 @@ jobs: -DCODE_COVERAGE=True \ -DCODE_COVERAGE_REPORT_FORMAT=lcov \ .. + - name: build all targets shell: bash run: | cd ${build_dir} cmake --build . --target all + - name: prepare coverage report shell: bash run: | @@ -115,18 +123,20 @@ jobs: popd mv ${build_dir}/coverage.lcov coverage.lcov cat coverage.lcov + - name: archive coverage report uses: actions/upload-artifact@v4 with: name: coverage.lcov path: coverage.lcov if-no-files-found: error + - name: upload coverage report - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v4.3.0 with: files: coverage.lcov fail_ci_if_error: true disable_search: true verbose: true - plugin: gcov + plugin: noop token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 2a94ca8..0000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "third_party/catch2"] - path = third_party/catch2 - url = git@github.com:catchorg/Catch2.git - branch = v2.x diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fb0003..79068cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,5 +17,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra -Wpedantic") add_subdirectory(libs) +include(Catch2) enable_testing() add_subdirectory(tests) diff --git a/cmake/Catch2.cmake b/cmake/Catch2.cmake new file mode 100644 index 0000000..dd4ca2e --- /dev/null +++ b/cmake/Catch2.cmake @@ -0,0 +1,11 @@ +include(FetchContent) + +FetchContent_Declare( + Catch2 + GIT_SHALLOW TRUE + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG v2.13.10) + +FetchContent_MakeAvailable(Catch2) + +list(APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/extras) diff --git a/cmake/MarketCov.cmake b/cmake/MarketCov.cmake index 6dd9d29..e76b791 100644 --- a/cmake/MarketCov.cmake +++ b/cmake/MarketCov.cmake @@ -19,7 +19,7 @@ if (CODE_COVERAGE) FORMAT ${CODE_COVERAGE_FORMAT} EXECUTABLE tests EXECUTABLE_ARGS -r console - EXCLUDE "tests" "third_party" + EXCLUDE "tests" "${CMAKE_BINARY_DIR}" DEPENDENCIES tests ) endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f256b00..ea02d59 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -10,7 +10,6 @@ set(SOURCE_FILES main.cpp market.cpp utils.cpp book.cpp) add_executable(${PROJECT_NAME} ${SOURCE_FILES}) -add_subdirectory(${PROJECT_SOURCE_DIR}/catch2) target_link_libraries(${PROJECT_NAME} libs Catch2::Catch2) add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME} -r junit) diff --git a/third_party/catch2 b/third_party/catch2 deleted file mode 160000 index 182c910..0000000 --- a/third_party/catch2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 182c910b4b63ff587a3440e08f84f70497e49a81