Merge branch 'main' of https://github.com/Martian-Technologies/Connec… #1014
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: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. | |
| fail-fast: false | |
| # Set up a matrix to run the following 3 configurations: | |
| # 1. <Windows, Tests, latest MSVC compiler toolchain on the default runner image, default generator> | |
| # 2. <Linux, Tests, latest GCC compiler toolchain on the default runner image, default generator> | |
| # 3. <Linux, Tests, latest Clang compiler toolchain on the default runner image, default generator> | |
| # | |
| # To add more build types (Release, Debug, etc.) customize the build_type list. | |
| matrix: | |
| build_type: [Debug] | |
| # os: [windows-latest, ubuntu-latest, macos-latest] | |
| # os: [ubuntu-latest, macos-latest] | |
| os: [windows-latest] | |
| include: | |
| - os: windows-latest | |
| c_compiler: cl | |
| cpp_compiler: cl | |
| runExecutable: .\Debug\Connection_Machine_tests.exe | |
| - os: ubuntu-latest | |
| c_compiler: gcc-14 | |
| cpp_compiler: g++-14 | |
| runExecutable: ./Connection_Machine_tests | |
| # - os: ubuntu-latest | |
| # c_compiler: clang | |
| # cpp_compiler: clang++ | |
| # runExecutable: ./Connection_Machine_tests | |
| # - os: macos-latest | |
| # c_compiler: clang | |
| # cpp_compiler: clang++ | |
| # runExecutable: ./Connection Machine_tests | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Cache CMake dependency source code | |
| uses: actions/cache@v4 | |
| env: | |
| cache-name: cache-cmake-dependency-sources | |
| with: | |
| # CMake cache is at ${{github.workspace}}/build/_deps but we only will cache folders ending in '-src' to cache source code | |
| path: ${{github.workspace}}/build/_deps/*-src | |
| # Cache hash is dependent on CMakeLists files anywhere as these can change what's in the cache, as well as cmake modules files | |
| key: ${{ env.cache-name }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} | |
| # it's acceptable to reuse caches for different CMakeLists content if exact match is not available and unlike build caches, we | |
| # don't need to restrict these by OS or compiler as it's only source code that's being cached | |
| restore-keys: | | |
| ${{ env.cache-name }}- | |
| - name: Install Linux dependencies | |
| if: matrix.os == 'ubuntu-latest' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential git make pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev libaudio-dev libfribidi-dev libjack-dev libsndio-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libxtst-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev | |
| sudo apt-get install -y python3-pip | |
| pip install --upgrade gcovr # gets latest (8.x) | |
| - name: Cache CMake dependency build objects | |
| uses: actions/cache@v4 | |
| env: | |
| cache-name: cache-cmake-dependency-builds | |
| with: | |
| # CMake cache is at ${{github.workspace}}/build/_deps but we only care about the folders ending in -build or -subbuild | |
| path: | | |
| ${{github.workspace}}/build/_deps/*-build | |
| ${{github.workspace}}/build/_deps/*-subbuild | |
| # Cache hash is dependent on CMakeLists files anywhere as these can change what's in the cache, as well as cmake modules files | |
| key: ${{ env.cache-name }}-${{ matrix.os }}-${{ matrix.cxx }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }} | |
| # it's acceptable to reuse caches for different CMakeLists content if exact match is not available | |
| # as long as the OS and Compiler match exactly | |
| restore-keys: | | |
| ${{ env.cache-name }}-${{ matrix.os }}-${{ matrix.cxx }}- | |
| - name: Check coverage tool versions | |
| if: success() && matrix.os == 'ubuntu-latest' | |
| run: | | |
| which gcc || true | |
| which g++ || true | |
| which gcov || true | |
| which gcc-14 || true | |
| which g++-14 || true | |
| which gcov-14 || true | |
| gcc-14 --version || true | |
| gcov-14 --version || true | |
| gcovr --version || true | |
| - name: Install Vulkan SDK | |
| uses: humbletim/install-vulkan-sdk@v1.2 | |
| with: | |
| version: 1.4.309.0 | |
| cache: true | |
| - name: Build with CMake | |
| uses: ashutoshvarma/action-cmake-build@master | |
| with: | |
| build-dir: ${{ github.workspace }}/build | |
| cc: ${{ matrix.c_compiler }} | |
| cxx: ${{ matrix.cpp_compiler }} | |
| configure-options: "-DCONNECTION_MACHINE_BUILD_TESTS=ON -DCONNECTION_MACHINE_CODE_COVERAGE=ON -DCONNECTION_MACHINE_BUILD_APP=OFF -DCONNECTION_MACHINE_BUILD_CLI_APP=OFF" | |
| target: Connection_Machine_tests | |
| build-type: ${{ matrix.build_type }} | |
| - name: List files | |
| run: ls ${{ github.workspace }}/build | |
| - name: Test | |
| id: run_tests | |
| working-directory: ${{ github.workspace }}/build | |
| # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). | |
| # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail | |
| run: ${{ matrix.runExecutable }} | |
| # run: Gatality_tests | |
| - name: Coverage Report | |
| if: success() && matrix.os == 'ubuntu-latest' | |
| working-directory: ${{ github.workspace }} | |
| run: | | |
| bash gcov_coverage.sh | |
| mv ./coverage/coverage.html ./coverage/index.html | |
| ls ./coverage | |
| # Publish the coverage folder as the Pages artifact (ubuntu job only) | |
| - name: Upload Pages artifact (coverage/) | |
| if: success() && matrix.os == 'ubuntu-latest' | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: coverage | |
| # optional: name: coverage-artifact | |
| - name: Notify Discord on test failure | |
| if: failure() | |
| uses: sarisia/actions-status-discord@v1 | |
| with: | |
| webhook: ${{ secrets.DISCORD_WEBHOOK }} | |
| status: failure | |
| title: Tests failed on ${{ matrix.os }} | |
| description: Build type ${{ matrix.build_type }} | |
| color: 0xff0000 | |
| # Deploy only after the matrix completes; it will pick up the uploaded artifact | |
| deploy: | |
| needs: build | |
| if: always() && needs.build.result == 'success' && github.event_name != 'pull_request' && github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |