From 6666e2f5273bbbabfb2808e86f7d236221d70f0e Mon Sep 17 00:00:00 2001 From: Dennis Klein Date: Thu, 20 May 2021 00:18:25 +0200 Subject: [PATCH] CI: Improve workflow * Test all supported CMake versions * Output CMake version * Test latest CMake version on macOS * Split build into multiple steps * Reduce log noise in test step --- .github/workflows/test.yml | 41 +++++++++++++++++++-------- FairCMakeModules_test.cmake | 56 ++++++++++++++++++++++++++----------- 2 files changed, 69 insertions(+), 28 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d8666ac..51a83b6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,15 +1,34 @@ --- -name: "Run Test suite" +name: Test on: [push, pull_request] jobs: - run-simple-tests: - runs-on: ubuntu-latest + main: + strategy: + matrix: + cmake: ['3.20', '3.19', '3.18', '3.17', '3.16', '3.15'] + os: [ubuntu-latest] + name: [Linux] + include: + - cmake: '3.20' + os: macos-latest + name: macOS + name: ${{ matrix.name }} - CMake ${{ matrix.cmake }} + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - # CMake already installed in /usr/local - Wow - # - name: Install cmake from OS - # run: | - # sudo apt-get install cmake - - name: Run CTest - run: | - ctest -VV -S *_test.cmake + - uses: actions/checkout@v2 + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v1.9 + with: + cmake-version: ${{ matrix.cmake }} + - name: Use cmake + run: cmake --version + - name: Configure + run: ctest -VV -D "STEPS=clean;configure" -S FairCMakeModules_test.cmake + - name: Build + run: ctest -VV -D "STEPS=build" -S FairCMakeModules_test.cmake + - name: Install + run: ctest -VV -D "STEPS=install" -S FairCMakeModules_test.cmake + - name: Test + run: > + ctest -V --output-on-failure -D "STEPS=test" + -S FairCMakeModules_test.cmake diff --git a/FairCMakeModules_test.cmake b/FairCMakeModules_test.cmake index 6ebf659..8d38f37 100644 --- a/FairCMakeModules_test.cmake +++ b/FairCMakeModules_test.cmake @@ -6,26 +6,48 @@ # copied verbatim in the file "LICENSE" # ################################################################################ +cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_policy(VERSION 3.15...3.20) + +if(NOT STEPS) + list(APPEND STEPS clean configure build install test) +endif() + set(CTEST_SOURCE_DIRECTORY .) set(CTEST_BINARY_DIRECTORY build) set(CTEST_CMAKE_GENERATOR "Unix Makefiles") - -ctest_empty_binary_directory("${CTEST_BINARY_DIRECTORY}") -ctest_start(Continuous) - get_filename_component(test_install_prefix "${CTEST_BINARY_DIRECTORY}/install" ABSOLUTE) -list(APPEND options - "-Wdev" - "-Werror=dev" - "-DCMAKE_INSTALL_PREFIX:PATH=${test_install_prefix}" -) -ctest_configure(OPTIONS "${options}") - -ctest_build(TARGET install) -ctest_test(RETURN_VALUE _ctest_test_ret_val) - -if (_ctest_test_ret_val) - message(FATAL_ERROR " \n" - " /!\\ Some tests failed.") + +if(clean IN_LIST STEPS) + file(REMOVE_RECURSE ${CTEST_BINARY_DIRECTORY}) + file(REMOVE_RECURSE ${test_install_prefix}) + ctest_start(Continuous) +else() + ctest_start(Continuous APPEND QUIET) +endif() + +if(configure IN_LIST STEPS) + list(APPEND options + "-Wdev" + "-Werror=dev" + "-DCMAKE_INSTALL_PREFIX:PATH=${test_install_prefix}" + ) + ctest_configure(OPTIONS "${options}") endif() + +if(build IN_LIST STEPS) + ctest_build() +endif() + +if(install IN_LIST STEPS) + ctest_build(TARGET install) +endif() + +if(test IN_LIST STEPS) + ctest_test(RETURN_VALUE __ret) + if(__ret) + message(FATAL_ERROR "Some tests failed.") + endif() +endif() +