Aller au contenu

pre-commit

Configuration

.pre-commit-config.yaml
fail_fast: false
repos:
  - repo: https://github.com/compilerla/conventional-pre-commit
    rev: v3.6.0
    hooks:
      - id: conventional-pre-commit
        stages: [commit-msg]
        args: ["--force-scope", "--strict"]
  - repo: https://github.com/commitizen-tools/commitizen
    rev: v4.0.0
    hooks:
      - id: commitizen
        stages: [commit-msg]
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v5.0.0
    hooks:
      - id: check-added-large-files
        args: ["--maxkb=1000"]
      - id: check-json
      - id: pretty-format-json
        args: ["--autofix", "--indent=4", "--no-sort-keys"]
      - id: check-merge-conflict
      - id: check-toml
      - id: check-xml
      - id: check-yaml
      - id: end-of-file-fixer
      - id: name-tests-test
      - id: sort-simple-yaml
      - id: trailing-whitespace
      - id: mixed-line-ending
        args: ["--fix=lf"]
        description: Forces to replace line ending by the UNIX 'lf' character.

Mise à jour des hooks

pre-commit autoupdate

Configuration de GitHub Actions

.github/workflows/pre-commit.yml
name: pre-commit

on:
  pull_request:

jobs:
  pre-commit:
    name: "Check code quality"
    runs-on: ubuntu-latest

    steps:
      - name: Check out
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}"

      - name: Run pre-commit
        uses: pre-commit/action@v3.0.0
        with:
          extra_args: --all-files

Ressources