Skip to content

Commit b69b2f5

Browse files
committed
ci: Filter file list for assert compile
Add support for a deadcode_exceptions file that contains a list of files are allowed to not be compiled. Useful for API code that are seasonally committed. Signed-off-by: Jorge Marques <[email protected]>
1 parent a285047 commit b69b2f5

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

ci/build.sh

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ compile_kernel_smatch() {
718718

719719
compile_gcc_fanalyzer () {
720720
export step_name="gcc_fanalyzer"
721+
local exceptions_file="ci/travis/deadcode_exceptions"
721722
local files=$(git diff --diff-filter=ACM --no-renames --name-only $base_sha..$head_sha)
722723
local regex='^[[:alnum:]/._-]+:[[:digit:]]+:[[:digit:]]+: .*$'
723724
local mail=
@@ -730,6 +731,10 @@ compile_gcc_fanalyzer () {
730731
return 1
731732
fi
732733

734+
if [[ -f $exceptions_file ]]; then
735+
files=$(comm -13 <(sort $exceptions_file) <(echo $files | tr ' ' '\n' | sort))
736+
fi
737+
733738
while read file; do
734739
case "$file" in
735740
*.c)
@@ -891,8 +896,17 @@ compile_clang_analyzer () {
891896

892897
assert_compiled () {
893898
export step_name="assert_compiled"
899+
local exceptions_file="ci/travis/deadcode_exceptions"
894900
local files=$(git diff --diff-filter=ACM --no-renames --name-only $base_sha..$head_sha)
895901
local fail=0
902+
local error="
903+
At least one file was not compiled during kernel compilation
904+
Either:
905+
1. ensure the Kconfig is able to enable it/them
906+
OR
907+
2. remove deadcode
908+
OR
909+
3. add it/them in file '$exceptions_file'"
896910

897911
echo "$step_name were compiled on range $base_sha..$head_sha"
898912

@@ -901,6 +915,11 @@ assert_compiled () {
901915
return 1
902916
fi
903917

918+
# Allows deadcode
919+
if [[ -f $exceptions_file ]]; then
920+
files=$(comm -13 <(sort $exceptions_file) <(echo $files | tr ' ' '\n' | sort))
921+
fi
922+
904923
while read file; do
905924
case "$file" in
906925
*.c)
@@ -909,14 +928,18 @@ assert_compiled () {
909928
compile_cmd=$(jq ".[] | select(.file == \"$abs_file\") |
910929
.command" compile_commands.json)
911930
if [[ -z "$compile_cmd" ]]; then
912-
echo "::error file=$file,line=0::$step_name: Was not compiled during kernel compilation, ensure defconfig enables it"
931+
echo "::error file=$file,line=0::$step_name: Was not compiled during kernel compilation."
913932
fail=1
914933
fi
915934
;;
916935
esac
917936

918937
done <<< "$files"
919938

939+
if [[ "$fail" == "true" ]]; then
940+
_fmt "::error ::$step_name: $error"
941+
fi
942+
920943
return $fail
921944
}
922945

0 commit comments

Comments
 (0)