Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PyCodeStyle (formaly pep8) checks to CI #56

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/pycodestyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: PyCodeStyle
on:
- push
- pull_request
- workflow_call

jobs:
python-3:
name: PyCodeStyle
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install pylint
run: |
python -m pip install --upgrade pip
pip install pycodestyle

- name: Analysing the code with pylint
run: |
pycodestyle --config=./.pycodestyle .

python-2-7:
name: PyCodeStyle
runs-on: ubuntu-latest
container:
image: python:2.7.18-buster
strategy:
fail-fast: false
matrix:
python-version: ["2.7"]

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install pylint
run: |
python -m pip install --upgrade pip
pip install pycodestyle

- name: Analysing the code with pylint
run: |
pycodestyle --config=./.pycodestyle .
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
uses: redhat-cop/infra.lvm_snapshots/.github/workflows/ansible-lint.yml@main
pylint:
uses: redhat-cop/infra.lvm_snapshots/.github/workflows/pylint.yml@main
pycodestyle:
uses: redhat-cop/infra.lvm_snapshots/.github/workflows/pycodestyle.yml@main
shellcheck:
uses: redhat-cop/infra.lvm_snapshots/.github/workflows/shellcheck.yml@main
codespell:
Expand All @@ -19,6 +21,7 @@ jobs:
needs:
- ansible-lint
- pylint
- pycodestyle
- shellcheck
- codespell
runs-on: ubuntu-latest
Expand All @@ -27,6 +30,7 @@ jobs:
python -c "assert set([
'${{ needs.ansible-lint.result }}',
'${{ needs.pylint.result }}',
'${{ needs.pycodestyle.result }}',
'${{ needs.shellcheck.result }}',
'${{ needs.codespell.result }}',
]) == {'success'}"
Expand Down
2 changes: 2 additions & 0 deletions .pycodestyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pycodestyle]
max-line-length=120
6 changes: 5 additions & 1 deletion roles/snapshot_create/files/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@
'ext4'
]


class CheckException(Exception):
""" Exception wrapper """


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


def _main():
args = parser.parse_args()

Expand Down Expand Up @@ -157,7 +160,7 @@ def _calc_requested_size(group_info, volume):

def _get_volume_size(vol):
volume_info_str = subprocess.check_output(
[_LVS_COMMAND, "{vg}/{lv}".format(vg=vol['vg'],lv=vol['lv']), '-v', '--units', 'b', '--reportformat', 'json']
[_LVS_COMMAND, "{vg}/{lv}".format(vg=vol['vg'], lv=vol['lv']), '-v', '--units', 'b', '--reportformat', 'json']
)
volume_info_json = json.loads(volume_info_str)
volume_info = volume_info_json['report'][0]['lv'][0]
Expand Down Expand Up @@ -230,5 +233,6 @@ def _to_printable_volumes(volumes):
} for volume in volumes
}


if __name__ == '__main__':
_main()