kopia lustrzana https://github.com/jgromes/RadioLib
[CI] Add uncrustify script and action
rodzic
83fbedb833
commit
21e4116427
|
|
@ -0,0 +1,33 @@
|
|||
name: "Uncrustify"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Run format check using uncrustify
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install uncrustify
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y cppcheck
|
||||
|
||||
- name: Run uncrustify
|
||||
run: ./extras/uncrustify/uncrustify.sh
|
||||
|
||||
- name: Upload patch file as artifact
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: uncrustify.patch
|
||||
path: extras/uncrustify/uncrustify.patch
|
||||
if-no-files-found: ignore
|
||||
|
|
@ -0,0 +1 @@
|
|||
uncrustify.patch
|
||||
|
|
@ -193,7 +193,7 @@ sp_before_ptr_star = remove # ignore/add/remove/force/not_defined
|
|||
|
||||
# Add or remove space before pointer star '*' that isn't followed by a
|
||||
# variable name. If set to ignore, sp_before_ptr_star is used instead.
|
||||
sp_before_unnamed_ptr_star = force # ignore/add/remove/force/not_defined
|
||||
sp_before_unnamed_ptr_star = remove # ignore/add/remove/force/not_defined
|
||||
|
||||
# Add or remove space between pointer stars '*', as in 'int ***a;'.
|
||||
sp_between_ptr_star = remove # ignore/add/remove/force/not_defined
|
||||
|
|
@ -249,7 +249,7 @@ sp_before_unnamed_byref = ignore # ignore/add/remove/force/not_defined
|
|||
# Add or remove space after reference sign '&', if followed by a word.
|
||||
#
|
||||
# Overrides sp_type_func.
|
||||
sp_after_byref = force # ignore/add/remove/force/not_defined
|
||||
sp_after_byref = remove # ignore/add/remove/force/not_defined
|
||||
|
||||
# Add or remove space after a reference sign '&', if followed by a function
|
||||
# prototype or function definition.
|
||||
|
|
@ -2609,7 +2609,7 @@ align_var_def_span = 0 # unsigned number
|
|||
# 1: Part of the variable 'void *foo;'
|
||||
# 2: Dangling 'void *foo;'
|
||||
# Dangling: the '*' will not be taken into account when aligning.
|
||||
align_var_def_star_style = 0 # unsigned number
|
||||
align_var_def_star_style = 1 # unsigned number
|
||||
|
||||
# How to consider (or treat) the '&' in the alignment of variable definitions.
|
||||
#
|
||||
|
|
@ -2617,7 +2617,7 @@ align_var_def_star_style = 0 # unsigned number
|
|||
# 1: Part of the variable 'long &foo;'
|
||||
# 2: Dangling 'long &foo;'
|
||||
# Dangling: the '&' will not be taken into account when aligning.
|
||||
align_var_def_amp_style = 0 # unsigned number
|
||||
align_var_def_amp_style = 1 # unsigned number
|
||||
|
||||
# The threshold for aligning variable definitions.
|
||||
# Use a negative number for absolute thresholds.
|
||||
|
|
@ -2745,7 +2745,7 @@ align_typedef_func = 0 # unsigned number
|
|||
# 1: Part of type name: 'typedef int *pint;'
|
||||
# 2: Dangling: 'typedef int *pint;'
|
||||
# Dangling: the '*' will not be taken into account when aligning.
|
||||
align_typedef_star_style = 0 # unsigned number
|
||||
align_typedef_star_style = 1 # unsigned number
|
||||
|
||||
# How to consider (or treat) the '&' in the alignment of typedefs.
|
||||
#
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
#! /bin/bash
|
||||
|
||||
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
out_file=$script_dir/uncrustify.patch
|
||||
rm $out_file
|
||||
|
||||
# for all soruce files, run uncrustify and save the output to a patch file
|
||||
for file in $(find src/ -name '*.cpp' -or -name '*.h'); do
|
||||
uncrustify -c $script_dir/uncrustify.cfg -f $file -o $file.uncrustify
|
||||
diff -u $file $file.uncrustify >> $out_file
|
||||
rm $file.uncrustify
|
||||
done
|
||||
|
||||
cat $out_file
|
||||
|
||||
if [ -s $out_file ]; then
|
||||
echo "Uncrustify finished and found some issues"
|
||||
echo "Apply the patch file by: 'cd src && git apply $out_file'"
|
||||
exit 1
|
||||
else
|
||||
echo "Uncrustify finished - all OK!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
Ładowanie…
Reference in New Issue