Skip to content

Commit a763f84

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 a763f84

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

ci/build.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,17 @@ compile_clang_analyzer () {
891891

892892
assert_compiled () {
893893
export step_name="assert_compiled"
894+
local exceptions_file="ci/travis/deadcode_exceptions"
894895
local files=$(git diff --diff-filter=ACM --no-renames --name-only $base_sha..$head_sha)
895896
local fail=0
897+
local error="
898+
At least one file was not compiled during kernel compilation
899+
Either:
900+
1. ensure the Kconfig is able to enable it/them
901+
OR
902+
2. remove deadcode
903+
OR
904+
3. add it/them in file '$exceptions_file'"
896905

897906
echo "$step_name were compiled on range $base_sha..$head_sha"
898907

@@ -901,6 +910,11 @@ assert_compiled () {
901910
return 1
902911
fi
903912

913+
# Allows deadcode
914+
if [[ -f $exceptions_file ]]; then
915+
files=$(comm -13 <(sort $exceptions_file) <(echo $files | tr ' ' '\n' | sort))
916+
fi
917+
904918
while read file; do
905919
case "$file" in
906920
*.c)
@@ -909,14 +923,18 @@ assert_compiled () {
909923
compile_cmd=$(jq ".[] | select(.file == \"$abs_file\") |
910924
.command" compile_commands.json)
911925
if [[ -z "$compile_cmd" ]]; then
912-
echo "::error file=$file,line=0::$step_name: Was not compiled during kernel compilation, ensure defconfig enables it"
926+
echo "::error file=$file,line=0::$step_name: Was not compiled during kernel compilation."
913927
fail=1
914928
fi
915929
;;
916930
esac
917931

918932
done <<< "$files"
919933

934+
if [[ "$fail" == "true" ]]; then
935+
_fmt "::error ::$step_name: $error"
936+
fi
937+
920938
return $fail
921939
}
922940

0 commit comments

Comments
 (0)