Run pre-commit hooks at CI level
Place a .pre-commit-config.yaml
at the root of your project
Create a new GitHub workflow:
# .github/workflows/pre-commit.yml
on:
pull_request:
jobs:
pre-commit:
name: "pre-commit"
runs-on: ubuntu-latest
steps:
- uses: SonarSource/[email protected] <--- replace with the last tag
with:
extra-args: >
--from-ref=origin/${{ github.event.pull_request.base.ref }}
--to-ref=${{ github.event.pull_request.head.sha }}
Notice: the extra-args parameter defined upper ensure that only files changed within the PR are checked by pre-commit. If you rather like to ensure that all files are valid, have a look at the example below.
Place a .pre-commit-config.yaml
at the root of your project
Create a new GitHub workflow:
# .github/workflows/pre-commit.yml
on:
branch:
- master
jobs:
pre-commit:
name: "pre-commit"
runs-on: ubuntu-latest
steps:
- uses: SonarSource/[email protected] <--- replace with last tag
with:
extra-args: --all-files
Option name | Description | Default |
---|---|---|
config-path |
Used to specify a custom path to a given .pre-commit-config.yaml |
.pre-commit-config.yaml |
extra-args |
Used to pass extra pre-commit args to the pre-commit run command | - |
ignore-failure |
Used to not fail the gh-action in case of pre-commit check failure | false |
This project is using Semantic Versioning.
The master
branch shall not be referenced by end-users,
please use tags instead and Renovate or
Dependabot to stay up to date.
Contributions are welcome, please have a look at DEV.md