Improve testing for pre-commit hooks

Open
#277 0 comments 1 reaction 0 assignees View on GitHub

@klmcadams is already working on this.

Since Apr 23, 2026.

  • #421 by @klmcadams — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
30/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
testing, tooling

Research direction

Start with the existing pytest tests for the hooks and the .pre-commit-config.yaml setup, then compare the hook tests in the pre-commit repository. Focus on add-license-headers and tech-review, including the listed fixture scenarios and configuration. Done means dummy repositories exercise all relevant hook scenarios without requiring local configuration edits.

Written by the indexing model from the issue text.

Description

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
Dominant language
Python
Stars
5
Forks
1
Avg merge
1h 47m
Merged PRs (30d)
7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ansys/pre-commit-hooks

All issues in ansys/pre-commit-hooks

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.