fail_fast: true
repos:

    # Clear output from jupyter notebooks so that only the input cells are committed.
  - repo: local
    hooks:
      - id: jupyter-nb-clear-output
        name: Clear output from Jupyter notebooks
        description: Clear output from Jupyter notebooks.
        files: \.ipynb$
        stages: [commit]
        language: system
        entry: jupyter nbconvert --clear-output

    # prevents committing directly branches named 'main' and 'master'.
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.4.0
    hooks:
      - id: no-commit-to-branch
        name: Prevent main branch commits
        description: Prevent the user from committing directly to the primary branch.
      - id: check-added-large-files
        name: Check for large files
        description: Prevent the user from committing very large files.
        args: ['--maxkb=500']

    # verify that pyproject.toml is well formed
  - repo: https://github.com/abravalheri/validate-pyproject
    rev: v0.12.1
    hooks:
      - id: validate-pyproject
        name: Validate pyproject.toml
        description: Verify that pyproject.toml adheres to the established schema.
    # Analyze the src code style and report code that doesn't adhere.
  - repo: local
    hooks:
      - id: pylint
        name: pylint (python files in src/)
        entry: pylint
        language: system
        types: [python]
        files: ^src/
        args:
          [
            "-rn", # Only display messages
            "-sn", # Don't display the score
          ]
    # Analyze the tests code style and report code that doesn't adhere.
  - repo: local
    hooks:
      - id: pylint
        name: pylint (python files in tests/)
        entry: pylint
        language: system
        types: [python]
        files: ^tests/
        args:
          [
            "-rn", # Only display messages
            "-sn", # Don't display the score
          ]

    # Run unit tests, verify that they pass. Note that coverage is run against
    # the ./src directory here because that is what will be committed. In the 
    # github workflow script, the coverage is run against the installed package
    # and uploaded to Codecov by calling pytest like so:
    # `python -m pytest --cov=<package_name> --cov-report=xml`
  - repo: local
    hooks:
      - id: pytest-check
        name: Run unit tests
        description: Run unit tests with pytest.
        entry: bash -c "if python -m pytest --co -qq; then python -m pytest --cov=./src --cov-report=html; fi"
        language: system
        pass_filenames: false
        always_run: true