diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e6a23dd0..09df394e4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -117,6 +117,10 @@ stages: variables: CMAKE_VERSION: "3.13.5" +.warning_policy: + allow_failure: + exit_codes: [ 47 ] + .install_cmake: &install_cmake | export PATH=$PWD/.gitlab/cmake/bin:$PATH .gitlab/ci/config/cmake.sh "$CMAKE_VERSION" @@ -141,8 +145,10 @@ stages: script: - "ctest -VV -S .gitlab/ci/ctest_build.cmake" - sccache --show-stats + - cmake -P .gitlab/ci/check_warnings.cmake || exit 47 extends: - .cmake_build_artifacts + - .warning_policy .cmake_test_linux: &cmake_test_linux stage: test @@ -192,6 +198,7 @@ stages: # CTest and CMake install files. # Note: this also captures our CIState.cmake file - build/CMakeCache.txt + - build/compile_num_warnings.log - build/**/*.cmake - build/Testing/ diff --git a/.gitlab/ci/check_warnings.cmake b/.gitlab/ci/check_warnings.cmake new file mode 100644 index 000000000..0eae9f322 --- /dev/null +++ b/.gitlab/ci/check_warnings.cmake @@ -0,0 +1,31 @@ +##============================================================================= +## +## Copyright (c) Kitware, Inc. +## All rights reserved. +## See LICENSE.txt for details. +## +## This software is distributed WITHOUT ANY WARRANTY; without even +## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +## PURPOSE. See the above copyright notice for more information. +## +##============================================================================= + +# Find the path the logs from the last configure +set(cnf_log_path "${CMAKE_SOURCE_DIR}/build/Testing/Temporary/LastConfigure*.log") +file(GLOB cnf_log_files ${cnf_log_path}) + +foreach(file IN LISTS cnf_log_files) + file(STRINGS ${file} lines) + string(FIND "${lines}" "Warning" line) + if (NOT ${line} EQUAL "-1") + message(FATAL_ERROR "Configure warnings detected, please check cdash-commit job") + endif() +endforeach() + +# `compile_num_warnings` contains a single integer symbolizing the number of +# warnings of the last build. +set(bld_log_path "${CMAKE_SOURCE_DIR}/build/compile_num_warnings.log") +file(STRINGS "${bld_log_path}" output) +if (NOT "${output}" STREQUAL "0") + message(FATAL_ERROR "Build warnings detected, please check cdash-commit job") +endif() diff --git a/.gitlab/ci/ctest_build.cmake b/.gitlab/ci/ctest_build.cmake index 38a55c8c8..0674f550f 100644 --- a/.gitlab/ci/ctest_build.cmake +++ b/.gitlab/ci/ctest_build.cmake @@ -30,11 +30,10 @@ if(NOT DEFINED ENV{GITLAB_CI_EMULATION}) else() ctest_submit(PARTS Build) endif() - - endif() +file(WRITE "${CTEST_BINARY_DIRECTORY}/compile_num_warnings.log" "${num_warnings}") + if (build_result) - message(FATAL_ERROR - "Failed to build") + message(FATAL_ERROR "Failed to build") endif () diff --git a/.gitlab/ci/macos.yml b/.gitlab/ci/macos.yml index bbe134023..e006fadc3 100644 --- a/.gitlab/ci/macos.yml +++ b/.gitlab/ci/macos.yml @@ -56,11 +56,13 @@ test:macos_xcode13: - "ctest -VV -S .gitlab/ci/ctest_configure.cmake" script: - "ctest -VV -S .gitlab/ci/ctest_build.cmake" + - cmake -P .gitlab/ci/check_warnings.cmake || exit 47 after_script: - ccache -v -s - ccache -z extends: - .cmake_build_artifacts + - .warning_policy .cmake_test_macos: stage: test diff --git a/.gitlab/ci/windows10.yml b/.gitlab/ci/windows10.yml index a1e926cc7..888e393d5 100644 --- a/.gitlab/ci/windows10.yml +++ b/.gitlab/ci/windows10.yml @@ -17,7 +17,7 @@ variables: VCVARSALL: "${VS160COMNTOOLS}\\..\\..\\VC\\Auxiliary\\Build\\vcvarsall.bat" VCVARSPLATFORM: "x64" - VCVARSVERSION: "14.25" + VCVARSVERSION: "14.28.29333" .cmake_build_windows: &cmake_build_windows extends: @@ -40,6 +40,8 @@ - "ctest -VV -S .gitlab/ci/ctest_configure.cmake" script: - "ctest -VV -S .gitlab/ci/ctest_build.cmake" + - "cmake -P .gitlab/ci/check_warnings.cmake" + - if (!$?) { $host.SetShouldExit(47); exit 47 } after_script: # This is needed since sometimes this process hangs holding files # in the build directory. Blocking new builds @@ -58,6 +60,7 @@ # CTest and CMake install files. # Note: this also captures our CIState.cmake file - build/CMakeCache.txt + - build/compile_num_warnings.log - build/**/*.cmake - build/Testing/ @@ -98,6 +101,7 @@ build:windows_vs2019: extends: - .cmake_build_windows - .run_automatically + - .warning_policy variables: CMAKE_GENERATOR: "Ninja" CMAKE_BUILD_TYPE: Release