diff --git a/dist/tools/ci/github_annotate.sh b/dist/tools/ci/github_annotate.sh index 41acd65461..3bf7e1f973 100644 --- a/dist/tools/ci/github_annotate.sh +++ b/dist/tools/ci/github_annotate.sh @@ -9,7 +9,7 @@ LOGFILE= OUTFILE=github_annotate_outfile.log ECHO_ESC=echo -if ps -p $$ | grep -q '\'; then +if [ -n "${BASH_VERSION}" ]; then # workaround when included in bash to escape newlines and carriage returns # properly in _escape ECHO_ESC='echo -e' @@ -37,7 +37,7 @@ _github_annotate() { MESSAGE="$(_escape "${1}")" LEVEL="${2:-error}" OPTS="${3:-}" - echo "::${LEVEL} ${OPTS}::${DETAILS}" >> ${OUTFILE} + echo "::${LEVEL} ${OPTS}::${MESSAGE}" >> ${OUTFILE} } github_annotate_error() { @@ -60,7 +60,7 @@ github_annotate_warning() { if [ -n "${GITHUB_RUN_ID}" ]; then FILENAME="${1}" LINENUM="${2}" - DETAILS="$(_escape "${3}")" + DETAILS="${3}" _github_annotate "${DETAILS}" warning "file=${FILENAME},line=${LINENUM}" fi } diff --git a/dist/tools/doccheck/check.sh b/dist/tools/doccheck/check.sh index c3bfcb30d9..0ad795b5ca 100755 --- a/dist/tools/doccheck/check.sh +++ b/dist/tools/doccheck/check.sh @@ -10,6 +10,10 @@ RIOTBASE="$(cd $(dirname $0)/../../..; pwd)" +. ${RIOTBASE}/dist/tools/ci/github_annotate.sh + +github_annotate_setup + if tput colors &> /dev/null && [ $(tput colors) -ge 8 ]; then CERROR="\e[1;31m" CWARN="\033[1;33m" @@ -22,17 +26,30 @@ fi DOXY_OUTPUT=$(make -C "${RIOTBASE}" doc 2>&1) DOXY_ERRCODE=$? +RESULT=0 + if [ "${DOXY_ERRCODE}" -ne 0 ] ; then echo "'make doc' exited with non-zero code (${DOXY_ERRCODE})" echo "${DOXY_OUTPUT}" - exit 2 + RESULT=2 else ERRORS=$(echo "${DOXY_OUTPUT}" | grep '.*warning' | sed "s#${PWD}/\([^:]*\)#\1#g") if [ -n "${ERRORS}" ] ; then - echo -e "${CERROR}ERROR: Doxygen generates the following warnings:${CRESET}" - echo "${ERRORS}" - exit 2 + if github_annotate_is_on; then + echo "${ERRORS}" | grep "^.\+:[0-9]\+: warning:" | while read error_line + do + FILENAME=$(echo "${error_line}" | cut -d: -f1) + LINENR=$(echo "${error_line}" | cut -d: -f2) + DETAILS=$(echo "${error_line}" | cut -d: -f4- | + sed -e 's/^[ \t]*//' -e 's/[ \t]*$//') + github_annotate_error "${FILENAME}" "${LINENR}" "${DETAILS}" + done + else + echo -e "${CERROR}ERROR: Doxygen generates the following warnings:${CRESET}" + echo "${ERRORS}" + fi + RESULT=2 fi fi @@ -42,8 +59,8 @@ exclude_filter() { # Check groups are correctly defined (e.g. no undefined groups and no group # defined multiple times) -ALL_RAW_DEFGROUP=$(git grep @defgroup -- '*.h' '*.c' '*.txt' | exclude_filter) -ALL_RAW_INGROUP=$(git grep '@ingroup' -- '*.h' '*.c' '*.txt' | exclude_filter) +ALL_RAW_DEFGROUP=$(git grep -n @defgroup -- '*.h' '*.c' '*.txt' | exclude_filter) +ALL_RAW_INGROUP=$(git grep -n '@ingroup' -- '*.h' '*.c' '*.txt' | exclude_filter) DEFINED_GROUPS=$(echo "${ALL_RAW_DEFGROUP}" | \ grep -oE '@defgroup[ ]+[^ ]+' | \ grep -oE '[^ ]+$' | \ @@ -62,15 +79,29 @@ UNDEFINED_GROUPS=$( \ if [ -n "${UNDEFINED_GROUPS}" ] then COUNT=$(echo "${UNDEFINED_GROUPS}" | wc -l) - echo -ne "${CERROR}ERROR${CRESET} " - echo -e "There are ${CWARN}${COUNT}${CRESET} undefined Doxygen groups:" + echo -ne "\n\n${CERROR}ERROR${CRESET} " + echo -ne "There are ${CWARN}${COUNT}${CRESET} undefined Doxygen groups" + if github_annotate_is_on; then + echo "" + else + echo ":" + fi for group in ${UNDEFINED_GROUPS}; do - echo -e "\n${CWARN}${group}${CRESET} found in:"; - echo "${ALL_RAW_INGROUP}" | grep "\<${group}\>$" | sort -u | - awk -F: '{ print "\t" $1 }'; + INGROUPS=$(echo "${ALL_RAW_INGROUP}" | grep "\<${group}\>$" | sort -u) + if github_annotate_is_on; then + echo "${INGROUPS}" | while read ingroup; + do + github_annotate_error \ + $(echo ${ingroup} | awk -F: '{ print $1,$2 }') \ + "Undefined doxygen group '${group}'" + done + else + echo -e "\n${CWARN}${group}${CRESET} found in:"; + echo "${INGROUPS}" | awk -F: '{ print "\t" $1 }'; + fi done - exit 2 + RESULT=2 fi # Check for groups defined multiple times: @@ -79,15 +110,31 @@ MULTIPLE_DEFINED_GROUPS=$(echo "${DEFINED_GROUPS}" | uniq -d) if [ -n "${MULTIPLE_DEFINED_GROUPS}" ] then COUNT=$(echo "${MULTIPLE_DEFINED_GROUPS}" | wc -l) - echo -ne "${CERROR}ERROR${CRESET} " - echo -e "There are ${CWARN}${COUNT}${CRESET} Doxygen groups defined multiple times:" + echo -ne "\n\n${CERROR}ERROR${CRESET} " + echo -ne "There are ${CWARN}${COUNT}${CRESET} Doxygen groups defined multiple times" + if github_annotate_is_on; then + echo "" + else + echo ":" + fi for group in ${MULTIPLE_DEFINED_GROUPS}; do - echo -e "\n${CWARN}${group}${CRESET} defined in:"; - echo "${ALL_RAW_DEFGROUP}" | \ + DEFGROUPS=$(echo "${ALL_RAW_DEFGROUP}" | awk -F@ '{ split($2, end, " "); printf("%s%s\n",$1,end[2]) }' | - grep "\<${group}\>$" | sort -u | - awk -F: '{ print "\t" $1 }'; + grep "\<${group}\>$" | sort -u) + DEFGROUPFILES=$(echo "${DEFGROUPS}" | awk -F: '{ print "\t" $1 }') + if github_annotate_is_on; then + echo "${DEFGROUPS}" | while read defgroup; + do + github_annotate_error $(echo ${defgroup} | awk -F: '{ print $1,$2 }') \ + "Multiple doxygen group definitions of '${group}' in\n${DEFGROUPFILES}" + done + else + echo -e "\n${CWARN}${group}${CRESET} defined in:"; + echo "${DEFGROUPFILES}" + fi done - exit 2 + RESULT=2 fi +github_annotate_teardown +exit ${RESULT}