-
Notifications
You must be signed in to change notification settings - Fork 10
38 lines (31 loc) · 1.02 KB
/
format.yml
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
name: check format
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types:
- published
jobs:
formatting:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: install jq
run: |
sudo apt install jq
- name: set CLANG_FORMAT_COMMAND
run: | # extract the clang format command from the CMakePresets.json
CLANG_FORMAT_COMMAND=$(jq -r '.configurePresets[] | select(.name == "clang-preset") | .cacheVariables.CMAKE_C_COMPILER' CMakePresets.json)
- name: install clang-format
run: |
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
sudo apt install -y --no-install-recommends $CLANG_FORMAT_COMMAND
- name: format files
run: find -name "*.cc" -o -name "*.h" -print0 | xargs -0 $CLANG_FORMAT_COMMAND -i
- name: Check for differences
run: |
git status --porcelain
git diff
git status --porcelain | xargs -I {} -0 test -z \"{}\"