Build and Test ChainedDecos #57
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: CMake on multiple platforms | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| [ $default-branch ] | |
| pull_request: | |
| branches: [ $default-branch ] | |
| env: | |
| CI: true | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| build_type: [Release] | |
| include: | |
| - os: ubuntu-latest | |
| c_compiler: gcc | |
| cpp_compiler: g++ | |
| - os: ubuntu-latest | |
| c_compiler: clang | |
| cpp_compiler: clang++ | |
| - os: windows-latest | |
| c_compiler: gcc | |
| cpp_compiler: g++ | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Update submodules to latest commits | |
| run: | | |
| git submodule sync | |
| git submodule update --init --remote --merge | |
| - name: Set build output dir | |
| shell: bash | |
| id: strings | |
| run: echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | |
| # ---------------- Linux setup ---------------- | |
| - name: Install dependencies (Linux) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential cmake \ | |
| libgl1-mesa-dev libx11-dev libxrandr-dev libxinerama-dev \ | |
| libxcursor-dev libxi-dev libasound2-dev libglu1-mesa-dev \ | |
| xvfb ccache | |
| - name: Clean build directory (Linux) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: rm -rf ${{ steps.strings.outputs.build-output-dir }} | |
| - name: Configure CMake (Linux) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| cmake -B ${{ steps.strings.outputs.build-output-dir }} \ | |
| -G "Unix Makefiles" \ | |
| -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \ | |
| -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} \ | |
| -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | |
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | |
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | |
| -S ${{ github.workspace }} | |
| - name: Build (Linux) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --target unit_tests -- -j$(nproc) | |
| - name: Run unit tests (Linux) | |
| if: matrix.os == 'ubuntu-latest' | |
| run: xvfb-run -a ${{ steps.strings.outputs.build-output-dir }}/tests/unit_tests | |
| # ---------------- Windows setup ---------------- | |
| - name: Install MinGW (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| choco install mingw --no-progress | |
| echo "C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin" >> $env:GITHUB_PATH | |
| - name: Clean build directory (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: Remove-Item -Path "${{ steps.strings.outputs.build-output-dir }}" -Recurse -Force -ErrorAction SilentlyContinue | |
| - name: Configure CMake (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: | | |
| cmake -B "${{ steps.strings.outputs.build-output-dir }}" ` | |
| -G "MinGW Makefiles" ` | |
| -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} ` | |
| -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} ` | |
| -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ` | |
| -S "${{ github.workspace }}" | |
| - name: Build (Windows) | |
| if: matrix.os == 'windows-latest' | |
| run: cmake --build "${{ steps.strings.outputs.build-output-dir }}" --config ${{ matrix.build_type }} --target unit_tests |