-
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Michał Cieślar <[email protected]>
- Loading branch information
1 parent
9ffffaa
commit 9d578b8
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: clang-format Check | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
paths: | ||
- 'src/**/*.cpp' | ||
- 'src/**/*.h' | ||
- 'include/**/*.h' | ||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- 'src/**/*.cpp' | ||
- 'src/**/*.h' | ||
- 'include/**/*.h' | ||
|
||
jobs: | ||
check_formatting: | ||
name: Check Code Formatting | ||
runs-on: ubuntu-24.04 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Cache clang-format dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: /tmp/apt-cache | ||
key: clang-format-${{ runner.os }}-${{ hashFiles('**/apt-packages.txt') }} | ||
restore-keys: | | ||
clang-format-${{ runner.os }}- | ||
- name: Install clang-format | ||
run: | | ||
if [ ! -f /tmp/apt-cache/clang-format-18 ]; then | ||
sudo apt-get update | ||
sudo apt-get install -y clang-format-18 | ||
touch /tmp/apt-cache/clang-format-18 | ||
fi | ||
- name: Run clang-format | ||
run: | | ||
clang-format src/**/*.cpp src/**/*.h include/**/*.h -i -style=file | ||
- name: Check for unformatted files | ||
run: | | ||
git diff --exit-code || (echo "Code is not formatted correctly" && exit 1) |