Skip to content

Improve testing for pre-commit hooks #277

@klmcadams

Description

@klmcadams

Figure out a way to test the pre-commit hooks in the actions.

Currently, the content of the hooks are tested with pytest, but I have to test my hook changes locally by updating the .pre-commit-config.yaml file:

- repo: local
  hooks:
  - id: add-license-headers
    name: "Add License Headers"
    entry: add-license-headers
    language: python
    files: '(src|examples|tests)/.*\.(py)|\.(proto)'
    require_serial: true
    args:
    - --start_year=2023
    exclude: |
        (?x)^(
              tests/test_add_license_headers_files/bad_chars.py |
              tests/test_add_license_headers_files/index_error.scss
         )$

Next steps

  • Look at how hooks are tested in the pre-commit repository & do something similar?
  • Create dummy repos for each hook that tests all scenarios for add-license-headers and tech-review respectively

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions