Skip to content

Commit

Permalink
Move Catch2 from git submodule to CMake fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
Bronek committed Apr 16, 2024
1 parent 09de0b6 commit bb6f7ca
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 17 deletions.
30 changes: 20 additions & 10 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -29,15 +29,17 @@ jobs:
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
..
- name: build all targets
shell: bash
run: |
pushd ${build_dir}
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 }}
Expand All @@ -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: |
Expand All @@ -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: |
Expand All @@ -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: |
Expand All @@ -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 }}
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
11 changes: 11 additions & 0 deletions cmake/Catch2.cmake
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion cmake/MarketCov.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
1 change: 0 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 0 additions & 1 deletion third_party/catch2
Submodule catch2 deleted from 182c91

0 comments on commit bb6f7ca

Please sign in to comment.