@cryptotaxi247 / netdata-1 / commits / fffd076e3

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.

Austin S. Hemmelgarn committed Feb 23, 2023 at 09:53 UTC fffd076e3403c7e59e79e06cb5cd07c5850d097a
2 files changed +35
.flake8 new
+2
@@ -0,0 +1,2 @@
1 +[flake8]
2 +max-line-length=120
.github/workflows/review.yml
+33
@@ -16,6 +16,7 @@ jobs:
16 outputs:
17 actionlint: ${{ steps.actionlint.outputs.run }}
18 eslint: ${{ steps.eslint.outputs.run }}
19 + flake8: ${{ steps.flake8.outputs.run }}
20 hadolint: ${{ steps.hadolint.outputs.run }}
21 shellcheck: ${{ steps.shellcheck.outputs.run }}
22 yamllint: ${{ steps.yamllint.outputs.run }}
@@ -47,6 +48,17 @@ jobs:
48 else
49 echo "run=false" >> "${GITHUB_OUTPUT}"
50 fi
51 + - name: Check files for flake8
52 + id: flake8
53 + run: |
54 + if [ "${{ contains(github.event.pull_request.labels.*.name, 'run-ci/flake8') }}" = "true" ]; then
55 + echo "run=true" >> "${GITHUB_OUTPUT}"
56 + elif git diff --name-only origin/${{ github.base_ref }} HEAD | grep -Eq '.*\.py' ; then
57 + echo "run=true" >> "${GITHUB_OUTPUT}"
58 + echo 'Python files have changed, need to run flake8.'
59 + else
60 + echo "run=false" >> "${GITHUB_OUTPUT}"
61 + fi
62 - name: Check files for hadolint
63 id: hadolint
64 run: |
@@ -118,6 +130,27 @@ jobs:
130 reporter: github-pr-check
131 eslint_flags: '.'
132
133 + flake8:
134 + name: flake8
135 + needs: prep-review
136 + if: needs.prep-review.outputs.flake8 == 'true'
137 + runs-on: ubuntu-latest
138 + steps:
139 + - name: Git clone repository
140 + uses: actions/checkout@v3
141 + with:
142 + submodules: recursive
143 + fetch-depth: 0
144 + - name: Setup Python
145 + uses: actions/setup-python@v4
146 + with:
147 + python-version: "3.10"
148 + - name: Run flake8
149 + uses: reviewdog/action-flake8@v3
150 + with:
151 + github_token: ${{ secrets.GITHUB_TOKEN }}
152 + reporter: github-pr-check
153 +
154 hadolint:
155 name: hadolint
156 needs: prep-review