Skip to content

Commit

Permalink
CI: Highlighting flake8 and grep errors in GitHub Actions (pandas-dev…
Browse files Browse the repository at this point in the history
  • Loading branch information
datapythonista authored and proost committed Dec 19, 2019
1 parent c7f397f commit cff32e7
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ###
Expand Down

0 comments on commit cff32e7

Please sign in to comment.