-
Notifications
You must be signed in to change notification settings - Fork 4
35 lines (33 loc) · 1.05 KB
/
format-checker.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
name: Check Formatting
on: [pull_request]
jobs:
check-format:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v1
with:
submodules: true
- name: Install dependencies from APT
run: |
set -e # Add this line
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 18
sudo apt install -y git clang-format-18
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-18 100
sudo update-alternatives --set clang-format /usr/bin/clang-format-18
- name: Check Formatting
run: |
set -e # Add this line
cd ${{ github.workspace }}
git reset --soft $(git merge-base HEAD origin/master)
diff=$(git clang-format-18 --style=file --diff)
if [ $(echo "${diff}" | wc -l) -gt 0 ]; then
echo "Formatting errors detected! Suggested changes:"
echo "${diff}"
exit 5
else
echo "No formatting errors detected!"
exit 0
fi