From cff32e79f21766b8d1167f1fd713e9ce5e6b05da Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Fri, 29 Nov 2019 22:36:09 +0000 Subject: [PATCH] CI: Highlighting flake8 and grep errors in GitHub Actions (#29915) --- ci/code_checks.sh | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 7c6c98d910492e..4e25fd0ddb5ea9 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -34,17 +34,13 @@ function invgrep { # # This is useful for the CI, as we want to fail if one of the patterns # that we want to avoid is found by grep. - if [[ "$AZURE" == "true" ]]; then - set -o pipefail - grep -n "$@" | awk -F ":" '{print "##vso[task.logissue type=error;sourcepath=" $1 ";linenumber=" $2 ";] Found unwanted pattern: " $3}' - else - grep "$@" - fi - return $((! $?)) + grep -n "$@" | sed "s/^/$INVGREP_PREPEND/" | sed "s/$/$INVGREP_APPEND/" ; EXIT_STATUS=${PIPESTATUS[0]} + return $((! $EXIT_STATUS)) } -if [[ "$AZURE" == "true" ]]; then - FLAKE8_FORMAT="##vso[task.logissue type=error;sourcepath=%(path)s;linenumber=%(row)s;columnnumber=%(col)s;code=%(code)s;]%(text)s" +if [[ "$GITHUB_ACTIONS" == "true" ]]; then + FLAKE8_FORMAT="##[error]%(path)s:%(row)s:%(col)s:%(code):%(text)s" + INVGREP_PREPEND="##[error]" else FLAKE8_FORMAT="default" fi @@ -199,14 +195,10 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then RET=$(($RET + $?)) ; echo $MSG "DONE" MSG='Check that no file in the repo contains trailing whitespaces' ; echo $MSG - set -o pipefail - if [[ "$AZURE" == "true" ]]; then - # we exclude all c/cpp files as the c/cpp files of pandas code base are tested when Linting .c and .h files - ! grep -n '--exclude=*.'{svg,c,cpp,html,js} --exclude-dir=env -RI "\s$" * | awk -F ":" '{print "##vso[task.logissue type=error;sourcepath=" $1 ";linenumber=" $2 ";] Tailing whitespaces found: " $3}' - else - ! grep -n '--exclude=*.'{svg,c,cpp,html,js} --exclude-dir=env -RI "\s$" * | awk -F ":" '{print $1 ":" $2 ":Tailing whitespaces found: " $3}' - fi + INVGREP_APPEND=" <- trailing whitespaces found" + invgrep -RI --exclude=\*.{svg,c,cpp,html,js} --exclude-dir=env "\s$" * RET=$(($RET + $?)) ; echo $MSG "DONE" + unset INVGREP_APPEND fi ### CODE ###