GithubHelp home page GithubHelp logo

kp-pre-commit-hooks's Introduction

pre-commit-hooks

Some out-of-the-box hooks for pre-commit, and a github action to easily run all kind of hooks from github CI.

Using pre-commit-hooks with pre-commit

Add this to your .pre-commit-config.yaml

    -   repo: https://github.com/Kpler/kp-pre-commit-hooks.git
        rev: v0.0.7  # Use the ref you want to point at
        hooks:
        -   id: check-branch-linearity
        -   id: check-branch-name
        -   id: no-ephemeral-links
            exclude: '\.md$'

Hooks available

check-branch-linearity

Simply check that your branch doesn't not contain any merge compare to a target branch, main by default. It's a pre-push hook and will always run

To configure the target branch:

    hooks:
    -   id: check-branch-linearity
        args: [targetbranch]

check-branch-name

Check that branch name is less than 70 characters It's a pre-push hook and will always run

no-ephemeral-links

Time is fleeting, we change services. Consequently to keep the code futureproof we don't want links to ephemeral thrid party stuff (slack, clubhouse, atlassian)

fastapi-generate-openapi-specification

Generate the Open API spec from a Fast API. If it has changed, write the new one and fails. If not, succeeds.

kafka-check-schemas

Check that the Kafka schemas present in the schemas/ folder are consistent with the code.

This hook currently only supports the scala language for now and relies on the presence of the sbt generateKafkaSchemas command to re-generate and compare the schemas.

The implementation of the generateKafkaSchemas is up to each project, but you can find an example of implementation in the template-kafka-stream-msk project with the corresponding sbt command defined in the build.sbt file

Add these lines in your .pre-commit-config.yaml file to enable this pre-commit hook:

repos:
  # [...]
  - repo: https://github.com/Kpler/kp-pre-commit-hooks.git
    rev: v0.22.0
    hooks:
      # [...]
      - id: kafka-check-schemas

Contributing

Debugging / testing

Hooks can be tried locally using try-repo For example if I want to try check-branch-linearity from another repo I can do:

pre-commit try-repo path_to_this_repo/kp-pre-commit-hooks/ check-branch-linearity --hook-stage push --verbose

kp-pre-commit-hooks's People

Contributors

leo-dur avatar yannrouillard avatar vl-kp avatar hnomichith avatar gregoirechauvet avatar gmocquet avatar dependabot[bot] avatar namsam avatar

Watchers

Alexandre Gindre avatar James Cloos avatar  avatar  avatar Prasad Hewage avatar Chris Buenger avatar linh avatar Pierre Karpov avatar Nicolas Guignard avatar  avatar  avatar  avatar Petar Todorov avatar Jivan Roquet avatar  avatar Preetwinder Singh avatar George Charikiopoulos avatar Germain avatar George avatar  avatar  avatar

Forkers

vl-kp

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.