diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index e90929bb..70c8dad1 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -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 #################################################################### #################################################################### diff --git a/.github/workflows/push-checks.yml b/.github/workflows/push-checks.yml index b6994b02..a11234ed 100644 --- a/.github/workflows/push-checks.yml +++ b/.github/workflows/push-checks.yml @@ -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 + #######################################################################