1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-12 23:37:14 +03:00
Athanasius 8628efa0a1
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.
2022-12-03 13:52:29 +00:00

60 lines
2.1 KiB
YAML

# This workflow will:
#
# * install Python dependencies
# * lint with a single version of Python
#
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Push-Checks
on:
push:
branches: [ develop ]
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version-file: '.python-version'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel flake8 pytest
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
- name: Setup flake8 annotations
uses: rbialon/flake8-annotations@v1
- name: Lint with flake8
env:
ROOT_SHA: ${{github.base_ref}}
run: |
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
#######################################################################
# 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 --name-only --diff-filter=d -z "$DATA" | \
grep -E -z -Z '\.py$' | \
xargs -0 flake8 . --count --statistics
#######################################################################