Newer
Older
> Executes all configured [pre-commit][pre-commit] hooks in the CI
```yaml
include:
- component: gitlab.arm.com/ci/component/pre-commit@<version>"
Execute the `pre-commit` hooks as part of the `test` stage to prevent any regressions in the repository. It is
recommended to set the GitLab merge requests to [prevent merging unless the pipeline has passed][prevent-merge].
The `.pre-commit` job will use the `pre-commit` container from the container registry for the same tag as the component version
used.
The image can be overridden with the [image][image] keyword in the `.gitlab-ci.yml`:
```yaml
include:
- component: "gitlab.arm.com/ci/component/pre-commit@<version>"
inputs:
image: registry.gitlab.arm.com/ci/component/pre-commit
job:
extends: .pre-commit
```
### Configuration
`pre-commit` hooks can be added to the `.pre-commit-config.yaml`. See the [documentation][plugins] for adding plugins to the project.
We have a _pre-configured, recommended hooks_ at pre-commit/hooks. It is **highly recommended** to use those.
[pre-commit]: https://gitlab.arm.com/ci/component/pre-commit/-/blob/main/README.md?ref_type=heads
[plugins]: https://pre-commit.com/#plugins
[prevent-merge]: https://docs.gitlab.com/ee/user/project/merge_requests/auto_merge.html#:~:text=Select%20Settings%20%3E%20Merge%20requests.,Select%20Save.
[image]: https://docs.gitlab.com/ee/ci/yaml/#image