From bdced1934f0b97dea47063008cca278da374b834 Mon Sep 17 00:00:00 2001 From: Arthur O'Dwyer Date: Wed, 18 Oct 2023 16:00:17 -0400 Subject: [PATCH] [test] Another attempt at CI Cribbed from https://github.com/alexreinking/so69978314/ But this still doesn't seem to work on Windows! --- .github/workflows/build-and-run-tests.yml | 51 ++++++++++++++++------- test/CMakeLists.txt | 26 ++++++------ 2 files changed, 50 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build-and-run-tests.yml b/.github/workflows/build-and-run-tests.yml index 822c85e..e198a5c 100644 --- a/.github/workflows/build-and-run-tests.yml +++ b/.github/workflows/build-and-run-tests.yml @@ -9,14 +9,17 @@ on: jobs: build: strategy: - fail-fast: true + fail-fast: false matrix: os: [ubuntu-latest, windows-latest] - build_type: [Debug, RelWithDebInfo, Release] - cpp_compiler: [g++, clang++] - cpp_standard: [14, 17, 20, 23] + build_type: [Debug] + cpp_compiler: [g++, clang++, cl] + cpp_standard: [14, 20, 23] exclude: + - os: windows-latest + - os: ubuntu-latest + cpp_compiler: cl - os: ubuntu-latest cpp_compiler: clang++ cpp_standard: 20 @@ -30,20 +33,40 @@ jobs: runs-on: ${{ matrix.os }} + env: + PREFIX: ${{ github.workspace }}/_local + steps: - uses: actions/checkout@v3 - - name: Install Google Test (Linux) - if: matrix.os == 'ubuntu-latest' + - name: Check out GTest + uses: actions/checkout@v3 + with: + repository: google/googletest + ref: f8d7d77c06936315286eb55f8de22cd23c188571 + path: googletest + + - name: Install GTest run: | - sudo apt-get install libgtest-dev + cmake -S googletest -B build/deps/googletest -DCMAKE_BUILD_TYPE=RelWithDebInfo '-DCMAKE_INSTALL_PREFIX=${{ env.PREFIX }}' -DBUILD_SHARED_LIBS=YES + cmake --build build/deps/googletest --config RelWithDebInfo --target install - - name: Build and Test + - name: Build (Linux) + if: matrix.os == 'ubuntu-latest' + working-directory: ${{ github.workspace }} run: | - cmake -S ${{ github.workspace }} -B ${{ github.workspace }}/build \ - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ + cmake . -B ./build -G 'Unix Makefiles' \ -DCMAKE_CXX_STANDARD=${{ matrix.cpp_standard }} \ - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - cd ${{ github.workspace }}/build - make - ./bin/utest + -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} '-DCMAKE_PREFIX_PATH=${{ env.PREFIX }}' + + - name: Build (Windows) + if: matrix.os == 'windows-latest' + working-directory: ${{ github.workspace }} + run: | + cmake . -B ./build -G 'Unix Makefiles' -DCMAKE_CXX_STANDARD=${{ matrix.cpp_standard }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} '-DCMAKE_PREFIX_PATH=${{ env.PREFIX }}' + + - name: Test + working-directory: ${{ github.workspace }}/build + run: | + make VERBOSE=1 && ./bin/utest diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3d34322..c1e08e3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,23 +13,23 @@ set(TEST_SOURCE_FILES unstable_remove_test.cpp ) -set(TEST_NAME utest) -add_executable(${TEST_NAME} ${TEST_SOURCE_FILES}) +add_executable(utest ${TEST_SOURCE_FILES}) include_directories(${GTEST_INCLUDE_DIRS} ${SG14_INCLUDE_DIRECTORY}) -target_link_libraries(${TEST_NAME} ${CMAKE_THREAD_LIBS_INIT} ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}) +target_link_libraries(utest ${CMAKE_THREAD_LIBS_INIT} ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}) # Compile options if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - target_compile_options(${TEST_NAME} PRIVATE -Wall -Wextra -Werror) + target_compile_options(utest PRIVATE -Wall -Wextra -Werror) elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - target_compile_options(${TEST_NAME} PRIVATE -Wall -Wextra -Werror) - if (CMAKE_CXX_COMPILER_VERSION MATCHES "^7.*") - set_source_files_properties(${SG14_TEST_SOURCE_DIRECTORY}/slot_map_test.cpp PROPERTIES - COMPILE_FLAGS "-Wno-error=unused-variable -Wno-error=unused-but-set-variable") # Fix gcc7 issues with structured bindings - message("Disabled -Wunused-variable and -Wunused-but-set-variable for gcc ${CMAKE_CXX_COMPILER_VERSION}.") - endif() + target_compile_options(utest PRIVATE -Wall -Wextra -Werror) + if (CMAKE_CXX_COMPILER_VERSION MATCHES "^7.*") + set_source_files_properties(${SG14_TEST_SOURCE_DIRECTORY}/slot_map_test.cpp PROPERTIES + COMPILE_FLAGS "-Wno-error=unused-variable -Wno-error=unused-but-set-variable" # Fix gcc7 issues with structured bindings + ) + message("Disabled -Wunused-variable and -Wunused-but-set-variable for gcc ${CMAKE_CXX_COMPILER_VERSION}.") + endif() elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${TEST_NAME}) - target_compile_options(${TEST_NAME} PRIVATE /Zc:__cplusplus /permissive- /W4 /WX) - add_definitions(-DNOMINMAX -D_SCL_SECURE_NO_WARNINGS) + set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT utest) + target_compile_options(utest PRIVATE /Zc:__cplusplus /permissive- /W4 /WX) + add_definitions(-DNOMINMAX -D_SCL_SECURE_NO_WARNINGS) endif()