66 pull_request :
77 branches : ["main", "develop"]
88
9+ # Prevent redundant runs on the same branch
10+ concurrency :
11+ group : ${{ github.workflow }}-${{ github.ref }}
12+ cancel-in-progress : true
13+
914env :
1015 BUILD_TYPE : Release
1116
1217jobs :
13- format-check :
14- name : Format Check
18+ checks :
19+ name : ${{ matrix.check-name }}
1520 runs-on : ubuntu-latest
21+ strategy :
22+ fail-fast : false # Show all failures instead of stopping early
23+ matrix :
24+ include :
25+ - check : format
26+ check-name : Format Check
27+ packages : clang-format clang
28+ - check : tidy
29+ check-name : Tidy Check
30+ packages : protobuf-compiler build-essential clang clang-tidy cmake
31+ - check : test
32+ check-name : Build and Test
33+ packages : protobuf-compiler build-essential cmake
1634
1735 steps :
1836 - name : Checkout
@@ -21,105 +39,61 @@ jobs:
2139 - name : Cache apt dependencies
2240 uses : awalsh128/cache-apt-pkgs-action@v1.6.0
2341 with :
24- packages : clang-format clang
42+ packages : ${{ matrix.packages }}
2543 version : 1.0
2644
27- - name : Setup ccache
28- uses : hendrikmuhs/ccache-action@v1.2.20
29- with :
30- key : ${{ github.job }}-${{ runner.os }}-mbedtls-3.6.5
31-
32- - name : Check clang-format
33- run : |
34- find src include tests examples -name "*.cpp" -o -name "*.h" | xargs clang-format --dry-run --Werror --style=file
35-
36- tidy-check :
37- name : Tidy Check
38- runs-on : ubuntu-latest
39-
40- steps :
41- - name : Checkout
42- uses : actions/checkout@v6
43-
44- - name : Cache apt dependencies
45- uses : awalsh128/cache-apt-pkgs-action@v1.6.0
46- with :
47- packages : protobuf-compiler build-essential clang clang-tidy cmake
48- version : 1.0
45+ - name : Install python dependencies
46+ if : matrix.check == 'test'
47+ run : python3 -m pip install protobuf grpcio-tools
4948
5049 - name : Setup ccache
50+ # Skip ccache for format check as it doesn't compile code
51+ if : matrix.check != 'format'
5152 uses : hendrikmuhs/ccache-action@v1.2.20
5253 with :
53- key : ${{ github.job }}-${{ runner.os }}-mbedtls-3.6.5
54+ key : checks- ${{ matrix.check }}-${{ runner.os }}-mbedtls-3.6.5
5455
5556 - name : Set reusable strings
57+ if : matrix.check != 'format'
5658 id : strings
5759 shell : bash
58- run : |
59- echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
60+ run : echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
6061
6162 - name : Configure CMake
63+ if : matrix.check != 'format'
6264 run : >
6365 cmake -B ${{ steps.strings.outputs.build-output-dir }}
6466 -DCMAKE_CXX_COMPILER=g++
6567 -DCMAKE_C_COMPILER=gcc
66- -DCMAKE_BUILD_TYPE=Release
68+ -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
6769 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
70+ -DCMAKE_C_COMPILER_LAUNCHER=ccache
71+ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
6872 -S ${{ github.workspace }}
6973
70- - name : Run clang-tidy
74+ - name : Check clang-format
75+ if : matrix.check == 'format'
7176 run : |
72- find src -name "*.cpp" | xargs clang-tidy -p ${{ steps.strings.outputs.build-output-dir }} --header-filter="^(?!.*_deps).*" --quiet
73-
74- test :
75- name : Build and Test
76- runs-on : ubuntu-latest
77-
78- steps :
79- - name : Checkout
80- uses : actions/checkout@v6
81-
82- - name : Cache apt dependencies
83- uses : awalsh128/cache-apt-pkgs-action@v1.6.0
84- with :
85- packages : protobuf-compiler build-essential
86- version : 1.0
87-
88- - name : Install python dependencies
89- run : python3 -m pip install protobuf grpcio-tools
90-
91- - name : Setup ccache
92- uses : hendrikmuhs/ccache-action@v1.2.20
93- with :
94- key : ${{ github.job }}-${{ matrix.os || 'ubuntu-latest' }}-mbedtls-3.6.5
77+ find src include tests examples -name "*.cpp" -o -name "*.h" | xargs clang-format --dry-run --Werror --style=file
9578
96- - name : Set reusable strings
97- id : strings
98- shell : bash
79+ - name : Run clang-tidy
80+ if : matrix.check == 'tidy'
9981 run : |
100- echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
101-
102- - name : Configure CMake
103- run : >
104- cmake -B ${{ steps.strings.outputs.build-output-dir }}
105- -DCMAKE_CXX_COMPILER=g++
106- -DCMAKE_C_COMPILER=gcc
107- -DCMAKE_BUILD_TYPE=Release
108- -DCMAKE_C_COMPILER_LAUNCHER=ccache
109- -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
110- -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
111- -S ${{ github.workspace }}
82+ find src -name "*.cpp" | xargs clang-tidy -p ${{ steps.strings.outputs.build-output-dir }} --header-filter="^(?!.*_deps).*" --quiet
11283
11384 - name : Build Library
114- run : cmake --build ${{ steps.strings.outputs.build-output-dir }} --config Release -j
85+ if : matrix.check == 'test'
86+ run : cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ env.BUILD_TYPE }} -j
11587
11688 - name : Run Tests
89+ if : matrix.check == 'test'
11790 working-directory : ${{ steps.strings.outputs.build-output-dir }}
118- run : ctest --build-config Release --output-on-failure --verbose
91+ run : ctest --build-config ${{ env.BUILD_TYPE }} --output-on-failure --verbose
11992
12093 - name : Build and run example
94+ if : matrix.check == 'test'
12195 run : |
12296 mkdir -p build-example && cd build-example
123- cmake ../examples/simple -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
124- cmake --build . --config Release
97+ cmake ../examples/simple -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
98+ cmake --build . --config ${{ env.BUILD_TYPE }}
12599 ./simple
0 commit comments