ICT290 / .github / workflows / cmake.yml
cmake.yml
Raw
name: CMake

on: [ pull_request ]

env:
  # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
  BUILD_TYPE: Release

jobs:
  build:
    # The CMake configure and build commands are platform agnostic and should work equally
    # well on Windows or Mac.  You can convert this to a matrix build if you need
    # cross-platform coverage.
    # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Install linux dependencies
        run: |
          sudo apt-get update
          sudo apt install git cmake ninja-build libasan6 libubsan1 libsdl2-dev libgl1-mesa-dev libglu1-mesa-dev libxcursor-dev libxrandr-dev x11-common xorg-dev extra-cmake-modules build-essential autoconf automake libtool pkg-config libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev libxss-dev libgl1-mesa-dev libdbus-1-dev libudev-dev libgles2-mesa-dev libegl1-mesa-dev libibus-1.0-dev fcitx-libs-dev libsamplerate0-dev libsndio-dev libwayland-dev libxkbcommon-dev libdrm-dev libgbm-dev libdecoration0-dev          

      - name: Install git lfs
        run: git lfs install

      - name: Clone Submodules
        run: git submodule init && git submodule update

      - name: CMake
        # Execute the build.  You can specify a specific target with "--target <NAME>"
        run: cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSDL_VIDEO=OFF

      - name: Build
        working-directory: build
        run: ninja

      - name: Test
        working-directory: build
        # Execute tests defined by the CMake configuration.
        # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
        run: ctest -C $BUILD_TYPE

  Cppcheck:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Install Cppcheck
        run: sudo apt install cppcheck

      - name: Run Cppcheck
        working-directory: ${{github.workspace}}
        shell: bash
        run: cppcheck src/ --enable=all --error-exitcode=1 --suppress=unusedFunction --suppress=stlFindInsert

  Clang-format:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Install clang-format
        run: |
          sudo apt install clang-format-12
          clang-format-12 --version
          clang-format-12 --help          

      - name: Run clang-format
        working-directory: src
        shell: bash
        run: find . -name "*.cpp" -o -name "*.h" | xargs -I {} clang-format-12 --style=file --Werror --dry-run {}