dev #133
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| 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 clang | |
| - check: tidy | |
| check-name: Tidy Check | |
| packages: protobuf-compiler build-essential clang clang-tidy cmake | |
| - check: test | |
| check-name: Build and Test | |
| packages: protobuf-compiler build-essential cmake | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Cache apt dependencies | |
| uses: awalsh128/cache-apt-pkgs-action@v1.6.0 | |
| with: | |
| packages: ${{ matrix.packages }} | |
| version: 1.0 | |
| - name: Install python dependencies | |
| if: matrix.check == 'test' | |
| 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: | | |
| find src include tests examples -name "*.cpp" -o -name "*.h" | xargs clang-format --dry-run --Werror --style=file | |
| - name: Run clang-tidy | |
| if: matrix.check == 'tidy' | |
| run: | | |
| find src -name "*.cpp" | xargs -P $(nproc) clang-tidy -p ${{ steps.strings.outputs.build-output-dir }} --header-filter="^(?!.*/(build|_deps|generated)/).*" --quiet | |
| - 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 == 'test' | |
| 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 |