Merge pull request #15750 from miri64/dist/enh/buildsystem-sanity-check-annotate

dist/tools/buildsystem_sanity_check: minor fixes and annotate errors in Github Action
This commit is contained in:
Martine Lenders 2021-01-13 16:42:36 +01:00 committed by GitHub
commit ff0e41ff9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,6 +15,9 @@
: "${RIOTBASE:="$(cd "$(dirname "$0")/../../../" || exit; pwd)"}" : "${RIOTBASE:="$(cd "$(dirname "$0")/../../../" || exit; pwd)"}"
: "${RIOTTOOLS:=${RIOTBASE}/dist/tools}"
. "${RIOTTOOLS}"/ci/github_annotate.sh
SCRIPT_PATH=dist/tools/buildsystem_sanity_check/check.sh SCRIPT_PATH=dist/tools/buildsystem_sanity_check/check.sh
@ -31,7 +34,22 @@ prepend() {
} }
error_with_message() { error_with_message() {
tab_indent | prepend "${1}" while read INPUT; do
if github_annotate_is_on; then
MESSAGE="${1}"
FILE=$(echo "${INPUT}" | cut -d: -f1)
LINE=$(echo "${INPUT}" | cut -d: -f2)
MATCH=$(echo "${INPUT}" | cut -d: -f3)
if [[ $var =~ ^[0-9]+$ ]] || [ -z "$MATCH" ]; then
# line is not provided in grep pattern
LINE=0
fi
github_annotate_error "$FILE" "$LINE" "$MESSAGE"
fi
# We need to generate non GitHub annotations for this script to fail.
# Also, the pure annotate output is not very helpful on its own ;-)
echo "${INPUT}" | tab_indent | prepend "${1}:"
done
} }
@ -56,8 +74,8 @@ check_not_parsing_features() {
# These two files contain sanity checks using FEATURES_ so are allowed # These two files contain sanity checks using FEATURES_ so are allowed
pathspec+=(':!Makefile.include' ':!makefiles/info-global.inc.mk') pathspec+=(':!Makefile.include' ':!makefiles/info-global.inc.mk')
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}" \ git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message 'Modules should not check the content of FEATURES_PROVIDED/_REQUIRED/OPTIONAL' | error_with_message 'Modules should not check the content of FEATURES_PROVIDED/REQUIRED/OPTIONAL'
} }
# Providing features for boards and CPUs should only be done in # Providing features for boards and CPUs should only be done in
@ -72,7 +90,7 @@ check_providing_features_only_makefile_features() {
pathspec+=(":!*Makefile.features") pathspec+=(":!*Makefile.features")
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}" \ git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message 'Features should only be provided in Makefile.features files' | error_with_message 'Features should only be provided in Makefile.features files'
} }
@ -136,8 +154,8 @@ check_not_exporting_variables() {
patterns+=(-e "export[[:blank:]]\+${variable}") patterns+=(-e "export[[:blank:]]\+${variable}")
done done
git -C "${RIOTBASE}" grep "${patterns[@]}" \ git -C "${RIOTBASE}" grep -n "${patterns[@]}" \
| error_with_message 'Variables must not be exported:' | error_with_message 'Variables must not be exported'
# Some variables may still be exported in 'makefiles/vars.inc.mk' as the # Some variables may still be exported in 'makefiles/vars.inc.mk' as the
# only place that should export common variables # only place that should export common variables
@ -152,8 +170,8 @@ check_not_exporting_variables() {
# Only run if there are patterns, otherwise it matches everything # Only run if there are patterns, otherwise it matches everything
if [ ${#patterns[@]} -ne 0 ]; then if [ ${#patterns[@]} -ne 0 ]; then
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}" \ git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message 'Variables must only be exported in `makefiles/vars.inc.mk`:' | error_with_message 'Variables must only be exported in `makefiles/vars.inc.mk`'
fi fi
} }
@ -172,8 +190,8 @@ check_deprecated_vars_patterns() {
# Ignore this file when matching as it self matches # Ignore this file when matching as it self matches
pathspec+=(":!${SCRIPT_PATH}") pathspec+=(":!${SCRIPT_PATH}")
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}" \ git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message 'Deprecated variables or patterns:' | error_with_message 'Deprecated variables or patterns'
} }
# Makefile files cpu must not be included by the board anymore # Makefile files cpu must not be included by the board anymore
@ -188,7 +206,7 @@ check_board_do_not_include_cpu_features_dep() {
pathspec+=('boards/') pathspec+=('boards/')
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}" \ git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message 'Makefiles files from cpu must not be included by the board anymore' | error_with_message 'Makefiles files from cpu must not be included by the board anymore'
} }
@ -204,7 +222,7 @@ check_cpu_cpu_model_defined_in_makefile_features() {
pathspec+=(':!boards/**/Makefile.features') pathspec+=(':!boards/**/Makefile.features')
pathspec+=(':!cpu/**/Makefile.features') pathspec+=(':!cpu/**/Makefile.features')
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}" \ git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message 'CPU and CPU_MODEL definition must be done by board/BOARD/Makefile.features, board/common/**/Makefile.features or cpu/CPU/Makefile.features' | error_with_message 'CPU and CPU_MODEL definition must be done by board/BOARD/Makefile.features, board/common/**/Makefile.features or cpu/CPU/Makefile.features'
} }
@ -217,7 +235,7 @@ check_not_setting_board_equal() {
pathspec+=('**/Makefile') pathspec+=('**/Makefile')
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}" \ git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message 'Applications Makefile should use "BOARD ?="' | error_with_message 'Applications Makefile should use "BOARD ?="'
} }
@ -231,7 +249,7 @@ check_board_insufficient_memory_not_in_makefile() {
pathspec+=('**/Makefile') pathspec+=('**/Makefile')
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}" \ git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message 'Move BOARD_INSUFFICIENT_MEMORY to Makefile.ci' | error_with_message 'Move BOARD_INSUFFICIENT_MEMORY to Makefile.ci'
} }
@ -245,7 +263,7 @@ checks_tests_application_not_defined_in_makefile() {
pathspec+=('tests/**/Makefile') pathspec+=('tests/**/Makefile')
pathspec+=(':!tests/external_board_native/Makefile') pathspec+=(':!tests/external_board_native/Makefile')
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}" \ git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message "Don't define APPLICATION in test Makefile" | error_with_message "Don't define APPLICATION in test Makefile"
} }
@ -258,7 +276,7 @@ checks_develhelp_not_defined_via_cflags() {
pathspec+=('**/Makefile') pathspec+=('**/Makefile')
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}" \ git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message "Use DEVELHELP ?= 1 instead of using CFLAGS directly" | error_with_message "Use DEVELHELP ?= 1 instead of using CFLAGS directly"
} }
@ -274,7 +292,7 @@ check_files_in_boards_not_reference_board_var() {
# boards/common/nrf52 uses a hack to resolve dependencies early # boards/common/nrf52 uses a hack to resolve dependencies early
pathspec+=(':!boards/common/nrf52/Makefile.include') pathspec+=(':!boards/common/nrf52/Makefile.include')
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}" \ git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message 'Code in boards/ should not use $(BOARDS) to reference files since this breaks external BOARDS changing BOARDSDIR"' | error_with_message 'Code in boards/ should not use $(BOARDS) to reference files since this breaks external BOARDS changing BOARDSDIR"'
} }
@ -286,7 +304,7 @@ check_no_pseudomodules_in_makefile_dep() {
pathspec+=('**/Makefile.dep') pathspec+=('**/Makefile.dep')
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}" \ git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message "Don't define PSEUDOMODULES in Makefile.dep" | error_with_message "Don't define PSEUDOMODULES in Makefile.dep"
} }
@ -301,7 +319,7 @@ check_no_usemodules_in_makefile_include() {
pathspec+=(':!tests/**/Makefile.include') pathspec+=(':!tests/**/Makefile.include')
pathspec+=(':!examples/**/Makefile.include') pathspec+=(':!examples/**/Makefile.include')
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}" \ git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message "Don't include USEMODULE in Makefile.include" | error_with_message "Don't include USEMODULE in Makefile.include"
} }
@ -312,7 +330,7 @@ check_no_pkg_source_local() {
patterns+=(-e 'PKG_SOURCE_LOCAL') patterns+=(-e 'PKG_SOURCE_LOCAL')
pathspec+=('pkg/*/Makefile') pathspec+=('pkg/*/Makefile')
git -C "${RIOTBASE}" grep "${patterns[@]}" -- "${pathspec[@]}" \ git -C "${RIOTBASE}" grep -n "${patterns[@]}" -- "${pathspec[@]}" \
| error_with_message "Don't push PKG_SOURCE_LOCAL definitions upstream" | error_with_message "Don't push PKG_SOURCE_LOCAL definitions upstream"
} }
@ -344,5 +362,8 @@ main() {
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
github_annotate_setup
main main
github_annotate_teardown
github_annotate_report_last_run
fi fi