|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +jobs: |
| 10 | + build_test: |
| 11 | + name: Build & Test Matrix |
| 12 | + runs-on: ubuntu-latest |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + compiler: [gcc-13, clang-17] |
| 16 | + build_type: [Debug, Release] |
| 17 | + fail-fast: false |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Install build dependencies |
| 22 | + run: | |
| 23 | + sudo apt-get update |
| 24 | + sudo apt-get install -y cmake ninja-build ccache |
| 25 | + if [ "${{ matrix.compiler }}" = "gcc-13" ]; then |
| 26 | + sudo apt-get install -y gcc-13 g++-13 |
| 27 | + else |
| 28 | + sudo apt-get install -y clang-17 |
| 29 | + fi |
| 30 | +
|
| 31 | + - name: Cache ccache |
| 32 | + uses: actions/cache@v4 |
| 33 | + with: |
| 34 | + path: ~/.ccache |
| 35 | + key: ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ matrix.build_type }}-${{ hashFiles('**/CMakeLists.txt') }} |
| 36 | + restore-keys: | |
| 37 | + ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ matrix.build_type }}- |
| 38 | + ${{ runner.os }}-ccache-${{ matrix.compiler }}- |
| 39 | +
|
| 40 | + - name: Configure |
| 41 | + run: | |
| 42 | + mkdir -p build |
| 43 | + if [ "${{ matrix.compiler }}" = "gcc-13" ]; then |
| 44 | + cmake -S . -B build -G Ninja \ |
| 45 | + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ |
| 46 | + -DCPUSCOPE_BUILD_TESTS=ON \ |
| 47 | + -DCPUSCOPE_WERROR=ON \ |
| 48 | + -DCMAKE_C_COMPILER=gcc-13 \ |
| 49 | + -DCMAKE_CXX_COMPILER=g++-13 \ |
| 50 | + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ |
| 51 | + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache |
| 52 | + else |
| 53 | + cmake -S . -B build -G Ninja \ |
| 54 | + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ |
| 55 | + -DCPUSCOPE_BUILD_TESTS=ON \ |
| 56 | + -DCPUSCOPE_WERROR=ON \ |
| 57 | + -DCMAKE_C_COMPILER=clang-17 \ |
| 58 | + -DCMAKE_CXX_COMPILER=clang++-17 \ |
| 59 | + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ |
| 60 | + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache |
| 61 | + fi |
| 62 | +
|
| 63 | + - name: Build |
| 64 | + run: cmake --build build --parallel |
| 65 | + |
| 66 | + - name: Run tests |
| 67 | + run: ctest --test-dir build --output-on-failure |
| 68 | + |
| 69 | + - name: Smoke test |
| 70 | + if: matrix.build_type == 'Release' |
| 71 | + run: ./build/cpuscope_cli --version |
| 72 | + |
| 73 | + lint: |
| 74 | + name: Lint (Placeholder) |
| 75 | + runs-on: ubuntu-latest |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v4 |
| 78 | + - name: Placeholder lint |
| 79 | + run: echo "Lint checks will be added later" |
| 80 | + |
| 81 | + sanitizer: |
| 82 | + name: Sanitizer Build |
| 83 | + runs-on: ubuntu-latest |
| 84 | + steps: |
| 85 | + - uses: actions/checkout@v4 |
| 86 | + |
| 87 | + - name: Install build dependencies |
| 88 | + run: | |
| 89 | + sudo apt-get update |
| 90 | + sudo apt-get install -y cmake ninja-build ccache clang-17 |
| 91 | +
|
| 92 | + - name: Cache ccache |
| 93 | + uses: actions/cache@v4 |
| 94 | + with: |
| 95 | + path: ~/.ccache |
| 96 | + key: ${{ runner.os }}-ccache-clang-17-Release-${{ hashFiles('**/CMakeLists.txt') }} |
| 97 | + restore-keys: | |
| 98 | + ${{ runner.os }}-ccache-clang-17-Release- |
| 99 | + ${{ runner.os }}-ccache-clang-17- |
| 100 | +
|
| 101 | + - name: Configure sanitizer build |
| 102 | + run: | |
| 103 | + mkdir -p build-sanitizer |
| 104 | + cmake -S . -B build-sanitizer -G Ninja \ |
| 105 | + -DCMAKE_BUILD_TYPE=Release \ |
| 106 | + -DCPUSCOPE_BUILD_TESTS=ON \ |
| 107 | + -DCPUSCOPE_WERROR=ON \ |
| 108 | + -DCMAKE_C_COMPILER=clang-17 \ |
| 109 | + -DCMAKE_CXX_COMPILER=clang++-17 \ |
| 110 | + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ |
| 111 | + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ |
| 112 | + -DCMAKE_C_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -fno-sanitize-recover=all" \ |
| 113 | + -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined -fno-omit-frame-pointer -fno-sanitize-recover=all" \ |
| 114 | + -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address,undefined" |
| 115 | +
|
| 116 | + - name: Build sanitizer build |
| 117 | + run: cmake --build build-sanitizer --parallel |
| 118 | + |
| 119 | + - name: Run sanitizer tests |
| 120 | + run: | |
| 121 | + export ASAN_OPTIONS=halt_on_error=1:detect_leaks=0 |
| 122 | + export UBSAN_OPTIONS=halt_on_error=1 |
| 123 | + ctest --test-dir build-sanitizer --output-on-failure |
0 commit comments