---
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
ci:
  autoupdate_commit_msg: "ci: pre-commit autoupdate"
  skip: [mypy]

files: ^(anta|docs|scripts|tests|asynceapi)/

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v5.0.0
    hooks:
      - id: trailing-whitespace
        exclude: docs/.*.svg
      - id: end-of-file-fixer
      - id: check-added-large-files
        exclude: tests/data/.*$
      - id: check-merge-conflict

  - repo: https://github.com/Lucas-C/pre-commit-hooks
    rev: v1.5.5
    hooks:
      - name: Check and insert license on Python files
        id: insert-license
        # exclude:
        files: .*\.py$
        args:
          - --license-filepath
          - .github/license-short.txt
          - --use-current-year
          - --allow-past-years
          - --fuzzy-match-generates-todo
          - --no-extra-eol

      - name: Check and insert license on Markdown files
        id: insert-license
        files: .*\.md$
        exclude: ^tests/data/.*\.md$
        args:
          - --license-filepath
          - .github/license-short.txt
          - --use-current-year
          - --allow-past-years
          - --fuzzy-match-generates-todo
          - --comment-style
          - "<!--|  ~|  -->"

  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.10.0
    hooks:
      - id: ruff
        name: Run Ruff linter
        args: [--fix]
      - id: ruff-format
        name: Run Ruff formatter

  - repo: https://github.com/pycqa/pylint
    rev: "v3.3.5"
    hooks:
      - id: pylint
        name: Check code style with pylint
        description: This hook runs pylint.
        types: [python]
        args:
          - -rn # Only display messages
          - -sn # Don't display the score
          - --rcfile=pyproject.toml # Link to config file
        additional_dependencies:
          - anta[cli]
          - types-PyYAML
          - types-requests
          - types-pyOpenSSL
          - pylint_pydantic
          - pytest
          - pytest-codspeed
          - respx

  - repo: https://github.com/codespell-project/codespell
    rev: v2.4.1
    hooks:
      - id: codespell
        name: Checks for common misspellings in text files.
        entry: codespell
        language: python
        types: [text]
        args: ["--ignore-words", ".codespellignore"]

  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.15.0
    hooks:
      - id: mypy
        name: Check typing with mypy
        args:
          - --config-file=pyproject.toml
        additional_dependencies:
          - anta[cli]
          - types-PyYAML
          - types-requests
          - types-pyOpenSSL
          - pytest
        files: ^(anta|tests|asynceapi)/

  - repo: https://github.com/igorshubovych/markdownlint-cli
    rev: v0.44.0
    hooks:
      - id: markdownlint
        name: Check Markdown files style.
        args:
          - --config=.github/markdownlint.yaml
          - --ignore-path=.github/markdownlintignore
          - --fix

  - repo: local
    hooks:
      - id: examples-test
        name: Generate examples/tests.yaml
        entry: >-
          sh -c "docs/scripts/generate_examples_tests.py"
        language: python
        types: [python]
        files: anta/
        verbose: true
        pass_filenames: false
        additional_dependencies:
          - anta[cli]
      - id: doc-snippets
        name: Generate doc snippets
        entry: >-
          sh -c "docs/scripts/generate_doc_snippets.py"
        language: python
        types: [python]
        files: anta/cli/
        verbose: true
        pass_filenames: false
        additional_dependencies:
          - anta[cli]
