Skip to content

Commit fd7f078

Browse files
committed
Add workflow for checking clang-format
1 parent ee0e0d7 commit fd7f078

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

.github/workflows/lint.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: lint
2+
3+
on: [push]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
13+
- name: clang-format
14+
id: clang-format
15+
uses: DoozyX/clang-format-lint-action@c3b2c943e924028b93a707a5b1b017976ab8d50c # v0.15
16+
with:
17+
exclude: './third_party'
18+
extensions: 'c,h,cpp,hpp'
19+
clangFormatVersion: 15
20+
style: file
21+
22+
- name: clang-format instructions
23+
if: ${{ failure() && steps.clang-format.outcome == 'failure' }}
24+
run: |
25+
# Instructions for fixing the formatting errors
26+
echo -e "\n\033[0;31mTo fix the formatting, run:\nclang-format -style=file -i \$(git ls-files \"*.c\" \"*.h\" \"*.cpp\" \"*.hpp\")\033[0m\n"
27+
exit 1

third_party/.clang-format

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Disable clang-format in this folder
2+
DisableFormat: true
3+
SortIncludes: Never

0 commit comments

Comments
 (0)