Skip to content

Commit bc1bfa3

Browse files
committed
GitHub Actions: Add workflow to run clang-format
1 parent d5eb954 commit bc1bfa3

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

.github/workflows/stylecheck.yml

+48
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,51 @@ jobs:
6666
git diff --color=always --minimal
6767
exit 1
6868
fi
69+
70+
clang-format:
71+
runs-on: ubuntu-latest
72+
73+
env:
74+
LLVM_VERSION: 17
75+
76+
steps:
77+
- name: Checkout
78+
uses: actions/checkout@v4
79+
with:
80+
fetch-depth: 0
81+
82+
- name: Install clang-format
83+
run: |
84+
wget https://apt.llvm.org/llvm.sh
85+
chmod +x llvm.sh
86+
sudo ./llvm.sh ${{ env.LLVM_VERSION }}
87+
rm -rf llvm.sh
88+
sudo apt install clang-format-${{ env.LLVM_VERSION }}
89+
git config --global clangFormat.binary "clang-format-${{ env.LLVM_VERSION }}"
90+
91+
- name: Fix formatting (pull_request)
92+
if: ${{ github.event_name == 'pull_request' }}
93+
continue-on-error: true
94+
run: git clang-format-${{ env.LLVM_VERSION }} ${{ github.event.pull_request.base.sha }} --verbose
95+
96+
- name: Fix formatting (push)
97+
if: ${{ github.event_name == 'push' }}
98+
continue-on-error: true
99+
run: git clang-format-${{ env.LLVM_VERSION }} HEAD~1 --verbose
100+
101+
- name: Ignore changes in external code
102+
run: |
103+
git restore ./Externals
104+
git restore ./res
105+
git restore ./sdk
106+
git restore ./src/utils/mp_gpprof_server/libraries
107+
108+
- name: Report result
109+
run: |
110+
if [ -z "$(git status -s)" ]; then
111+
echo Everything seems to be in order
112+
else
113+
echo Formatting problems found!
114+
git diff --color=always --minimal
115+
exit 1
116+
fi

0 commit comments

Comments
 (0)