-
-
Notifications
You must be signed in to change notification settings - Fork 20
131 lines (112 loc) · 4.58 KB
/
cmake.yml
File metadata and controls
131 lines (112 loc) · 4.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: CI/CD Pipeline
on:
push:
branches: ["main", "develop"]
pull_request:
branches: ["main", "develop"]
# Prevent redundant runs on the same branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
BUILD_TYPE: Release
# NOTE: When updating CLANG_VERSION, also update the matrix packages below
CLANG_VERSION: 21
jobs:
checks:
name: ${{ matrix.check-name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false # Show all failures instead of stopping early
matrix:
include:
- check: format
check-name: Format Check
packages: clang-format-21
needs_symlink: true
- check: tidy
check-name: Tidy Check
packages: clang-tidy-21 protobuf-compiler build-essential cmake ccache
needs_symlink: true
- check: test
check-name: Build and Test
packages: protobuf-compiler build-essential cmake ccache
- check: examples
check-name: Build Examples
packages: protobuf-compiler build-essential cmake ccache
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Cache LLVM repository setup
if: matrix.check == 'format' || matrix.check == 'tidy'
id: cache-llvm-repo
uses: actions/cache@v4
with:
path: /etc/apt/sources.list.d/llvm.list
key: llvm-repo-noble-${{ env.CLANG_VERSION }}-${{ hashFiles('.github/workflows/cmake.yml') }}
- name: Add LLVM repository
if: (matrix.check == 'format' || matrix.check == 'tidy') && steps.cache-llvm-repo.outputs.cache-hit != 'true'
run: |
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
echo "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-${{ env.CLANG_VERSION }} main" | sudo tee /etc/apt/sources.list.d/llvm.list
sudo apt-get update
- name: Install apt dependencies (with cache)
uses: awalsh128/cache-apt-pkgs-action@v1.6.0
with:
packages: ${{ matrix.packages }}
version: 1.1
- name: Symlink clang-format
if: matrix.check == 'format'
run: |
ln -sf /usr/bin/clang-format-${{ env.CLANG_VERSION }} /usr/bin/clang-format
clang-format --version
- name: Install clang tools (uncached for correct symlinks)
if: matrix.check == 'tidy'
run: |
ln -sf /usr/bin/clang-tidy-${{ env.CLANG_VERSION }} /usr/bin/clang-tidy
clang-tidy --version
- name: Install python dependencies
if: matrix.check == 'test' || matrix.check == 'examples'
run: python3 -m pip install protobuf grpcio-tools
- name: Setup ccache
# Skip ccache for format check as it doesn't compile code
if: matrix.check != 'format'
uses: hendrikmuhs/ccache-action@v1.2.20
with:
key: checks-${{ matrix.check }}-${{ runner.os }}-mbedtls-3.6.5
- name: Set reusable strings
if: matrix.check != 'format'
id: strings
shell: bash
run: echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure CMake
if: matrix.check != 'format'
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=g++
-DCMAKE_C_COMPILER=gcc
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-S ${{ github.workspace }}
- name: Check clang-format
if: matrix.check == 'format'
run: ./scripts/clang-format.sh --check
- name: Run clang-tidy
if: matrix.check == 'tidy'
run: ./scripts/clang-tidy.sh --check
- name: Build Library
if: matrix.check == 'test'
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ env.BUILD_TYPE }} -j
- name: Run Tests
if: matrix.check == 'test'
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: ctest --build-config ${{ env.BUILD_TYPE }} --output-on-failure --verbose
- name: Build and run example
if: matrix.check == 'examples'
run: |
mkdir -p build-example && cd build-example
cmake ../examples/simple -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build . --config ${{ env.BUILD_TYPE }}
./simple