Skip to content

howto pre commit

Ludovico Bianchi edited this page Jul 14, 2022 · 3 revisions

How to: set up pre-commit hooks

Explanation

What are pre-commit hooks?

  • Pre-commit hooks are scripts that are automatically run by Git "client-side" (i.e. on a developer's local machine) whenever git commit is run

How are pre-commit different from other automated code checks?

  • Pre-commit hooks are distinct (and, indeed, complementary) from "server-side" functionality, such as the check suite that is run when a local commit is pushed to the IDAES GitHub remote as part of the IDAES Continuous Integration (CI) workflow:
    • Pre-commit hooks run locally, before a commit is pushed
    • The IDAES CI check suite runs remotely (on GitHub), after a commit is pushed (typically to the head branch of an open PR)

How do I set up pre-commit hooks for IDAES?

  • IDAES uses the pre-commit framework to manage a few hooks that are useful for IDAES developers. Read below for instructions.

Set up (run once for every environment)

  • PR #911 must be merged in (or the files copied manually)
pip install -r requirements-dev.txt
pre-commit install

Run the pre-commit scripts manually

  • Useful to check if they work, etc
pre-commit run

More information

Clone this wiki locally