|
| 1 | +name: C++ Tools |
| 2 | + |
| 3 | +# Called by top-level ci.yml. |
| 4 | +on: |
| 5 | + workflow_call: {} |
| 6 | + workflow_dispatch: {} |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +jobs: |
| 12 | + clang-format: |
| 13 | + name: clang-format |
| 14 | + runs-on: ubuntu-latest |
| 15 | + timeout-minutes: 15 |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 20 | + with: |
| 21 | + fetch-depth: 1 |
| 22 | + |
| 23 | + - name: Initialize cpp-tools |
| 24 | + run: git submodule update --init cpp-tools |
| 25 | + |
| 26 | + - name: Install shared clang-format configuration |
| 27 | + run: ./cpp-tools/install.sh clang-format --repo-root "$GITHUB_WORKSPACE" --force |
| 28 | + |
| 29 | + - name: Install clang-format 22 |
| 30 | + run: | |
| 31 | + set -eux |
| 32 | + # Pin clang-format 22 to match the current macOS Homebrew LLVM. |
| 33 | + # Ubuntu 24.04's default clang-format ships with LLVM 18. |
| 34 | + sudo install -m 0755 -d /etc/apt/keyrings |
| 35 | + wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key \ |
| 36 | + | sudo tee /etc/apt/keyrings/llvm.asc >/dev/null |
| 37 | + sudo chmod a+r /etc/apt/keyrings/llvm.asc |
| 38 | + codename=$(lsb_release -cs) |
| 39 | + echo "deb [signed-by=/etc/apt/keyrings/llvm.asc] http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}-22 main" \ |
| 40 | + | sudo tee /etc/apt/sources.list.d/llvm-22.list >/dev/null |
| 41 | + sudo apt-get update |
| 42 | + sudo apt-get install -y clang-format-22 |
| 43 | + sudo ln -sf /usr/bin/clang-format-22 /usr/local/bin/clang-format |
| 44 | + clang-format --version |
| 45 | +
|
| 46 | + - name: Run clang-format |
| 47 | + env: |
| 48 | + FORMAT_BLOB_SHA: ${{ github.event.pull_request.head.sha || github.sha }} |
| 49 | + run: ./scripts/clang-format.sh |
| 50 | + |
| 51 | + clang-tidy: |
| 52 | + name: clang-tidy |
| 53 | + runs-on: ubuntu-latest |
| 54 | + timeout-minutes: 45 |
| 55 | + |
| 56 | + steps: |
| 57 | + - name: Checkout with submodules |
| 58 | + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 59 | + with: |
| 60 | + submodules: recursive |
| 61 | + fetch-depth: 1 |
| 62 | + |
| 63 | + - name: Install shared clang-tidy configuration |
| 64 | + run: ./cpp-tools/install.sh clang-tidy --repo-root "$GITHUB_WORKSPACE" --force |
| 65 | + |
| 66 | + - name: Install dependencies |
| 67 | + run: | |
| 68 | + set -eux |
| 69 | + sudo apt-get update |
| 70 | + sudo apt-get install -y \ |
| 71 | + build-essential cmake ninja-build pkg-config \ |
| 72 | + llvm-dev libclang-dev clang \ |
| 73 | + libssl-dev libcurl4-openssl-dev wget ca-certificates gnupg |
| 74 | +
|
| 75 | + - name: Install clang-tidy 19 |
| 76 | + run: | |
| 77 | + set -eux |
| 78 | + # ExcludeHeaderFilterRegex requires clang-tidy 19 or newer. |
| 79 | + sudo install -m 0755 -d /etc/apt/keyrings |
| 80 | + wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key \ |
| 81 | + | sudo tee /etc/apt/keyrings/llvm.asc >/dev/null |
| 82 | + sudo chmod a+r /etc/apt/keyrings/llvm.asc |
| 83 | + codename=$(lsb_release -cs) |
| 84 | + echo "deb [signed-by=/etc/apt/keyrings/llvm.asc] http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}-19 main" \ |
| 85 | + | sudo tee /etc/apt/sources.list.d/llvm-19.list >/dev/null |
| 86 | + sudo apt-get update |
| 87 | + sudo apt-get install -y clang-tidy-19 clang-tools-19 |
| 88 | + sudo ln -sf /usr/bin/clang-tidy-19 /usr/local/bin/clang-tidy |
| 89 | + sudo ln -sf /usr/bin/run-clang-tidy-19 /usr/local/bin/run-clang-tidy |
| 90 | + clang-tidy --version |
| 91 | + run-clang-tidy --help >/dev/null |
| 92 | +
|
| 93 | + - name: Install Rust |
| 94 | + uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 |
| 95 | + with: |
| 96 | + toolchain: stable |
| 97 | + |
| 98 | + - name: Set Linux build environment |
| 99 | + run: | |
| 100 | + echo "CXXFLAGS=-Wno-deprecated-declarations" >> "$GITHUB_ENV" |
| 101 | + echo "CFLAGS=-Wno-deprecated-declarations" >> "$GITHUB_ENV" |
| 102 | + LLVM_VERSION=$(llvm-config --version | cut -d. -f1) |
| 103 | + echo "LIBCLANG_PATH=/usr/lib/llvm-${LLVM_VERSION}/lib" >> "$GITHUB_ENV" |
| 104 | +
|
| 105 | + - name: Configure compilation database |
| 106 | + run: cmake --preset linux-release |
| 107 | + |
| 108 | + - name: Generate protobuf headers |
| 109 | + run: cmake --build build-release --target livekit_proto |
| 110 | + |
| 111 | + - name: Run clang-tidy |
| 112 | + env: |
| 113 | + TIDY_BLOB_SHA: ${{ github.event.pull_request.head.sha || github.sha }} |
| 114 | + run: ./scripts/clang-tidy.sh --fail-on-warning |
0 commit comments