Add flake8 to review CI to check Python files. (#14582)
* Add flake8 to review CI to check Python files. We used to have this in our old Travis jobs, but it got removed at some point before the switch to GitHub Actions and we never re-added it. * Fix typo.
This commit is contained in:
parent
d7ca7f5010
commit
fffd076e34
|
@ -16,6 +16,7 @@ jobs:
|
|||
outputs:
|
||||
actionlint: ${{ steps.actionlint.outputs.run }}
|
||||
eslint: ${{ steps.eslint.outputs.run }}
|
||||
flake8: ${{ steps.flake8.outputs.run }}
|
||||
hadolint: ${{ steps.hadolint.outputs.run }}
|
||||
shellcheck: ${{ steps.shellcheck.outputs.run }}
|
||||
yamllint: ${{ steps.yamllint.outputs.run }}
|
||||
|
@ -47,6 +48,17 @@ jobs:
|
|||
else
|
||||
echo "run=false" >> "${GITHUB_OUTPUT}"
|
||||
fi
|
||||
- name: Check files for flake8
|
||||
id: flake8
|
||||
run: |
|
||||
if [ "${{ contains(github.event.pull_request.labels.*.name, 'run-ci/flake8') }}" = "true" ]; then
|
||||
echo "run=true" >> "${GITHUB_OUTPUT}"
|
||||
elif git diff --name-only origin/${{ github.base_ref }} HEAD | grep -Eq '.*\.py' ; then
|
||||
echo "run=true" >> "${GITHUB_OUTPUT}"
|
||||
echo 'Python files have changed, need to run flake8.'
|
||||
else
|
||||
echo "run=false" >> "${GITHUB_OUTPUT}"
|
||||
fi
|
||||
- name: Check files for hadolint
|
||||
id: hadolint
|
||||
run: |
|
||||
|
@ -118,6 +130,27 @@ jobs:
|
|||
reporter: github-pr-check
|
||||
eslint_flags: '.'
|
||||
|
||||
flake8:
|
||||
name: flake8
|
||||
needs: prep-review
|
||||
if: needs.prep-review.outputs.flake8 == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Git clone repository
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: "3.10"
|
||||
- name: Run flake8
|
||||
uses: reviewdog/action-flake8@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
reporter: github-pr-check
|
||||
|
||||
hadolint:
|
||||
name: hadolint
|
||||
needs: prep-review
|
||||
|
|
Loading…
Reference in New Issue