default_install_hook_types:
  - pre-commit
  - commit-msg
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v6.0.0
    hooks:
      # list of supported hooks: https://pre-commit.com/hooks.html
      - id: check-yaml
        args: ["--unsafe"]
        exclude: "examples/online_serving/chart-helm/templates/"
      - id: debug-statements
      - id: end-of-file-fixer
      - id: mixed-line-ending
        args: ["--fix=lf"]
      - id: trailing-whitespace
        args: ["--markdown-linebreak-ext=md"]

  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.14.10
    hooks:
    - id: ruff-check
      args: [--output-format, github, --fix]
    - id: ruff-format

  - repo: https://github.com/crate-ci/typos
    rev: typos-dict-v0.13.13
    hooks:
      - id: typos
        # only for staged files

  - repo: https://github.com/rhysd/actionlint
    # v1.7.8+ sets `go 1.24.0` in go.mod, which older Go toolchains (and most
    # current CI images) cannot parse. Pin to v1.7.7 until actionlint fixes the
    # go.mod directive.
    rev: v1.7.7
    hooks:
      - id: actionlint
        files: ^\.github/workflows/.*\.ya?ml$


  - repo: local
    hooks:
    - id: signoff-commit
      name: Sign-off Commit
      entry: bash
      args:
        - -c
        - |
          if ! grep -q "^Signed-off-by: $(git config user.name) <$(git config user.email)>" "$(git rev-parse --git-path COMMIT_EDITMSG)"; then
            printf "\nSigned-off-by: $(git config user.name) <$(git config user.email)>\n" >> "$(git rev-parse --git-path COMMIT_EDITMSG)"
          fi
      language: system
      verbose: true
      stages: [commit-msg]

    # Keep `suggestion` last
    - id: suggestion
      name: Suggestion
      entry: bash -c 'echo "To bypass all the pre-commit hooks, add --no-verify to git commit. To skip a specific hook, prefix the commit command with SKIP=<hook-id>."'
      language: system
      verbose: true
      pass_filenames: false
    # Insert new entries above the `suggestion` entry

    - id: check-pickle-imports
      name: Prevent new pickle/cloudpickle imports
      entry: python tools/pre_commit/check_pickle_imports.py
      language: python
      types: [python]
      additional_dependencies: [regex]
