DoozyX / clang-format-lint-action

This action checks if the source code matches the .clang-format file.
MIT License
129 stars 46 forks source link

Save formatted files (with the `clang-format -i`) #17

Closed johnboiles closed 3 years ago

johnboiles commented 3 years ago

See also #4

This patch uses clang-format -i to save the formatted files back to disk instead of returning a diff.

This should probably be paired with a GitHub action to commit the change (such as EndBug/add-and-commit). Here's an example yml file

name: Run clang-format Linter

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - uses: johnboiles/clang-format-lint-action@inplace
      with:
        source: '.'
        exclude: './lib'
        extensions: 'h,cpp,c'
        clangFormatVersion: 11
        inplace: True
    - uses: EndBug/add-and-commit@v4
      with:
        author_name: Clang Robot
        author_email: robot@example.com
        message: 'Committing clang-format changes'
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DoozyX commented 3 years ago

Thank you