🔨 [CI] Improved script using a matrix #981
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and run tests | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
env: | |
target: Tests-Coollab | |
jobs: | |
build-and-run-tests: | |
name: ${{ matrix.config.name }} ${{ matrix.build_type }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
name: Windows MSVC, | |
os: windows-latest, | |
compiler: -D CMAKE_C_COMPILER=cl -D CMAKE_CXX_COMPILER=cl, | |
} | |
- { name: Windows Clang, os: windows-latest, compiler: -T ClangCL } | |
- { | |
name: Linux Clang, | |
os: ubuntu-latest, | |
compiler: -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++, | |
} | |
- { | |
name: Linux GCC, | |
os: ubuntu-latest, | |
compiler: -D CMAKE_C_COMPILER=gcc -D CMAKE_CXX_COMPILER=g++, | |
} | |
- { | |
name: MacOS Clang, | |
os: macos-latest, | |
compiler: -D CMAKE_C_COMPILER=$(brew --prefix llvm@15)/bin/clang -D CMAKE_CXX_COMPILER=$(brew --prefix llvm@15)/bin/clang++ -D OPENSSL_ROOT_DIR=/usr/local/opt/openssl -D OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include, | |
} | |
build_type: | |
- Debug | |
- Release | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Update apt-get | |
if: runner.os == 'Linux' | |
run: sudo apt-get update -y | |
- name: Install glfw dependencies | |
if: runner.os == 'Linux' | |
run: sudo apt-get install -y libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev mesa-common-dev build-essential libgtk-3-dev | |
- name: Install OpenSSL | |
if: runner.os == 'Linux' | |
run: sudo apt-get install libssl-dev | |
- name: Install audio libraries | |
if: runner.os == 'Linux' | |
run: sudo apt install libpulse-dev libasound2-dev | |
- name: Setup ccache | |
uses: hendrikmuhs/ccache-action@v1.2 | |
with: | |
key: ${{ matrix.config.name }}-${{ matrix.build_type }} | |
- name: Build | |
uses: lukka/run-cmake@v3 | |
with: | |
cmakeListsTxtPath: ${{ github.workspace }}/CMakeLists.txt | |
cmakeAppendedArgs: -D WARNINGS_AS_ERRORS_FOR_COOLLAB=ON -D COOLLAB_REQUIRE_ALL_FEATURES=ON -D CMAKE_BUILD_TYPE=${{ matrix.build_type }} ${{ matrix.config.compiler }} -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache | |
buildWithCMakeArgs: --config ${{ matrix.build_type }} --target ${{env.target}} | |
cmakeListsOrSettingsJson: CMakeListsTxtAdvanced | |
cmakeBuildType: ${{ matrix.build_type }} | |
buildDirectory: ${{ github.workspace }}/build | |
- name: Run on Windows | |
if: runner.os == 'Windows' | |
run: ${{github.workspace}}\build\bin\${{ matrix.build_type }}\${{env.target}}.exe | |
- name: Run on Linux and Mac | |
if: runner.os != 'Windows' | |
run: ${{github.workspace}}/build/bin/${{env.target}} |