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 3d7f71e3 authored by Dorian Turba's avatar Dorian Turba
Browse files

add pre-commit autoupdate

parent bf7bec0d
No related branches found
No related tags found
No related merge requests found
files:
template: ../templates/python/code_quality/pre-commit-autoupdate/pre-commit-autoupdate.yml
documentation: ../templates/python/code_quality/pre-commit-autoupdate/README.md
data:
description: "Run pre-commit autoupdate on your repository"
icon: 🔄
public: true
labels:
- Utilities
- Robustness
license: MIT
deprecated: false
# pre-commit template
## Objective
Run [pre-commit autoupdate](https://pre-commit.com/#pre-commit-autoupdate) on your
project. `pre-commit` is a Python framework for managing and maintaining multi-language
pre-commit hooks. `pre-commit autoupdate` will check if your pre-commit hooks are
up-to-date. If not, an update should be performed.
## 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-autoupdate 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"` |
| `AUTOUPDATE_CMD` | Bash commands to run pre-commit autoupdate | `"pre-commit autoupdate"` |
## 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: version_management
variables:
PYTHON_SETUP: "pip install pre-commit"
PRE_COMMIT_INSTALL: "pre-commit install"
AUTOUPDATE_CMD: "pre-commit autoupdate"
script:
- !reference [.python_install, script]
- ${PRE_COMMIT_INSTALL}
- ${AUTOUPDATE_CMD}
- git diff --exit-code
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