Skip to content

Using pre-commit hooks #390

Closed
Closed

Description

@knoepfel

We use a variety of formatting tools for the code in the phlex repository, which is written in C++, Python, YAML, CMake, Jsonnet, etc. Although there is a comment-based GitHub action that can apply formatting conventions to the pull request, we should consider incorporating https://pre-commit.com into our development workflow.

Activity

  1. added
    discussion
    developer workflow
    on Mar 5, 2026
  2. olantwin commented on Mar 5, 2026

    @olantwin
    Contributor

    We've made very positive experiences with pre-commit in SHiP, both for C++ and Python code.

    I can prepare a PR with the first few hooks (e.g. clang-format, yaml syntax checking, ruff format, file endings, trailing whitespace) tomorrow.
    I also saw that there's a hook for jsonnetfmt, but it seems unmaintained.

    Would you also be interested in using the CI service? It's free for public github projects and very convenient.

  3. knoepfel commented on Mar 10, 2026

    @knoepfel
    MemberAuthor

    Agreement at developer retreat: Using pre-commit would benefit our development workflow. Right now, the pre-commit steps should apply formatting changes only (and only for the changed files). Two points:

    1. We do not think using the pre-commit CI is necessary right now.
    2. The pre-commit configuration should stay in sync with other configurations used to achieve similar purposes; ideally, this would be a single point of maintenance within the repository.
  4. olantwin commented on Mar 10, 2026

    @olantwin
    Contributor

    Agreement at developer retreat: Using pre-commit would benefit our development workflow. Right now, the pre-commit steps should apply formatting changes only (and only for the changed files).

    When installed as a pre-commit hook, the hooks only run over the staged files.

    Two points:

    1. We do not think using the pre-commit CI is necessary right now.

    OK.

    1. The pre-commit configuration should stay in sync with other configurations used to achieve similar purposes; ideally, this would be a single point of maintenance within the repository.

    At least the ruff and clang-format hooks reuse the same configuration as the CI, so no additional maintenance should be needed (apart from potentially updating the version every now and again).

    I'll make a small PR to start with ruff format (no check) and clang-format. We can then expand from there.

  5. linked a pull request that will close this issueAdd minimal pre-commit config #406on Mar 10, 2026
  6. removed
    discussion
    on Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    developer workflow

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions