Skip to content

Commit

Permalink
Add github action to use flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicaj committed Jun 11, 2021
1 parent 1eb4cc6 commit db5554e
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: flake8

on:
pull_request:
types:
- 'synchronize'
- 'opened'

jobs:
lint:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
- name: Get current errors
# echo "CURRENT_ERROR_STR=\"$(cat $tmpafter)\"" >> $GITHUB_ENV
run: |
tmpafter=$(mktemp)
find src -name \*.py -exec flake8 --ignore=E402,E501,W504 {} + | egrep -v "alembic/versions/|usr/local/share/pysnmp/mibs/" > $tmpafter
num_errors_after=`cat $tmpafter | wc -l`
echo "CURRENT_ERRORS=${num_errors_after}" >> $GITHUB_ENV
- name: Checkout base branch
uses: actions/checkout@v2
with:
ref: ${{ github.base_ref }}
- name: Get errors from base branch
# echo "OLD_ERROR_STR=\"$(cat $tmpbefore)\"" >> $GITHUB_ENV
run: |
tmpbefore=$(mktemp)
find src -name \*.py -exec flake8 --ignore=E402,E501,W504 {} + | egrep -v "alembic/versions/|usr/local/share/pysnmp/mibs/" > $tmpbefore
num_errors_before=`cat $tmpbefore | wc -l`
echo "OLD_ERRORS=${num_errors_before}" >> $GITHUB_ENV
- name: Conclusion
# diff <(echo "${{ env.OLD_ERROR_STR }}") <(echo "${{ env.CURRENT_ERROR_str }}")
run: |
if [ ${{ env.CURRENT_ERRORS }} -gt ${{ env.OLD_ERRORS }} ]; then
echo "New flake8 errors were introduced"
exit 1
else
echo "No new flake 8 errors were introduced"
fi

0 comments on commit db5554e

Please sign in to comment.