Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit a55f734e authored by Dorian Turba's avatar Dorian Turba
Browse files

add pre-commit

parent 132bad37
No related branches found
No related tags found
No related merge requests found
Pipeline #28706 canceled
files:
template: ../templates/python/code_quality/pre-commit/pre-commit.yml
documentation: ../templates/python/code_quality/pre-commit/README.md
data:
description: "Run pre-commit on your repository"
icon: ⚠️
public: true
labels:
- Utilities
- Code Quality
- Robustness
- Security
- Spelling
license: MIT
deprecated: false
# pre-commit template
## Objective
Run [pre-commit](https://pre-commit.com/) on your project. `pre-commit` is a Python
framework for managing and maintaining multi-language pre-commit hooks.
## How to use it
1. Configure the `.pre-commit-config.yaml` file in your repository's root directory with
your desired hooks.
2. Include the pre-commit template in your CI/CD configuration (see quick use above).
3. If you need to customize the job, check
the [jobs customization](https://docs.r2devops.io/get-started/use-templates/#job-templates-customization).
## Variables
| Name | Description | Default |
|----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------|
| `PYTHON_SETUP` | Bash commands to setup your python environment with pre-commit. | `"pip install pre-commit"` |
| `IMAGE_TAG` | The default tag for the docker image. See [Python Docker Official Image](https://hub.docker.com/_/python) for supported tags and respective Dockerfile links. | `"latest"` |
| `PRE_COMMIT_INSTALL` | Bash commands to install pre-commit. | `"pre-commit install"` |
| `PRE_COMMIT_RUN` | Bash commands to run pre-commit. | `"pre-commit run --all-files"` |
## Configuration of pre-commit
To add configuration to `pre-commit`, you can add a `.pre-commit-config.yaml` file to
the root of your repository. This file will be used by `pre-commit` to configure the
hooks.
include:
- remote: 'https://api.r2devops.io/job/r/gitlab/dorianturba-templates/r2devops_catalog/r2_metadata/python_install@latest.yaml'
pre-commit:
extends:
- .python_install
stage: code_quality
variables:
PYTHON_SETUP: "pip install pre-commit"
PRE_COMMIT_INSTALL: "pre-commit install"
PRE_COMMIT_RUN: "pre-commit run --all-files"
script:
- !reference [.python_install, script]
- ${PRE_COMMIT_INSTALL}
- ${PRE_COMMIT_RUN}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment