1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-12 15:27:14 +03:00

github/pr-/push-checks: Attempt non-diff flake8 checks

* flake8 6.0.0 dropped support for, the broken, --diff.
* We want to only run against python files.  We will have 'git diff's for
  other types of files.
* Uses 'git diff -z', 'grep -z -Z' and 'xargs -0' so as to pass NUL-terminated
  strings around to avoid "special characters in path/filenames" issues.
This commit is contained in:
Athanasius 2022-12-03 12:40:33 +00:00
parent 514f3fac8a
commit 8628efa0a1
No known key found for this signature in database
GPG Key ID: 772697E181BB2767
2 changed files with 21 additions and 4 deletions

View File

@ -85,11 +85,15 @@ jobs:
# F63 - 'tests' checking
# F7 - syntax errors
# F82 - undefined checking
git diff "refs/remotes/${BASE_REPO_OWNER}/${BASE_REF}" -- | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --diff
echo git diff --name-only --diff-filter=d -z "refs/remotes/${BASE_REPO_OWNER}/${BASE_REF}" -- | \
grep -E -z -Z '\.py$' | \
xargs -0 flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# Can optionally add `--exit-zero` to the flake8 arguments so that
# this doesn't fail the build.
# explicitly ignore docstring errors (start with D)
git diff "refs/remotes/${BASE_REPO_OWNER}/${BASE_REF}" -- | flake8 . --count --statistics --diff --extend-ignore D
git diff --name-only --diff-filter=d -z "refs/remotes/${BASE_REPO_OWNER}/${BASE_REF}" -- | \
grep -E -z -Z '\.py$' | \
xargs -0 flake8 . --count --statistics --extend-ignore D
####################################################################
####################################################################

View File

@ -40,7 +40,20 @@ jobs:
DATA=$(jq --raw-output .before $GITHUB_EVENT_PATH)
echo "DATA: ${DATA}"
#######################################################################
# stop the build if there are Python syntax errors or undefined names, ignore existing
git diff "$DATA" | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --diff
#######################################################################
# We need to get just the *filenames* of only *python* files changed.
# Using various -z/-Z/-0 to utilise NUL-terminated strings.
git diff --name-only --diff-filter=d -z "$DATA" | \
grep -E -z -Z '\.py$' | \
xargs -0 flake8 --count --select=E9,F63,F7,F82 --show-source --statistics
#######################################################################
#######################################################################
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
git diff "$DATA" | flake8 . --count --statistics --diff
#######################################################################
git diff --name-only --diff-filter=d -z "$DATA" | \
grep -E -z -Z '\.py$' | \
xargs -0 flake8 . --count --statistics
#######################################################################