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

Pr formatting #121

Closed
wants to merge 13 commits into from
Closed
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
21 changes: 21 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Setup
Language: Cpp
BasedOnStyle: LLVM
IndentWidth: 4
TabWidth: 4
UseTab: Never
ColumnLimit: 80

# MultiLine / Packing configuration
PackConstructorInitializers: NextLine
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: None
AllowShortIfStatementsOnASingleLine: true

# Braces and wrapping styles
BreakBeforeBraces: Custom
BraceWrapping:
AfterControlStatement: MultiLine
BeforeElse: true
BeforeCatch: true
35 changes: 35 additions & 0 deletions .github/workflows/clangformat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# ClangFormat
# Author: Eliot Hall
# This program formats all cpp files in the repository
name: ClangFormat

on:
pull_request:
branches: ["master"]

jobs:
format:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Format .cpp and .hpp files
run:
# don't include .c* since that would format .clang-format
clang-format -style=file:${{github.workspace}}/.clang-format -i
$(find ${{github.workspace}} -name "*.h*")
$(find ${{github.workspace}} -name "*.c")
$(find ${{github.workspace}} -name "*.cpp")
- name: Setup git config
run: |
git config user.name "Clang Formatter Bot"
git config user.email ""
- name: Push to GitHub
run: |
git add -A
git diff --quiet HEAD || git commit -m "AutoFormat with clang-format"
git push origin HEAD:${{github.head_ref}}