Skip to content

Add pre commit hooks#83

Open
ewu63 wants to merge 12 commits into
mainfrom
add-pre-commit-hooks
Open

Add pre commit hooks#83
ewu63 wants to merge 12 commits into
mainfrom
add-pre-commit-hooks

Conversation

@ewu63

@ewu63 ewu63 commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Purpose

This PR adds a custom set of pre-commit hooks which vendor the lab-preferred config files. This allows repos to directly use these hooks without having to have a local copy of each config file per repo. The outcome should be identical to the CI workflows. Note that the root pyproject.toml had to be added to make this a package for pre-commit, and I had to move the config files into a sub-directory so it can be packaged.
The next steps would be:

  1. Add pre-commit-config.yaml to all relevant repos to enable local dev
  2. Update the CI scripts to simply install and run pre-commit. This can be done in lightweight GHA workflows without maintaining a duplicate Azure set.
  3. Once stable, we should be careful to tag this repo. A git ref can be used to reference the specific rev of the pre-commit workflow to be used, for stability.

There are some minor behaviour differences with existing workflows

  • ignoring specific AD files, this can be done in specific repos via the exclude option to pre-commit
  • pinning specific tool versions, previously only some were pinned.

Expected time until merged

As long as it takes to review. This should not break any existing workflows but may take some time to test that the pre-commit works as expected.

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (non-backwards-compatible fix or feature)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Documentation update
  • Maintenance update
  • Other (please describe)

Testing

The command try-repo can be used, e.g. if .github is in a folder parallel with say pyoptsparse:

pre-commit try-repo ../.github mdolab-ruff-check --all-files

Checklist

  • I have run ruff check and ruff format to make sure the Python code adheres to PEP-8 and is consistently formatted
  • I have formatted the Fortran code with fprettify or C/C++ code with clang-format as applicable
  • I have run unit and regression tests which pass locally with my changes
  • I have added new tests that prove my fix is effective or that my feature works
  • I have added necessary documentation

@ewu63 ewu63 requested a review from a team as a code owner June 21, 2026 04:56
@ewu63 ewu63 requested review from A-CGray, eirikurj and sanjan98 and removed request for a team, A-CGray and sanjan98 June 21, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant