Skip to content

Commit 2a755ec

Browse files
committed
CI: use llvm apt repo
CI: separate build examples step
1 parent 2e5a97b commit 2a755ec

1 file changed

Lines changed: 41 additions & 7 deletions

File tree

.github/workflows/cmake.yml

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ concurrency:
1313

1414
env:
1515
BUILD_TYPE: Release
16+
# NOTE: When updating CLANG_VERSION, also update the matrix packages below
17+
CLANG_VERSION: 21
1618

1719
jobs:
1820
checks:
@@ -24,26 +26,58 @@ jobs:
2426
include:
2527
- check: format
2628
check-name: Format Check
27-
packages: clang-format clang
29+
packages: clang-format-21
30+
needs_symlink: true
2831
- check: tidy
2932
check-name: Tidy Check
30-
packages: protobuf-compiler build-essential clang clang-tidy cmake
33+
packages: clang-tidy-21 protobuf-compiler build-essential cmake ccache
34+
needs_symlink: true
3135
- check: test
3236
check-name: Build and Test
33-
packages: protobuf-compiler build-essential cmake
37+
packages: protobuf-compiler build-essential cmake ccache
38+
- check: examples
39+
check-name: Build Examples
40+
packages: protobuf-compiler build-essential cmake ccache
3441

3542
steps:
3643
- name: Checkout
3744
uses: actions/checkout@v6
3845

39-
- name: Cache apt dependencies
46+
- name: Cache LLVM repository setup
47+
if: matrix.check == 'format' || matrix.check == 'tidy'
48+
id: cache-llvm-repo
49+
uses: actions/cache@v4
50+
with:
51+
path: /etc/apt/sources.list.d/llvm.list
52+
key: llvm-repo-noble-${{ env.CLANG_VERSION }}-${{ hashFiles('.github/workflows/cmake.yml') }}
53+
54+
- name: Add LLVM repository
55+
if: (matrix.check == 'format' || matrix.check == 'tidy') && steps.cache-llvm-repo.outputs.cache-hit != 'true'
56+
run: |
57+
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
58+
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-${{ env.CLANG_VERSION }} main" | sudo tee /etc/apt/sources.list.d/llvm.list
59+
sudo apt-get update
60+
61+
- name: Install apt dependencies (with cache)
4062
uses: awalsh128/cache-apt-pkgs-action@v1.6.0
4163
with:
4264
packages: ${{ matrix.packages }}
43-
version: 1.0
65+
version: 1.1
66+
67+
- name: Symlink clang-format
68+
if: matrix.check == 'format'
69+
run: |
70+
ln -sf /usr/bin/clang-format-${{ env.CLANG_VERSION }} /usr/bin/clang-format
71+
clang-format --version
72+
73+
- name: Install clang tools (uncached for correct symlinks)
74+
if: matrix.check == 'tidy'
75+
run: |
76+
ln -sf /usr/bin/clang-tidy-${{ env.CLANG_VERSION }} /usr/bin/clang-tidy
77+
clang-tidy --version
4478
4579
- name: Install python dependencies
46-
if: matrix.check == 'test'
80+
if: matrix.check == 'test' || matrix.check == 'examples'
4781
run: python3 -m pip install protobuf grpcio-tools
4882

4983
- name: Setup ccache
@@ -89,7 +123,7 @@ jobs:
89123
run: ctest --build-config ${{ env.BUILD_TYPE }} --output-on-failure --verbose
90124

91125
- name: Build and run example
92-
if: matrix.check == 'test'
126+
if: matrix.check == 'examples'
93127
run: |
94128
mkdir -p build-example && cd build-example
95129
cmake ../examples/simple -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache

0 commit comments

Comments
 (0)