Skip to content

HTCONDOR-2030: Fix tests #277

HTCONDOR-2030: Fix tests

HTCONDOR-2030: Fix tests #277

name: Run Python linters
on: [push, pull_request]
jobs:
python-files:
runs-on: ubuntu-20.04
outputs:
filelist: ${{ steps.python-files.outputs.filelist }}
steps:
- uses: actions/checkout@v3
- id: python-files
run: |
find . -type f -name '*.py' > py_files.txt
find . -type f -exec awk ' /^#!.*python/{print FILENAME} {nextfile}' {} + > py_shebangs.txt
echo "filelist=$(sort py_files.txt py_shebangs.txt | uniq | tr '\n' ' ')" >> ${GITHUB_OUTPUT}
pylint:
runs-on: ubuntu-20.04
needs: [python-files]
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.6
uses: actions/setup-python@v4
with:
python-version: 3.6
- uses: actions/cache@v3
with:
path: ~/pip-cache
key: pip-3.6-${{ github.sha }}
# allow cache hits from previous runs of the current branch,
# parent branch, then upstream branches, in that order
restore-keys: |
pip-3.6-
- name: Install Requirements
run: |
python -m pip install --upgrade pip
pip --cache-dir ~/pip-cache install pylint htcondor flask jinja2 gunicorn
- name: Run Pylint
env:
PYTHON_FILES: ${{ needs.python-files.outputs.filelist }}
# HACK: in newer versions of HTCondor (at least 8.9.11+),
# classad/htcondor modules are placed in python packages where
# straight 'import htcondor' works but this causes problems for
# pylint unless you use 'from htcondor import htcondor'. Older
# versions of HTCondor don't work with the latter so instead of
# adding a version requirement to HTCondor-CE, we'll just ignore
# these errors
run: |
export PYTHONPATH=$PYTHONPATH:$PWD/src/htcondorce
pylint --errors-only --disable no-member $PYTHON_FILES
flake8:
runs-on: ubuntu-20.04
needs: [python-files]
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.6
uses: actions/setup-python@v4
with:
python-version: 3.6
- uses: actions/cache@v3
with:
path: ~/pip-cache
key: pip-3.6-${{ github.sha }}
# allow cache hits from previous runs of the current branch,
# parent branch, then upstream branches, in that order
restore-keys: |
pip-3.6-
- name: Install Requirements
run: |
python -m pip install --upgrade pip
pip --cache-dir ~/pip-cache install flake8 htcondor flask jinja2 gunicorn
- name: Run flake8
env:
PYTHON_FILES: ${{ needs.python-files.outputs.filelist }}
run: |
export PYTHONPATH=$PYTHONPATH:$PWD/src/htcondorce
flake8 --select F $PYTHON_FILES