|
| 1 | +name: CI Build & Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["**"] |
| 6 | + pull_request: |
| 7 | + branches: ["**"] |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + name: ${{ matrix.os }} / ${{ matrix.compiler }} |
| 12 | + runs-on: ${{ matrix.os }} |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + os: [ubuntu-latest, macos-latest] |
| 17 | + compiler: [gcc, clang] |
| 18 | + exclude: |
| 19 | + - os: macos-latest |
| 20 | + compiler: gcc |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Install GCC (Ubuntu) |
| 27 | + if: matrix.os == 'ubuntu-latest' && matrix.compiler == 'gcc' |
| 28 | + run: | |
| 29 | + sudo apt-get update |
| 30 | + sudo apt-get install -y gcc g++ |
| 31 | +
|
| 32 | + - name: Install Clang (Ubuntu) |
| 33 | + if: matrix.os == 'ubuntu-latest' && matrix.compiler == 'clang' |
| 34 | + run: | |
| 35 | + sudo apt-get update |
| 36 | + sudo apt-get install -y clang |
| 37 | +
|
| 38 | + - name: Set compiler (GCC) |
| 39 | + if: matrix.compiler == 'gcc' |
| 40 | + run: | |
| 41 | + echo "CC=gcc" >> $GITHUB_ENV |
| 42 | + echo "CXX=g++" >> $GITHUB_ENV |
| 43 | +
|
| 44 | + - name: Set compiler (Clang) |
| 45 | + if: matrix.compiler == 'clang' |
| 46 | + run: | |
| 47 | + echo "CC=clang" >> $GITHUB_ENV |
| 48 | + echo "CXX=clang++" >> $GITHUB_ENV |
| 49 | +
|
| 50 | + - name: Configure |
| 51 | + run: cmake -B build -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON |
| 52 | + |
| 53 | + - name: Build (zero warnings required) |
| 54 | + run: cmake --build build 2>&1 | tee build.log |
| 55 | + |
| 56 | + - name: Verify zero warnings |
| 57 | + run: | |
| 58 | + if grep -iE "warning:" build.log | grep -v "In file included"; then |
| 59 | + echo "::error::Build produced warnings — see above" |
| 60 | + exit 1 |
| 61 | + fi |
| 62 | +
|
| 63 | + - name: Test |
| 64 | + run: ctest --test-dir build --output-on-failure |
| 65 | + |
| 66 | + lint: |
| 67 | + name: clang-tidy |
| 68 | + runs-on: ubuntu-latest |
| 69 | + |
| 70 | + steps: |
| 71 | + - name: Checkout |
| 72 | + uses: actions/checkout@v4 |
| 73 | + |
| 74 | + - name: Install clang-tidy |
| 75 | + run: | |
| 76 | + sudo apt-get update |
| 77 | + sudo apt-get install -y clang-tidy |
| 78 | +
|
| 79 | + - name: Configure (with compile_commands.json) |
| 80 | + run: cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF |
| 81 | + |
| 82 | + - name: Build (needed for generated headers) |
| 83 | + run: cmake --build build |
| 84 | + |
| 85 | + - name: Run clang-tidy |
| 86 | + run: | |
| 87 | + find src -name '*.c' | xargs clang-tidy -p build --warnings-as-errors='*' |
| 88 | +
|
| 89 | + format-check: |
| 90 | + name: clang-format check |
| 91 | + runs-on: ubuntu-latest |
| 92 | + |
| 93 | + steps: |
| 94 | + - name: Checkout |
| 95 | + uses: actions/checkout@v4 |
| 96 | + |
| 97 | + - name: Install clang-format |
| 98 | + run: | |
| 99 | + sudo apt-get update |
| 100 | + sudo apt-get install -y clang-format |
| 101 | +
|
| 102 | + - name: Check formatting |
| 103 | + run: | |
| 104 | + find include src wrapper/src wrapper/include -name '*.c' -o -name '*.h' -o -name '*.cpp' -o -name '*.hpp' | \ |
| 105 | + xargs clang-format --dry-run --Werror |
| 106 | +
|
| 107 | + build-32bit: |
| 108 | + name: Ubuntu / GCC / 32-bit |
| 109 | + runs-on: ubuntu-latest |
| 110 | + |
| 111 | + steps: |
| 112 | + - name: Checkout |
| 113 | + uses: actions/checkout@v4 |
| 114 | + |
| 115 | + - name: Install 32-bit toolchain |
| 116 | + run: | |
| 117 | + sudo apt-get update |
| 118 | + sudo apt-get install -y gcc-multilib g++-multilib |
| 119 | +
|
| 120 | + - name: Configure (32-bit) |
| 121 | + run: | |
| 122 | + cmake -B build \ |
| 123 | + -DBUILD_TESTS=ON \ |
| 124 | + -DBUILD_EXAMPLES=ON \ |
| 125 | + -DCMAKE_C_FLAGS=-m32 \ |
| 126 | + -DCMAKE_CXX_FLAGS=-m32 |
| 127 | +
|
| 128 | + - name: Build |
| 129 | + run: cmake --build build |
| 130 | + |
| 131 | + - name: Test |
| 132 | + run: ctest --test-dir build --output-on-failure |
0 commit comments