Skip to content

Commit

Permalink
🔨 [CI] Improved script using a matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
JulesFouchy committed Jan 15, 2024
1 parent 81ed240 commit 8369c6e
Showing 1 changed file with 54 additions and 239 deletions.
293 changes: 54 additions & 239 deletions .github/workflows/build_and_run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,269 +3,84 @@ name: Build and run tests
on:
push:
branches: [main]

pull_request:
branches: [main]

env:
EXE-TARGET: Coollab
TESTS-TARGET: Tests-Coollab
target: Tests-Coollab

jobs:
#-----------------------------------------------------------------------------------------------
Windows_MSVC_Debug:
name: Windows MSVC Debug
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Configure CMake
run: cmake -B ${{github.workspace}}\build -DWARNINGS_AS_ERRORS_FOR_COOLLAB=ON -D CMAKE_C_COMPILER=cl -D CMAKE_CXX_COMPILER=cl -D COOLLAB_REQUIRE_ALL_FEATURES=ON

- name: Build exe
run: cmake --build ${{github.workspace}}\build --config Debug --target ${{env.EXE-TARGET}}

- name: Build tests
run: cmake --build ${{github.workspace}}\build --config Debug --target ${{env.TESTS-TARGET}}

- name: Run tests
run: ${{github.workspace}}\build\bin\Debug\${{env.TESTS-TARGET}}.exe

#-----------------------------------------------------------------------------------------------
Windows_MSVC_Release:
name: Windows MSVC Release
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Configure CMake
run: cmake -B ${{github.workspace}}\build -DWARNINGS_AS_ERRORS_FOR_COOLLAB=ON -D CMAKE_C_COMPILER=cl -D CMAKE_CXX_COMPILER=cl -D COOLLAB_REQUIRE_ALL_FEATURES=ON
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=clang -D CMAKE_CXX_COMPILER=clang++ -D OPENSSL_ROOT_DIR=/usr/local/opt/openssl -D OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include,
}
build_type:
- Debug
- Release

- name: Build exe
run: cmake --build ${{github.workspace}}\build --config Release --target ${{env.EXE-TARGET}}

- name: Build tests
run: cmake --build ${{github.workspace}}\build --config Release --target ${{env.TESTS-TARGET}}

- name: Run tests
run: ${{github.workspace}}\build\bin\Release\${{env.TESTS-TARGET}}.exe

#-----------------------------------------------------------------------------------------------
Windows_Clang_Debug:
name: Windows Clang Debug
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Configure CMake
run: cmake -B ${{github.workspace}}\build -DWARNINGS_AS_ERRORS_FOR_COOLLAB=ON -T ClangCL -D COOLLAB_REQUIRE_ALL_FEATURES=ON

- name: Build exe
run: cmake --build ${{github.workspace}}\build --config Debug --target ${{env.EXE-TARGET}}

- name: Build tests
run: cmake --build ${{github.workspace}}\build --config Debug --target ${{env.TESTS-TARGET}}

- name: Run tests
run: ${{github.workspace}}\build\bin\Debug\${{env.TESTS-TARGET}}.exe

#-----------------------------------------------------------------------------------------------
Windows_Clang_Release:
name: Windows Clang Release
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Configure CMake
run: cmake -B ${{github.workspace}}\build -DWARNINGS_AS_ERRORS_FOR_COOLLAB=ON -T ClangCL -D COOLLAB_REQUIRE_ALL_FEATURES=ON

- name: Build exe
run: cmake --build ${{github.workspace}}\build --config Release --target ${{env.EXE-TARGET}}

- name: Build tests
run: cmake --build ${{github.workspace}}\build --config Release --target ${{env.TESTS-TARGET}}

- name: Run tests
run: ${{github.workspace}}\build\bin\Release\${{env.TESTS-TARGET}}.exe

#-----------------------------------------------------------------------------------------------
Linux_GCC_Debug:
name: Linux GCC Debug
runs-on: ubuntu-latest
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: Configure CMake
run: cmake -B ${{github.workspace}}/build -DWARNINGS_AS_ERRORS_FOR_COOLLAB=ON -D CMAKE_BUILD_TYPE=Debug -D CMAKE_C_COMPILER=gcc -D CMAKE_CXX_COMPILER=g++ -D COOLLAB_REQUIRE_ALL_FEATURES=ON

- name: Build exe
run: cmake --build ${{github.workspace}}/build --config Debug --target ${{env.EXE-TARGET}}

- name: Build tests
run: cmake --build ${{github.workspace}}/build --config Debug --target ${{env.TESTS-TARGET}}

- name: Run tests
run: ${{github.workspace}}/build/bin/${{env.TESTS-TARGET}}

#-----------------------------------------------------------------------------------------------
Linux_GCC_Release:
name: Linux GCC Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
submodules: recursive

- name: Update apt-get
run: sudo apt-get update -y

- name: Install glfw dependencies
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
run: sudo apt-get install libssl-dev

