Skip to content

Commit

Permalink
CI: Improve workflow
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
dennisklein authored and ChristianTackeGSI committed May 20, 2021
1 parent 15a8f1f commit 6666e2f
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 28 deletions.
41 changes: 30 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
56 changes: 39 additions & 17 deletions FairCMakeModules_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 6666e2f

Please sign in to comment.