Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/doozyx/clang-format-lint-action
This action checks if the source code matches the .clang-format file.
https://github.com/doozyx/clang-format-lint-action
actions ci clang-format cpp github-action github-actions hacktoberfest lint linter
Last synced: 6 days ago
JSON representation
This action checks if the source code matches the .clang-format file.
- Host: GitHub
- URL: https://github.com/doozyx/clang-format-lint-action
- Owner: DoozyX
- License: mit
- Created: 2019-10-18T16:54:16.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-04T22:07:09.000Z (4 months ago)
- Last Synced: 2024-10-29T17:29:07.271Z (about 2 months ago)
- Topics: actions, ci, clang-format, cpp, github-action, github-actions, hacktoberfest, lint, linter
- Language: Python
- Homepage:
- Size: 16.3 MB
- Stars: 134
- Watchers: 6
- Forks: 51
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# clang-format lint action
This action checks if the source code matches the .clang-format file.
## Inputs
### `source`
Where the source files are located.\
Default: '.' (current folder)\
Example: './src' or 'src test examples' for multiple.### `exclude`
What folder should be excluded from format checking.\
Default: 'none'\
Example: './third_party' or 'third_party exclude' for multiple.Multiple exclude rules can also be put in a `.clang-format-ignore` file, which also supports comments.\
Example:
```
# ignore third_party code from clang-format checks
./src/third_party/*
./src/ignored/*
```### `extensions`
What filename extensions should be used for format checking.\
Default: 'c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx'\
Example: 'cpp,h'### `clangFormatVersion`
What clang-format version should be used.\
Available version are\
5,6,7,8,9,10,11(11.0.0),11.0.0, 11.1.0, 12(12.0.1), 12.0.0, 12.0.1, 13(13.0.0), 13.0.0, 14(14.0.0), 14.0.0, 15(15.0.2), 15.0.2, 16(16.0.3), 16.0.0, 16.0.3, 17(17.0.4), 17.0.4, 18(18.1.8), 18.1.3, 18.1.8\
Default: 18\
Example: 15### `style`
Style to use.\
Results in the appropriate --style parameter.\
Default: file\
Example: chromium### `inplace`
Whether to change the files on the disk instead of writing to disk.\
This is the same as `clang-format -i`\
Default: False\You probably want to pair this with a GitHub action (such as [`EndBug/add-and-commit`](https://github.com/EndBug/add-and-commit)) to commit the changed files. For example:
```yml
name: Run clang-format Linteron: [push]
jobs:
build:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v2
- uses: DoozyX/[email protected]
with:
source: '.'
exclude: './lib'
extensions: 'h,cpp,c'
clangFormatVersion: 16
inplace: True
- uses: EndBug/add-and-commit@v9
with:
author_name: Clang Robot
author_email: [email protected]
message: 'Committing clang-format changes'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```## Example usage
```yml
name: test-clang-formaton: [push]
jobs:
build:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@v2
- uses: DoozyX/[email protected]
with:
source: '.'
exclude: './third_party ./external'
extensions: 'h,cpp'
clangFormatVersion: 18
style: chromium
```## Run locally
Install Docker and then run:
```bash
docker build -t clang-format-lint github.com/DoozyX/clang-format-lint-action
```When the image is built, run the linting:
```bash
docker run -it --rm --workdir /src -v $(pwd):/src clang-format-lint \
--clang-format-executable /clang-format/clang-format9 -r --exclude .git .
```Actions clion format binary are from https://github.com/muttleyxd/clang-tools-static-binaries