dist/tools/ci/github_annotate.sh: allow annotations without files
This commit is contained in:
parent
6eb8e17861
commit
20350edebb
8
dist/tools/ci/README.md
vendored
8
dist/tools/ci/README.md
vendored
@ -71,6 +71,14 @@ github_annotate_parse_log_default github_annotate_warning
|
|||||||
does the same as the last example snippet, but uses `github_annotate_warning`
|
does the same as the last example snippet, but uses `github_annotate_warning`
|
||||||
instead.
|
instead.
|
||||||
|
|
||||||
|
If you do not need to provide a file with your error or warning, you can also
|
||||||
|
use `github_annotate_error_no_file` or `github_annotate_warning_no_file`,
|
||||||
|
respectively. Both take a just message as single parameter:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
github_annotate_error_no_file "Something is wrong!"
|
||||||
|
```
|
||||||
|
|
||||||
After all errors or warnings are annotated, call `github_annotate_teardown` to
|
After all errors or warnings are annotated, call `github_annotate_teardown` to
|
||||||
finish annotations.
|
finish annotations.
|
||||||
|
|
||||||
|
|||||||
27
dist/tools/ci/github_annotate.sh
vendored
27
dist/tools/ci/github_annotate.sh
vendored
@ -33,12 +33,26 @@ _escape() {
|
|||||||
-e 's/%/%25/g' -e 's/\r/%0D/g' -e 's/\n/%0A/g'
|
-e 's/%/%25/g' -e 's/\r/%0D/g' -e 's/\n/%0A/g'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_github_annotate() {
|
||||||
|
MESSAGE="$(_escape "${1}")"
|
||||||
|
LEVEL="${2:-error}"
|
||||||
|
OPTS="${3:-}"
|
||||||
|
echo "::${LEVEL} ${OPTS}::${DETAILS}" >> ${OUTFILE}
|
||||||
|
}
|
||||||
|
|
||||||
github_annotate_error() {
|
github_annotate_error() {
|
||||||
if [ -n "${GITHUB_RUN_ID}" ]; then
|
if [ -n "${GITHUB_RUN_ID}" ]; then
|
||||||
FILENAME="${1}"
|
FILENAME="${1}"
|
||||||
LINENUM="${2}"
|
LINENUM="${2}"
|
||||||
DETAILS="$(_escape "${3}")"
|
DETAILS="${3}"
|
||||||
echo "::error file=${FILENAME},line=${LINENUM}::${DETAILS}" >> ${OUTFILE}
|
_github_annotate "${DETAILS}" error "file=${FILENAME},line=${LINENUM}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
github_annotate_error_no_file() {
|
||||||
|
if [ -n "${GITHUB_RUN_ID}" ]; then
|
||||||
|
DETAILS="${1}"
|
||||||
|
_github_annotate "${DETAILS}" error
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +61,14 @@ github_annotate_warning() {
|
|||||||
FILENAME="${1}"
|
FILENAME="${1}"
|
||||||
LINENUM="${2}"
|
LINENUM="${2}"
|
||||||
DETAILS="$(_escape "${3}")"
|
DETAILS="$(_escape "${3}")"
|
||||||
echo "::warning file=${FILENAME},line=${LINENUM}::${DETAILS}" >> ${OUTFILE}
|
_github_annotate "${DETAILS}" warning "file=${FILENAME},line=${LINENUM}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
github_annotate_warning_no_file() {
|
||||||
|
if [ -n "${GITHUB_RUN_ID}" ]; then
|
||||||
|
DETAILS="${1}"
|
||||||
|
_github_annotate "${DETAILS}" warning
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user