build icon indicating copy to clipboard operation
build copied to clipboard

chore: add git hooks & code lint

Open littlecxm opened this issue 2 years ago • 4 comments

Description

add code & formatter and commit message lint AR-1130

1.Install

lefthook,shellcheck and shfmt

2.Config

just run lefthook install && lefthook run pre-commit in project root dir to enable git hooks

3.Result

  • Wrong commit message: Untitled

  • Illegal bash: (e.g:) image

Untitled1

littlecxm avatar Mar 27 '22 03:03 littlecxm

Cool utility to help improve code quality (general Jira https://armbian.atlassian.net/browse/AR-1130) , but as @lanefu pointed out - for the acceptance, integration is crucial. Can be done as build host extension:

https://github.com/armbian/build/blob/master/lib/main.sh#L465 https://docs.armbian.com/Developer-Guide_Extensions/

Implementation example: https://github.com/armbian/build/pull/3572

igorpecovnik avatar Mar 27 '22 07:03 igorpecovnik

lol looks works fine and I messed up some

littlecxm avatar Mar 27 '22 16:03 littlecxm

I have somewhat related stuff in armbian-next, for automated download/install/run of shellfmt and shellcheck, but I did not touch the hooks part. I really think it's better to leave the checking to a GH PR handler, and PR's will be rejected if they're not formatted. I guess lefthook is somewhat similar to pre-commit which I investigated and gave up on (requires too much developer setup)....

rpardini avatar Mar 31 '22 13:03 rpardini

I have somewhat related stuff in armbian-next, for automated download/install/run of shellfmt and shellcheck, but I did not touch the hooks part. I really think it's better to leave the checking to a GH PR handler, and PR's will be rejected if they're not formatted. I guess lefthook is somewhat similar to pre-commit which I investigated and gave up on (requires too much developer setup)....

yeah I compare with husky lefthook pre-commit, the lefthook is easy for use, and when you not install it wont works, but code format and lint is strong recommend for community project

there are many benefits in the commit convention, can see more: https://www.conventionalcommits.org

littlecxm avatar Mar 31 '22 14:03 littlecxm

@littlecxm What's the state of this thing do you need a help or something

Kreyren avatar Mar 04 '23 17:03 Kreyren

@littlecxm What's the state of this thing do you need a help or something

need CI test & git hook for auto code format test!

littlecxm avatar Apr 10 '23 08:04 littlecxm

succesor #4952, closed

littlecxm avatar May 04 '23 09:05 littlecxm