Add pre-commit template and basic pre-commit configuration
It adds two pre-commit jobs on MR pipelines if the project has a pre-commit configuration (located at .pre-commit-config.yaml)
pre-commit check
This job will make sure the configured pre-commit hooks are run on the files that changed between the code in the MR and the code on the target branch.
A patch in diff format will be generated as an artifact.
pre-commit apply
This job will apply the patch generated in the pre-commit check job and push it to the source branch of the MR
As @jonathang is off for a while, I push some changes to finish his works on this topic.
- This template will provide the 2 jobs describe above.
- Theses jobs can be disable individually at project level and/or allowed to fail (in case we need to unlock a CI)
- The apply job is only preset if we configure a specific token that can commit into the branch. This job is manual and is here to help people that don't use pre-commit locally to automatically fix their code if they need. Otherwise the git diff patch is available in the check job artifact
We choose to made this job "optional" as not everyone like to have a bot committing in his branch
Edited by Loic Nicolle