From 91eab5739679e4e90a1ea70ddd25a6b07d6c4c12 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Fri, 6 Jan 2023 06:23:32 -0500 Subject: [PATCH 1/4] Adding in a action file from cmake example The purpose of this is to run the tests automatically to prevent regression. --- .github/workflows/tests.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..fb9fd1e --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,29 @@ +name: Libdbc Tests + +on: + push: + branches: [ "master" ] + pull_request: + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Configure CMake + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + + - name: Build + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Test + working-directory: ${{github.workspace}}/build + # Didn't configure to use ctest. Opted for a custom target to run instead + run: cmake --build build --target test + From aad6fa2eb01ff5004373a396dee22cd7048bf915 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Fri, 6 Jan 2023 07:17:43 -0500 Subject: [PATCH 2/4] Removing submodule of Catch2. Opting for Cmake FetchContent --- .gitmodules | 3 --- test/CMakeLists.txt | 12 ++++++++++-- third_party/Catch2 | 1 - 3 files changed, 10 insertions(+), 6 deletions(-) delete mode 160000 third_party/Catch2 diff --git a/.gitmodules b/.gitmodules index 61932e2..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "third_party/Catch2"] - path = third_party/Catch2 - url = https://github.com/catchorg/Catch2.git diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3d2cbe2..d08b404 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,12 +1,20 @@ project(tests VERSION 0.1.0) +# Download and build Catch2 test framework +Include(FetchContent) +FetchContent_Declare( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG v3.2.1 +) +FetchContent_MakeAvailable(Catch2) + list(APPEND TEST_SOURCES main.cpp test_dbc.cpp test_utils.cpp) -include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/third_party/Catch2/single_include) - add_executable(tests ${TEST_SOURCES} ${SOURCE}) +target_link_libraries(tests PRIVATE Catch2::Catch2WithMain) add_custom_target(test COMMAND ${PROJECT_NAME} diff --git a/third_party/Catch2 b/third_party/Catch2 deleted file mode 160000 index de6fe18..0000000 --- a/third_party/Catch2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit de6fe184a9ac1a06895cdd1c9b437f0a0bdf14ad From 0292ab706d8edac8747faac67df199ae512b9508 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Fri, 6 Jan 2023 07:43:20 -0500 Subject: [PATCH 3/4] Fixing the Catch2 upgrade to v3, removed old catch main, updated action to use all cores --- .github/workflows/tests.yml | 4 ++-- test/CMakeLists.txt | 2 +- test/main.cpp | 2 -- test/test_dbc.cpp | 2 +- test/test_utils.cpp | 2 +- 5 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 test/main.cpp diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fb9fd1e..c04f2fa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,10 +20,10 @@ jobs: run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -- -j - name: Test working-directory: ${{github.workspace}}/build # Didn't configure to use ctest. Opted for a custom target to run instead - run: cmake --build build --target test + run: cmake --build build --target test -- -j diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d08b404..d7d18f9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -9,7 +9,7 @@ FetchContent_Declare( ) FetchContent_MakeAvailable(Catch2) -list(APPEND TEST_SOURCES main.cpp +list(APPEND TEST_SOURCES test_dbc.cpp test_utils.cpp) diff --git a/test/main.cpp b/test/main.cpp deleted file mode 100644 index afeca98..0000000 --- a/test/main.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file -#include diff --git a/test/test_dbc.cpp b/test/test_dbc.cpp index 55c4a14..9393488 100644 --- a/test/test_dbc.cpp +++ b/test/test_dbc.cpp @@ -1,4 +1,4 @@ -#include +#include #include "defines.hpp" #include diff --git a/test/test_utils.cpp b/test/test_utils.cpp index 39f623e..37aab50 100644 --- a/test/test_utils.cpp +++ b/test/test_utils.cpp @@ -1,4 +1,4 @@ -#include +#include #include "defines.hpp" #include From d4ae428520e25ed7c586e8dd1edd519aee2e4a50 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Fri, 6 Jan 2023 07:48:17 -0500 Subject: [PATCH 4/4] Fixing missing github workspace env --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c04f2fa..3bc437c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,5 +25,5 @@ jobs: - name: Test working-directory: ${{github.workspace}}/build # Didn't configure to use ctest. Opted for a custom target to run instead - run: cmake --build build --target test -- -j + run: cmake --build ${{github.workspace}}/build --target test -- -j