From 628b45d975903db7f06df35d31edea907f36c6b4 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Tue, 15 Dec 2020 20:53:17 +0100 Subject: [PATCH] dist/tools/externc: annotate errors in Github Action --- dist/tools/externc/check.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/dist/tools/externc/check.sh b/dist/tools/externc/check.sh index a8a9cd791e..851b9161aa 100755 --- a/dist/tools/externc/check.sh +++ b/dist/tools/externc/check.sh @@ -13,6 +13,9 @@ cd $RIOTBASE : "${RIOTTOOLS:=${RIOTBASE}/dist/tools}" . "${RIOTTOOLS}"/ci/changed_files.sh +. "${RIOTTOOLS}"/ci/github_annotate.sh + +github_annotate_setup # prepare ROOT=$(git rev-parse --show-toplevel) @@ -28,9 +31,24 @@ for FILE in ${FILES}; do | sed -e 's/ */ /g' \ | grep -v -q '#ifdef __cplusplus extern "C" {'; \ then + ANNOTATION="File does not have a C++ compatible header" EXIT_CODE=1 - echo "file does not have a C++ compatible header: '${FILE}'" + echo "${ANNOTATION}: '${FILE}'" + ANNOTATION="${ANNOTATION}.\nPlease add:\n\n" + ANNOTATION="${ANNOTATION}"'```C\n' + ANNOTATION="${ANNOTATION}#ifdef __cplusplus\n" + ANNOTATION="${ANNOTATION}extern \"C\" {\n" + ANNOTATION="${ANNOTATION}#endif\n\n" + ANNOTATION="${ANNOTATION}/* your file content */\n\n" + ANNOTATION="${ANNOTATION}"'#ifdef __cplusplus\n' + ANNOTATION="${ANNOTATION}}\n" + ANNOTATION="${ANNOTATION}"'#endif\n' + ANNOTATION="${ANNOTATION}"'```\n\n' + ANNOTATION="${ANNOTATION}after your header \`#include\`s" + github_annotate_error "${FILE}" 0 "${ANNOTATION}" fi done +github_annotate_teardown + exit ${EXIT_CODE}