Feature/cwm/4 add clang format and clang tidy configuration #9
Workflow file for this run
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] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| build_test: | |
| name: Build & Test Matrix | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| compiler: [gcc-13, clang-17] | |
| build_type: [Debug, Release] | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install build dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake ninja-build ccache | |
| if [ "${{ matrix.compiler }}" = "gcc-13" ]; then | |
| sudo apt-get install -y gcc-13 g++-13 | |
| else | |
| sudo apt-get install -y clang-17 | |
| fi | |
| - name: Cache ccache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.ccache | |
| key: ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ matrix.build_type }}-${{ hashFiles('**/CMakeLists.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ matrix.build_type }}- | |
| ${{ runner.os }}-ccache-${{ matrix.compiler }}- | |
| - name: Configure | |
| run: | | |
| mkdir -p build | |
| if [ "${{ matrix.compiler }}" = "gcc-13" ]; then | |
| cmake -S . -B build -G Ninja \ | |
| -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | |
| -DCPUSCOPE_BUILD_TESTS=ON \ | |
| -DCPUSCOPE_WERROR=ON \ | |
| -DCMAKE_C_COMPILER=gcc-13 \ | |
| -DCMAKE_CXX_COMPILER=g++-13 \ | |
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | |
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache | |
| else | |
| cmake -S . -B build -G Ninja \ | |
| -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | |
| -DCPUSCOPE_BUILD_TESTS=ON \ | |
| -DCPUSCOPE_WERROR=ON \ | |
| -DCMAKE_C_COMPILER=clang-17 \ | |
| -DCMAKE_CXX_COMPILER=clang++-17 \ | |
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | |
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache | |
| fi | |
| - name: Build | |
| run: cmake --build build --parallel | |
| - name: Run tests | |
| run: ctest --test-dir build --output-on-failure | |
| - name: Smoke test | |
| if: matrix.build_type == 'Release' | |
| run: ./build/cpuscope_cli --version | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install lint dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake ninja-build ccache clang-format clang-tidy clang-17 | |
| - name: Configure compile commands | |
| run: | | |
| mkdir -p build | |
| cmake -S . -B build -G Ninja \ | |
| -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | |
| -DCPUSCOPE_BUILD_TESTS=ON \ | |
| -DCMAKE_C_COMPILER=clang-17 \ | |
| -DCMAKE_CXX_COMPILER=clang++-17 \ | |
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | |
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache | |
| - name: Check formatting | |
| run: scripts/check-format.sh | |
| - name: Run static analysis | |
| run: scripts/lint.sh | |
| sanitizer: | |
| name: Sanitizer Build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install build dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake ninja-build ccache clang-17 | |
| - name: Cache ccache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.ccache | |
| key: ${{ runner.os }}-ccache-clang-17-Release-${{ hashFiles('**/CMakeLists.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-ccache-clang-17-Release- | |
| ${{ runner.os }}-ccache-clang-17- | |
| - name: Configure sanitizer build | |
| run: | | |
| mkdir -p build-sanitizer | |
| cmake -S . -B build-sanitizer -G Ninja \ | |
| -DCMAKE_BUILD_TYPE=Release \ | |
| -DCPUSCOPE_BUILD_TESTS=ON \ | |
| -DCPUSCOPE_WERROR=ON \ | |
| -DCMAKE_C_COMPILER=clang-17 \ | |
| -DCMAKE_CXX_COMPILER=clang++-17 \ | |
| -DCMAKE_C_COMPILER_LAUNCHER=ccache \ | |
| -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | |
| -DCMAKE_C_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -fno-sanitize-recover=all" \ | |
| -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -fno-sanitize-recover=all" \ | |
| -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address,undefined" | |
| - name: Build sanitizer build | |
| run: cmake --build build-sanitizer --parallel | |
| - name: Run sanitizer tests | |
| run: | | |
| export ASAN_OPTIONS=halt_on_error=1:detect_leaks=0 | |
| export UBSAN_OPTIONS=halt_on_error=1 | |
| ctest --test-dir build-sanitizer --output-on-failure |