The simplest use of this image is to check source files in the current folder, after mounting it with `-v`. The example below checks all files in the current folder (`.`), and recursively (`-r`):
`docker run --rm -v $(pwd):/src witekio/clang-format-checker -r .`
Arguments after the image name are passed directly to `run-clang-format.py`. You can target multiple folders and files. The example below will recursively analyze files in the `src` and `includes` folder, as well as the file `main.cpp`.
`docker run --rm -v $(pwd):/src witekio/clang-format-checker -r src includes main.cpp`
## CI Integration
### BitBucket Pipeline
The following BitBucket Pipeline step will check for any style error in the `src` folder, and return an error if problems are found
```bitbucket-pipelines.yml
pipelines:
default:
- step:
name: Check code format
image: witekio/clang-format-checker
script:
- run-clang-format.py -r src
```
### GitLab CI Pipeline
The following GitLab CI step will check for any style error in the `src` folder, and return an error if problems are found
The style used by `clang-format` can be defined by providing a `.clang-format` file in your source folder. For more information, see [clang-format style options](https://clang.llvm.org/docs/ClangFormatStyleOptions.html)
This image relies on `run-clang-format`. For more information, you can check [`run-clang-format` official repository](https://github.com/Sarcasm/run-clang-format).
To build manually this image, you can clone this repository, and run `make`. Other supported Makefile targets are:
-`make build [TAG=latest]`: Build the image, and use the specified tag, or `latest`
-`make push [TAG=latest]`: Push the image to Docker HUB registry
-`make run [TAG=latest] [CMD="-r ."]`: Run the image locally after mounting the current folder. `run-clang-format` arguments can be customized with `CMD="<args>"`