Adding the clang format to the CI #51
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 | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| workflow_dispatch: | |
| defaults: | |
| run: | |
| shell: bash | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| clang-format-check: | |
| name: Check code formatting | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install clang-format | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang-format | |
| - name: Run clang-format check | |
| run: | | |
| clang-format --version | |
| files=$(git ls-files '*.cc' '*.cpp' '*.h' '*.hpp') | |
| [ -z "$files" ] || clang-format --dry-run --Werror $files | |
| build: | |
| name: Bazel tests | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| needs: [clang-format-check] # Don't run build if format check fails | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Bazel | |
| uses: bazel-contrib/setup-bazel@0.14.0 | |
| with: | |
| bazelisk-cache: true | |
| disk-cache: ${{ github.workflow }} | |
| repository-cache: true | |
| - name: Install clang-format (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang-format | |
| - name: Install clang-format (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install clang-format | |
| - name: Bazel tests | |
| run: bazel test src:all |