- name: Install audio libraries
run: sudo apt install libpulse-dev libasound2-dev

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DWARNINGS_AS_ERRORS_FOR_COOLLAB=ON -D CMAKE_BUILD_TYPE=Release -D CMAKE_C_COMPILER=gcc -D CMAKE_CXX_COMPILER=g++ -D COOLLAB_REQUIRE_ALL_FEATURES=ON

- name: Build exe
run: cmake --build ${{github.workspace}}/build --config Release --target ${{env.EXE-TARGET}}

- name: Build tests
run: cmake --build ${{github.workspace}}/build --config Release --target ${{env.TESTS-TARGET}}

- name: Run tests
run: ${{github.workspace}}/build/bin/${{env.TESTS-TARGET}}
key: ${{ matrix.config.name }}-${{ matrix.build_type }}

#-----------------------------------------------------------------------------------------------
Linux_Clang_Debug:
name: Linux Clang Debug
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Update apt-get
run: sudo apt-get update -y

- name: Install glfw dependencies
run: sudo apt-get install -y libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev mesa-common-dev build-essential libgtk-3-dev

- name: Install audio libraries
run: sudo apt install libpulse-dev libasound2-dev

- name: Install OpenSSL
run: sudo apt-get install libssl-dev

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DWARNINGS_AS_ERRORS_FOR_COOLLAB=ON -D CMAKE_BUILD_TYPE=Debug -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++ -D COOLLAB_REQUIRE_ALL_FEATURES=ON

- name: Build exe
run: cmake --build ${{github.workspace}}/build --config Debug --target ${{env.EXE-TARGET}}

- name: Build tests
run: cmake --build ${{github.workspace}}/build --config Debug --target ${{env.TESTS-TARGET}}

- name: Run tests
run: ${{github.workspace}}/build/bin/${{env.TESTS-TARGET}}

#-----------------------------------------------------------------------------------------------
Linux_Clang_Release:
name: Linux Clang Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Update apt-get
run: sudo apt-get update -y

- name: Install glfw dependencies
run: sudo apt-get install -y libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev mesa-common-dev build-essential libgtk-3-dev

- name: Install audio libraries
run: sudo apt install libpulse-dev libasound2-dev

- name: Install OpenSSL
run: sudo apt-get install libssl-dev

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DWARNINGS_AS_ERRORS_FOR_COOLLAB=ON -D CMAKE_BUILD_TYPE=Release -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++ -D COOLLAB_REQUIRE_ALL_FEATURES=ON

- name: Build exe
run: cmake --build ${{github.workspace}}/build --config Release --target ${{env.EXE-TARGET}}

- name: Build tests
run: cmake --build ${{github.workspace}}/build --config Release --target ${{env.TESTS-TARGET}}

- name: Run tests
run: ${{github.workspace}}/build/bin/${{env.TESTS-TARGET}}

#-----------------------------------------------------------------------------------------------
MacOS_Clang_Debug:
name: MacOS Clang Debug
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Build
uses: lukka/run-cmake@v3
with:
submodules: recursive

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DWARNINGS_AS_ERRORS_FOR_COOLLAB=ON -D CMAKE_BUILD_TYPE=Debug -D CMAKE_C_COMPILER=$(brew --prefix llvm@15)/bin/clang -D CMAKE_CXX_COMPILER=$(brew --prefix llvm@15)/bin/clang++ -D COOLLAB_REQUIRE_ALL_FEATURES=ON -D OPENSSL_ROOT_DIR=/usr/local/opt/openssl -D OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include

- name: Build exe
run: cmake --build ${{github.workspace}}/build --config Debug --target ${{env.EXE-TARGET}}

- name: Build tests
run: cmake --build ${{github.workspace}}/build --config Debug --target ${{env.TESTS-TARGET}}

- name: Run tests
run: ${{github.workspace}}/build/bin/${{env.TESTS-TARGET}}

#-----------------------------------------------------------------------------------------------
MacOS_Clang_Release:
name: MacOS Clang Release
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DWARNINGS_AS_ERRORS_FOR_COOLLAB=ON -D CMAKE_BUILD_TYPE=Release -D CMAKE_C_COMPILER=$(brew --prefix llvm@15)/bin/clang -D CMAKE_CXX_COMPILER=$(brew --prefix llvm@15)/bin/clang++ -D COOLLAB_REQUIRE_ALL_FEATURES=ON -D OPENSSL_ROOT_DIR=/usr/local/opt/openssl -D OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include

- name: Build exe
run: cmake --build ${{github.workspace}}/build --config Release --target ${{env.EXE-TARGET}}

- name: Build tests
run: cmake --build ${{github.workspace}}/build --config Release --target ${{env.TESTS-TARGET}}

- name: Run tests
run: ${{github.workspace}}/build/bin/${{env.TESTS-TARGET}}
cmakeListsTxtPath: ${{ github.workspace }}/tests/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}}

0 comments on commit 8369c6e

Please sign in to comment.