Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format code using clang-format #50

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
BasedOnStyle: WebKit
AlignAfterOpenBracket: Align
ColumnLimit: 120
CompactNamespaces: true
TabWidth: 4
UseTab: ForIndentation
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# EditorConfig: https://editorconfig.org

root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{c,cc,cpp,h}]
indent_style = tab
indent_size = 4
29 changes: 29 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---

name: Check for correct formatting

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
check_formatting:
runs-on: ubuntu-latest
container:
image: archlinux:latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: pacman --noconfirm -Syu diffutils findutils clang
- name: Run clang-format on all C and C++ sources
run: |
cp -av ../jack-example-tools ../jack-example-tools.orig
find . -type f \( -iname "*.c" -or -iname "*.cc" -or -iname "*.cpp" -or -iname "*.h" \) -exec clang-format -i {} \;
- name: Check whether there are differences
run: |
if test -n "$(diff -ruN ../jack-example-tools.orig ../jack-example-tools)"; then
diff -ruN ../jack-example-tools.orig ../jack-example-tools
exit 1
fi