forked from htcondor/htcondor-ce
-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (75 loc) · 2.66 KB
/
python-linters.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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