|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master] |
| 6 | + pull_request: |
| 7 | + branches: [master] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - os: ubuntu-24.04 |
| 23 | + cc: gcc-14 |
| 24 | + cxx: g++-14 |
| 25 | + name: Linux GCC |
| 26 | + lint: false |
| 27 | + - os: ubuntu-24.04 |
| 28 | + cc: clang-19 |
| 29 | + cxx: clang++-19 |
| 30 | + name: Linux Clang |
| 31 | + lint: true |
| 32 | + - os: macos-14 |
| 33 | + cc: clang |
| 34 | + cxx: clang++ |
| 35 | + name: macOS |
| 36 | + lint: false |
| 37 | + |
| 38 | + name: ${{ matrix.name }} |
| 39 | + runs-on: ${{ matrix.os }} |
| 40 | + |
| 41 | + steps: |
| 42 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 43 | + with: |
| 44 | + persist-credentials: false |
| 45 | + |
| 46 | + - name: Install dependencies (Linux) |
| 47 | + if: runner.os == 'Linux' |
| 48 | + run: | |
| 49 | + wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key \ |
| 50 | + | sudo apt-key add - |
| 51 | + echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-19 main" \ |
| 52 | + | sudo tee /etc/apt/sources.list.d/llvm.list |
| 53 | + sudo apt-get update -qq |
| 54 | + sudo apt-get install -y -qq \ |
| 55 | + llvm-19-dev clang-19 clang-format-19 clang-tidy-19 \ |
| 56 | + libz3-dev |
| 57 | + echo "LLVM_DIR=/usr/lib/llvm-19/lib/cmake/llvm" >> "$GITHUB_ENV" |
| 58 | +
|
| 59 | + - name: Install dependencies (macOS) |
| 60 | + if: runner.os == 'macOS' |
| 61 | + run: | |
| 62 | + brew install llvm@19 z3 |
| 63 | + LLVM_PREFIX="$(brew --prefix llvm@19)" |
| 64 | + echo "${LLVM_PREFIX}/bin" >> "$GITHUB_PATH" |
| 65 | + { |
| 66 | + echo "LLVM_DIR=${LLVM_PREFIX}/lib/cmake/llvm" |
| 67 | + echo "CC=${LLVM_PREFIX}/bin/clang" |
| 68 | + echo "CXX=${LLVM_PREFIX}/bin/clang++" |
| 69 | + echo "LDFLAGS=-L${LLVM_PREFIX}/lib/c++ -Wl,-rpath,${LLVM_PREFIX}/lib/c++" |
| 70 | + } >> "$GITHUB_ENV" |
| 71 | +
|
| 72 | + - name: Cache GoogleTest |
| 73 | + uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 |
| 74 | + with: |
| 75 | + path: build-deps/install |
| 76 | + key: gtest-${{ matrix.os }}-${{ matrix.cc }}-v1.16.0 |
| 77 | + |
| 78 | + - name: Build dependencies |
| 79 | + run: | |
| 80 | + cmake -S dependencies -B build-deps \ |
| 81 | + -DCMAKE_C_COMPILER="${CC:-${{ matrix.cc }}}" \ |
| 82 | + -DCMAKE_CXX_COMPILER="${CXX:-${{ matrix.cxx }}}" \ |
| 83 | + -DCMAKE_BUILD_TYPE=Release \ |
| 84 | + -DUSE_EXTERNAL_LLVM=ON |
| 85 | + cmake --build build-deps |
| 86 | +
|
| 87 | + - name: Build CoBRA |
| 88 | + run: | |
| 89 | + cmake -S . -B build \ |
| 90 | + -DCMAKE_C_COMPILER="${CC:-${{ matrix.cc }}}" \ |
| 91 | + -DCMAKE_CXX_COMPILER="${CXX:-${{ matrix.cxx }}}" \ |
| 92 | + -DCMAKE_PREFIX_PATH="$(pwd)/build-deps/install" \ |
| 93 | + -DCMAKE_BUILD_TYPE=Release |
| 94 | + cmake --build build |
| 95 | +
|
| 96 | + - name: Run tests |
| 97 | + run: ctest --test-dir build --output-on-failure |
| 98 | + |
| 99 | + - name: clang-format check |
| 100 | + if: matrix.lint |
| 101 | + run: | |
| 102 | + find include lib tools \( -name '*.h' -o -name '*.cpp' \) -print0 \ |
| 103 | + | xargs -0 clang-format-19 --dry-run --Werror |
| 104 | +
|
| 105 | + - name: clang-tidy |
| 106 | + if: matrix.lint |
| 107 | + run: | |
| 108 | + find lib tools -name '*.cpp' -print0 \ |
| 109 | + | xargs -0 clang-tidy-19 -p build --warnings-as-errors='*' |
0 commit comments