Skip to content

Commit b649c9d

Browse files
committed
Add PyCodeStyle (formaly pep8) checks to CI
Add a config file Make the required fixes Signed-off-by: Ygal Blum <[email protected]>
1 parent 8e8cdf7 commit b649c9d

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

.github/workflows/pycodestyle.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: PyCodeStyle
2+
on:
3+
- push
4+
- pull_request
5+
- workflow_call
6+
7+
jobs:
8+
python-3:
9+
name: PyCodeStyle
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
27+
- name: Install pylint
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install pycodestyle
31+
32+
- name: Analysing the code with pylint
33+
run: |
34+
pycodestyle --config=./.pycodestyle .
35+
36+
python-2-7:
37+
name: PyCodeStyle
38+
runs-on: ubuntu-latest
39+
container:
40+
image: python:2.7.18-buster
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
python-version: ["2.7"]
45+
46+
steps:
47+
- name: Checkout
48+
uses: actions/checkout@v4
49+
with:
50+
fetch-depth: 0
51+
52+
- name: Install pylint
53+
run: |
54+
python -m pip install --upgrade pip
55+
pip install pycodestyle
56+
57+
- name: Analysing the code with pylint
58+
run: |
59+
pycodestyle --config=./.pycodestyle .

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
uses: redhat-cop/infra.lvm_snapshots/.github/workflows/ansible-lint.yml@main
1212
pylint:
1313
uses: redhat-cop/infra.lvm_snapshots/.github/workflows/pylint.yml@main
14+
pycodestyle:
15+
uses: redhat-cop/infra.lvm_snapshots/.github/workflows/pycodestyle.yml@main
1416
shellcheck:
1517
uses: redhat-cop/infra.lvm_snapshots/.github/workflows/shellcheck.yml@main
1618
codespell:
@@ -19,6 +21,7 @@ jobs:
1921
needs:
2022
- ansible-lint
2123
- pylint
24+
- pycodestyle
2225
- shellcheck
2326
- codespell
2427
runs-on: ubuntu-latest
@@ -27,6 +30,7 @@ jobs:
2730
python -c "assert set([
2831
'${{ needs.ansible-lint.result }}',
2932
'${{ needs.pylint.result }}',
33+
'${{ needs.pycodestyle.result }}',
3034
'${{ needs.shellcheck.result }}',
3135
'${{ needs.codespell.result }}',
3236
]) == {'success'}"

.pycodestyle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pycodestyle]
2+
max-line-length=120

roles/snapshot_create/files/check.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@
3030
'ext4'
3131
]
3232

33+
3334
class CheckException(Exception):
3435
""" Exception wrapper """
3536

37+
3638
parser = argparse.ArgumentParser()
3739
parser.add_argument('that', help='What should the script check', type=str, choices=['snapshots', 'resize'])
3840
parser.add_argument('volumes', help='Volumes JSON array in a string', type=str)
3941

42+
4043
def _main():
4144
args = parser.parse_args()
4245

@@ -157,7 +160,7 @@ def _calc_requested_size(group_info, volume):
157160

158161
def _get_volume_size(vol):
159162
volume_info_str = subprocess.check_output(
160-
[_LVS_COMMAND, "{vg}/{lv}".format(vg=vol['vg'],lv=vol['lv']), '-v', '--units', 'b', '--reportformat', 'json']
163+
[_LVS_COMMAND, "{vg}/{lv}".format(vg=vol['vg'], lv=vol['lv']), '-v', '--units', 'b', '--reportformat', 'json']
161164
)
162165
volume_info_json = json.loads(volume_info_str)
163166
volume_info = volume_info_json['report'][0]['lv'][0]
@@ -230,5 +233,6 @@ def _to_printable_volumes(volumes):
230233
} for volume in volumes
231234
}
232235

236+
233237
if __name__ == '__main__':
234238
_main()

0 commit comments

Comments
 (0)