|
| 1 | +name: Run Python linters |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + python-files: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + outputs: |
| 9 | + filelist: ${{ steps.python-files.outputs.filelist }} |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v2 |
| 12 | + - id: python-files |
| 13 | + run: | |
| 14 | + echo "::set-output name=filelist::$(find . -type f -exec awk ' /^#!.*python/{print FILENAME} {nextfile}' {} + | tr '\n' ' ')" |
| 15 | +
|
| 16 | + pylint: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + needs: [python-files] |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v2 |
| 21 | + |
| 22 | + - name: Set up Python 3.6 |
| 23 | + uses: actions/setup-python@v2 |
| 24 | + with: |
| 25 | + python-version: 3.6 |
| 26 | + |
| 27 | + - uses: actions/cache@v2 |
| 28 | + with: |
| 29 | + path: ~/pip-cache |
| 30 | + key: pip-3.6-${{ github.sha }} |
| 31 | + # allow cache hits from previous runs of the current branch, |
| 32 | + # parent branch, then upstream branches, in that order |
| 33 | + restore-keys: | |
| 34 | + pip-3.6- |
| 35 | + - name: Install Requirements |
| 36 | + run: | |
| 37 | + python -m pip install --upgrade pip |
| 38 | + pip --cache-dir ~/pip-cache install pylint |
| 39 | + - name: Run Pylint |
| 40 | + env: |
| 41 | + PYTHON_FILES: ${{ needs.python-files.outputs.filelist }} |
| 42 | + run: | |
| 43 | + pylint --errors-only $PYTHON_FILES |
| 44 | + |
| 45 | + flake8: |
| 46 | + runs-on: ubuntu-latest |
| 47 | + needs: [python-files] |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v2 |
| 50 | + |
| 51 | + - name: Set up Python 3.6 |
| 52 | + uses: actions/setup-python@v2 |
| 53 | + with: |
| 54 | + python-version: 3.6 |
| 55 | + |
| 56 | + - uses: actions/cache@v2 |
| 57 | + with: |
| 58 | + path: ~/pip-cache |
| 59 | + key: pip-3.6-${{ github.sha }} |
| 60 | + # allow cache hits from previous runs of the current branch, |
| 61 | + # parent branch, then upstream branches, in that order |
| 62 | + restore-keys: | |
| 63 | + pip-3.6- |
| 64 | + - name: Install Requirements |
| 65 | + run: | |
| 66 | + python -m pip install --upgrade pip |
| 67 | + pip --cache-dir ~/pip-cache install flake8 |
| 68 | + - name: Run flake8 |
| 69 | + env: |
| 70 | + PYTHON_FILES: ${{ needs.python-files.outputs.filelist }} |
| 71 | + run: | # Change PYTHONPATH for different repo |
| 72 | + export PYTHONPATH=$PYTHONPATH:$PWD/src/scripts |
| 73 | + flake8 --select F $PYTHON_FILES |
0 commit comments