Skip to content

Add Formatter #119

Open
Open
@LuchoBazz

Description

@LuchoBazz
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions