Skip to content

Commit

Permalink
[test] Another attempt at CI
Browse files Browse the repository at this point in the history
Cribbed from https://github.com/alexreinking/so69978314/
But this still doesn't seem to work on Windows!
  • Loading branch information
Quuxplusone committed Oct 19, 2023
1 parent 6309755 commit bdced19
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 27 deletions.
51 changes: 37 additions & 14 deletions .github/workflows/build-and-run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
26 changes: 13 additions & 13 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit bdced19

Please sign in to comment.