1name: clang-format Check
2
3on: [push, pull_request]
4
5jobs:
6  # Building using the github runner environement directly.
7  clang-format:
8    runs-on: ubuntu-latest
9    steps:
10    - uses: actions/checkout@v2
11    - name: Fetch origin/master
12      run: git fetch origin master
13    - name: List of changed file(s)
14      run: git diff --name-only FETCH_HEAD
15
16    - name: Build clang-format docker
17      run: cd .github/workflows && docker build --tag=linter .
18    - name: Check clang-format
19      run: docker run --rm --init -v $(pwd):/repo linter:latest clang-format --version
20    - name: clang-format help
21      run: docker run --rm --init -v $(pwd):/repo linter:latest clang-format --help
22
23    - name: Check current commit
24      run: docker run --rm --init -v $(pwd):/repo -w /repo linter:latest sh -c "git diff --diff-filter=d --name-only FETCH_HEAD | grep '\.c$\|\.h$\|\.cc$' | xargs clang-format --style=file --dry-run --Werror "
25