Skip to content

Commit

Permalink
Lint policy recommendation PySpark code with flake8 (#68)
Browse files Browse the repository at this point in the history
Signed-off-by: Yongming Ding <dyongming@vmware.com>
  • Loading branch information
dreamtalen authored Sep 9, 2022
1 parent 0f79549 commit f230d45
Show file tree
Hide file tree
Showing 5 changed files with 2,223 additions and 1,370 deletions.
72 changes: 59 additions & 13 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
outputs:
has_changes: ${{ steps.check_diff.outputs.has_changes }}

test-unit:
python-lint:
needs: check-python-changes
if: ${{ needs.check-python-changes.outputs.has_changes == 'yes' }}
name: Unit test
name: Python Lint
strategy:
matrix:
os: [ubuntu-latest]
Expand All @@ -43,16 +43,62 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Check-out code
uses: actions/checkout@v3
- name: Install dependencies
# H106: Don't put vim configuration in source files
# H203: Use assertIs(Not)None to check for None
# H204: Use assert(Not)Equal to check for equality
# H205: Use assert(Greater|Less)(Equal) for comparison
# E125 continuation line does not distinguish itself from next logical line
# E126 continuation line over-indented for hanging indent
# E128 continuation line under-indented for visual indent
# E129 visually indented line with same indent as next logical line
# E265 block comment should start with '#'
# H305 imports not grouped correctly
# H307 like imports should be grouped together
# H404 multi line docstring should start with a summary
# H405 multi line docstring summary not separated with an empty line
# I202 Additional newline in a group of imports
# H904 Wrap long lines in parentheses instead of a backslash
# TODO(dougwig) -- uncomment this to test for remaining linkages
# N530 direct neutron imports not allowed
# N531 translations hints
# W504 line break after binary operator
- name: Lint with flake8
run: |
python -m pip install --upgrade pip
python -m pip install pytest-cov
python -m pip install -r plugins/policy-recommendation/requirements.txt
- name: Run unit tests
run: |
cd plugins/policy-recommendation/
pytest -vv --cov . --cov-report xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
pip install flake8
flake8 --ignore E125,E126,E128,E129,E265,H305,H307,H404,H405,H904,N530,N531,W504,I202 \
--enable-extensions H106,H203,H204,H205 \
--show-source \
--count \
--statistic \
plugins/policy-recommendation/
test-unit:
needs: check-python-changes
if: ${{ needs.check-python-changes.outputs.has_changes == 'yes' }}
name: Unit test
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.7"]
runs-on: ${{ matrix.os }}
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Check-out code
uses: actions/checkout@v3
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest-cov
python -m pip install -r plugins/policy-recommendation/requirements.txt
- name: Run unit tests
run: |
cd plugins/policy-recommendation/
pytest -vv --cov . --cov-report xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
Loading

0 comments on commit f230d45

Please sign in to comment.