Skip to content

Commit

Permalink
Merge pull request #78 from fktn-k/feature/77_run_sanitizer_on_sh_runner
Browse files Browse the repository at this point in the history
#77 Run sanitizer only on self-hosted runners
  • Loading branch information
fktn-k committed Sep 17, 2023
2 parents 492cc80 + ffb563b commit 9340121
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
submodules: recursive

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build_${{matrix.build_type}} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DFK_YAML_DEFAULT_CI=ON -DFK_YAML_RUN_SANITIZERS=OFF
run: cmake -B ${{github.workspace}}/build_${{matrix.build_type}} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DFK_YAML_DEFAULT_CI=ON

- name: Build
run: cmake --build ${{github.workspace}}/build_${{matrix.build_type}} --config ${{matrix.build_type}}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
submodules: recursive

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build_${{matrix.build_type}} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DFK_YAML_DEFAULT_CI=ON -DFK_YAML_RUN_SANITIZERS=ON
run: cmake -B ${{github.workspace}}/build_${{matrix.build_type}} -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DFK_YAML_DEFAULT_CI=ON

- name: Build
run: cmake --build ${{github.workspace}}/build_${{matrix.build_type}} --config ${{matrix.build_type}}
Expand Down Expand Up @@ -63,6 +63,7 @@ jobs:
- ci_test_clang++_c++17
- ci_test_clang++_c++20
- ci_test_clang++_c++23
- ci_test_clang++_sanitizer

steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
submodules: recursive

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DFK_YAML_DEFAULT_CI=ON -DFK_YAML_RUN_SANITIZERS=OFF
run: cmake -B ${{github.workspace}}/build -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DFK_YAML_DEFAULT_CI=ON

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}}
Expand All @@ -46,7 +46,7 @@ jobs:
submodules: recursive

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DFK_YAML_DEFAULT_CI=ON -DFK_YAML_RUN_SANITIZERS=OFF
run: cmake -B ${{github.workspace}}/build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DFK_YAML_DEFAULT_CI=ON

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{matrix.build_type}}
Expand Down
16 changes: 3 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ else()
set(FK_YAML_BUILD_TEST_INIT OFF)
endif()

if(FK_YAML_RUN_SANITIZERS)
set(FK_YAML_RUN_SANITIZERS_INIT ON)
else()
set(FK_YAML_RUN_SANITIZERS_INIT OFF)
endif()

if(FK_YAML_CODE_COVERAGE)
# Code coverage data depends on unit test app.
# So force build it.
Expand Down Expand Up @@ -74,18 +68,14 @@ if(FK_YAML_DEFAULT_CI OR FK_YAML_CUSTOM_CI)
endif()

option(FK_YAML_BuildTests "Build the unit tests when FK_YAML_BUILD_TEST is enabled or if this library is the main target." ${FK_YAML_BUILD_TEST_INIT})
option(FK_YAML_RunSanitizers "Build the unit tests with sanitizers if FK_YAML_RUN_SANITIZERS is enabled." ${FK_YAML_RUN_SANITIZERS_INIT})
option(FK_YAML_GenerateCoverage "Build the unit tests with code coverage data if FK_YAML_CODE_COVERAGE is enabled." ${FK_YAML_CODE_COVERAGE_INIT})
option(FK_YAML_Install "Install CMake targets during install step." ${FK_YAML_IS_MAIN_PROJECT})
option(FK_YAML_RunDoxygen "Generate API documentation with doxygen." ${FK_YAML_RUN_DOXYGEN_INIT})
option(FK_YAML_RunClangFormat "Run clang-format when FK_YAML_RUN_CLANG_FORMAT is enabled or if this library is the main target." ${FK_YAML_RUN_CLANG_FORMAT_INIT})
option(FK_YAML_RunClangTidy "Run clang-tidy when FK_YAML_RUN_CLANG_TIDY is enabled or if this library is the main target." ${FK_YAML_RUN_CLANG_TIDY_INIT})

if(FK_YAML_BuildTests OR FK_YAML_RunClangFormat OR FK_YAML_RunClangTidy OR FK_YAML_CUSTOM_CI)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if(FK_YAML_BuildTests)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/catch2/contrib")
endif()
if(FK_YAML_RunClangFormat OR FK_YAML_CUSTOM_CI)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
endif()

if(FK_YAML_GenerateCoverage)
Expand Down Expand Up @@ -168,9 +158,9 @@ add_custom_target(build_library ALL DEPENDS ${FK_YAML_TARGET_NAME})

if(FK_YAML_BuildTests)
set(CATCH2_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/catch2")
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CATCH2_ROOT_DIR}/contrib")
add_subdirectory(${CATCH2_ROOT_DIR})
include(CTest)
include(AddSanitizers)
enable_testing()
add_subdirectory(test)
endif()
Expand Down
41 changes: 0 additions & 41 deletions cmake/AddSanitizers.cmake

This file was deleted.

18 changes: 17 additions & 1 deletion cmake/ci.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,20 @@ foreach(TARGET_CXX_STANDARD 11 14 17 20 23)
COMMAND cd ${PROJECT_BINARY_DIR}/build_g++_c++${TARGET_CXX_STANDARD} && ${CMAKE_CTEST_COMMAND} -C Debug --output-on-failure
COMMENT "Compile and test with g++ for C++${CXX_STANDARD}"
)
endforeach()
endforeach()

##############################################
# Execute unit tests with clang sanitizers #
##############################################

set(CLANGXX_SANITIZER_FLAGS
"-g -O1 -fno-omit-frame-pointer -fsanitize=address,undefined,bounds,integer,nullability -fno-sanitize-recover=all -fno-sanitize=unsigned-integer-overflow,unsigned-shift-base")

add_custom_target(ci_test_clang++_sanitizer
COMMAND CXX=${CLANGXX_TOOL} CXXFLAGS=${CLANGXX_SANITIZER_FLAGS} ${CMAKE_COMMAND}
-DCMAKE_BUILD_TYPE=Debug -GNinja -DFK_YAML_CUSTOM_CI=ON
-S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_clang++_sanitizer
COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_clang++_sanitizer --config Debug
COMMAND cd ${PROJECT_BINARY_DIR}/build_clang++_sanitizer && ${CMAKE_CTEST_COMMAND} -C Debug --output-on-failure
COMMENT "Compile and test with clang++ & sanitizers"
)
2 changes: 0 additions & 2 deletions test/unit_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ if("${FK_YAML_TestTargetCxxStandard}" STREQUAL "")
set(FK_YAML_TestTargetCxxStandard 11)
endif()

add_sanitizer_flags(${FK_YAML_RunSanitizers})

set(TEST_TARGET "fkYAMLUnitTest")

add_executable(${TEST_TARGET}
Expand Down

0 comments on commit 9340121

Please sign in to comment.