Update main.yml #5
This file contains hidden or 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: CI | |
on: | |
push: | |
branches: [ main, dev ] | |
pull_request: | |
branches: [ main, dev ] | |
jobs: | |
build-and-test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# Linux + GCC | |
- os: ubuntu-latest | |
compiler: gcc | |
cc: gcc | |
cxx: g++ | |
# Linux + Clang | |
- os: ubuntu-latest | |
compiler: clang | |
cc: clang | |
cxx: clang++ | |
# Windows + MSVC | |
- os: windows-latest | |
compiler: msvc | |
cc: cl | |
cxx: cl | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install prerequisites (Linux) | |
if: matrix.os == 'ubuntu-latest' | |
run: sudo apt-get update && sudo apt-get install -y build-essential cmake ccache | |
- name: Cache ccache | |
uses: actions/cache@v3 | |
with: | |
path: ~/.ccache | |
key: ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ hashFiles('**/CMakeLists.txt') }} | |
restore-keys: | | |
${{ runner.os }}-ccache-${{ matrix.compiler }}- | |
- name: Cache CMake build | |
uses: actions/cache@v3 | |
with: | |
path: build | |
key: ${{ runner.os }}-cmake-${{ matrix.compiler }}-${{ hashFiles('**/CMakeLists.txt') }} | |
restore-keys: | | |
${{ runner.os }}-cmake-${{ matrix.compiler }}- | |
- name: Configure with CMake | |
run: | | |
mkdir -p build | |
cd build | |
cmake \ | |
-DCMAKE_C_COMPILER=${{ matrix.cc }} \ | |
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
.. | |
- name: Build | |
run: cmake --build build --config Release -- -j$(nproc || echo 2) | |
- name: Run unit tests | |
run: | | |
cd build | |
ctest --output-on-failure --parallel $(nproc || echo 2) | |
- name: Upload test logs on failure | |
if: failure() | |
uses: actions/upload-artifact@v3.1.0 | |
with: | |
name: ctest-logs-${{ matrix.os }}-{{ matrix.compiler }} | |
path: build/Testing/**/Test.xml |