mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 14:58:13 +08:00
github/workflows/check.yml: Enhance checkpatch for breaking change labels
- Updated the check workflow to conditionally include a '-b' option for breaking change enforcement based on PR labels. - Modified the checkpatch script to support reading commit messages from stdin when using the '-m -g' flags. - Improved usage instructions to clarify the new stdin option for commit message checks. Signed-off-by: Arjav Patel <arjav1528@gmail.com>
This commit is contained in:
@@ -45,5 +45,9 @@ jobs:
|
||||
cd nuttx
|
||||
commits="${{ github.event.pull_request.base.sha }}..HEAD"
|
||||
git log --oneline $commits
|
||||
echo "../nuttx/tools/checkpatch.sh -c -u -m -g $commits"
|
||||
../nuttx/tools/checkpatch.sh -c -u -m -g $commits
|
||||
breaking_opts=""
|
||||
if echo '${{ toJSON(github.event.pull_request.labels) }}' | jq -e 'any(.[].name; test("breaking change"; "i"))' >/dev/null 2>&1; then
|
||||
breaking_opts="-b"
|
||||
fi
|
||||
echo "../nuttx/tools/checkpatch.sh -c -u -m -g $breaking_opts $commits"
|
||||
../nuttx/tools/checkpatch.sh -c -u -m -g $breaking_opts $commits
|
||||
|
||||
+11
-1
@@ -60,6 +60,7 @@ usage() {
|
||||
echo "-m Check commit message (coupled with -g)"
|
||||
echo "-b Enforce breaking change format when checking commit message (requires -m -g; use when PR has breaking change label)"
|
||||
echo "-g <commit list>"
|
||||
echo " Use --stdin as the only argument with -m -g to read commit message from stdin (message-only check, no patch/diff)."
|
||||
echo "-f <file list>"
|
||||
echo "-x format supported files (only .py, requires: pip install black)"
|
||||
echo "- read standard input mainly used by git pre-commit hook as below:"
|
||||
@@ -286,6 +287,7 @@ check_patch() {
|
||||
check_msg() {
|
||||
signedoffby_found=0
|
||||
num_lines=0
|
||||
# Commit subject line length limit (50/72 are common; NuttX uses 80)
|
||||
max_line_len=80
|
||||
min_num_lines=5
|
||||
breaking_change_found=0
|
||||
@@ -420,6 +422,9 @@ while [ ! -z "$1" ]; do
|
||||
-h )
|
||||
usage 0
|
||||
;;
|
||||
--stdin )
|
||||
break
|
||||
;;
|
||||
-p )
|
||||
check=check_patch
|
||||
;;
|
||||
@@ -437,7 +442,12 @@ while [ ! -z "$1" ]; do
|
||||
done
|
||||
|
||||
for arg in $@; do
|
||||
$check $arg
|
||||
if [ "$arg" = "--stdin" ] && [ "$check" = "check_commit" ]; then
|
||||
msg=$(cat)
|
||||
check_msg <<< "$msg"
|
||||
else
|
||||
$check $arg
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $fail == 1 ]; then
|
||||
|
||||
Reference in New Issue
Block a user