-
Notifications
You must be signed in to change notification settings - Fork 493
50 lines (46 loc) · 1.61 KB
/
lint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: flake8
on:
pull_request:
types:
- 'synchronize'
- 'opened'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 flake8-builtins
- name: Get current errors
run: |
tmpafter=$(mktemp)
find src -name \*.py -exec flake8 --ignore=A003,E402,E501,W504 {} + | egrep -v "alembic/versions/|usr/local/share/pysnmp/mibs/" > $tmpafter
num_errors_after=`cat $tmpafter | wc -l`
echo "CURRENT_ERROR_FILE=${tmpafter}" >> $GITHUB_ENV
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
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_ERROR_FILE=${tmpbefore}" >> $GITHUB_ENV
echo "OLD_ERRORS=${num_errors_before}" >> $GITHUB_ENV
- name: Conclusion
run: |
if [ ${{ env.CURRENT_ERRORS }} -gt ${{ env.OLD_ERRORS }} ]; then
echo "New flake8 errors were introduced"
diff -u ${{ env.OLD_ERROR_FILE }} ${{ env.CURRENT_ERROR_FILE }}
exit 1
else
echo "No new flake 8 errors were introduced"
fi