Extended CI workflow to support MacOS and Windows

This commit is contained in:
Stefan Hillmich 2022-09-12 09:26:01 +02:00
parent 82ac083886
commit ddd5cefb8b

View File

@ -2,9 +2,9 @@ name: CMake
on: on:
push: push:
branches: [ master ] branches: [ master, main ]
pull_request: pull_request:
branches: [ master ] branches: [ master, main ]
workflow_dispatch: workflow_dispatch:
env: env:
@ -12,33 +12,47 @@ env:
BUILD_TYPE: Release BUILD_TYPE: Release
jobs: jobs:
build: build-ubuntu:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ${{matrix.os}}
strategy: strategy:
matrix: matrix:
os: [ubuntu-18.04] os: [ ubuntu-18.04, ubuntu-20.04, ubuntu-22.04 ]
compiler: [g++-7, g++-9, g++-10, clang++] compiler: [ g++-7, g++-9, g++-10, clang++ ]
name: Build and Test on Ubuntu
runs-on: ${{matrix.os}}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Configure CMake
run: cmake -S "${{github.workspace}}" -B "${{github.workspace}}/build" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_COMPILER=${{matrix.compiler}}
- name: Build
run: cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE
- name: Test
working-directory: ${{github.workspace}}/build/test
run: ctest -C $BUILD_TYPE --output-on-failure
- name: Configure CMake build-macos:
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. name: Build and Test on MacOS
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type runs-on: macos-latest
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_CXX_COMPILER=${{matrix.compiler}} steps:
- uses: actions/checkout@v3
- name: Configure CMake
run: cmake -S "${{github.workspace}}" -B "${{github.workspace}}/build" -DCMAKE_BUILD_TYPE=$BUILD_TYPE
- name: Build
run: cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE
- name: Test
working-directory: ${{github.workspace}}/build/test
shell: bash
run: ctest -C $BUILD_TYPE --output-on-failure
- name: Build build-windows:
# Build your program with the given configuration name: Build and Test on Windows
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} runs-on: windows-latest
steps:
- name: Test - uses: actions/checkout@v3
working-directory: ${{github.workspace}}/build - uses: ilammy/msvc-dev-cmd@v1
# Execute tests defined by the CMake configuration. - name: Configure CMake
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail run: cmake -S "${{github.workspace}}" -B "${{github.workspace}}/build" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -T "ClangCl"
run: ctest -C ${{env.BUILD_TYPE}} - name: Build
run: cmake --build "${{github.workspace}}/build" --config $BUILD_TYPE
- name: Test
working-directory: ${{github.workspace}}/build/test
run: cd $BUILD_TYPE && ./link_test && ./options_test