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

Add Formatter #119

Open
LuchoBazz opened this issue Jun 7, 2024 · 0 comments
Open

Add Formatter #119

LuchoBazz opened this issue Jun 7, 2024 · 0 comments

Comments

@LuchoBazz
Copy link
Owner

LuchoBazz commented Jun 7, 2024

clang-format -style='{IndentWidth: 4, ColumnLimit: 80}' -i A.cpp 

file: .clang-format

BasedOnStyle: LLVM
IndentWidth: 4
ColumnLimit: 80

.github/workflows/clang-format.yml

name: Clang-Format Check

on:
  pull_request:
    branches:
      - main
      - master
  push:
    branches:
      - main
      - master

jobs:
  clang-format:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2

    - name: Set up clang-format
      run: sudo apt-get install -y clang-format

    - name: Run clang-format
      run: |
        # Find all C++ source files and check if they comply with the format
        FILES=$(find . -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -o -name '*.c')
        for file in $FILES; do
          clang-format --style=file $file | diff -u $file -
        done

    - name: Fail if format is incorrect
      run: |
        FILES=$(find . -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -o -name '*.c')
        for file in $FILES; do
          if ! clang-format --style=file $file | diff -u $file -; then
            echo "Formatting error in $file"
            exit 1
          fi
        done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant