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 support for tox with pylint, pyunit, flake8, black, shellcheck #15

Merged
merged 1 commit into from
Sep 3, 2020

Conversation

richm
Copy link
Contributor

@richm richm commented Sep 1, 2020

add support for tox with pylint, pyunit, flake8, black, shellcheck

@richm richm force-pushed the tox branch 3 times, most recently from 2c74c32 to a519280 Compare September 1, 2020 22:12
@richm richm requested review from nhosoi and pcahyna September 1, 2020 22:15
@richm
Copy link
Contributor Author

richm commented Sep 1, 2020

@nhosoi this will give you the ability to do linting/formatting of your python file, and the ability to do unit testing of your functions e.g. you could create a unit test like tests/unit/test_lsr_role2collection.py like this:

# SPDX-License-Identifier: GPL-2.0-or-later
"""unit tests for lsr_role2collection"""

import unittest

import lsr_role2collection

class LSRRole2Collection(unittest.TestCase):
    """test lsr_role2collection"""

    def test_add_rolename(self):
        """test add_rolename"""
        result = lsr_role2collection.add_rolename("README.md", "rolename")
        self.assertEqual("README-rolename.md", result)
        ... more tests for this ...

    def test_for_other_funcs(self):
        """tests for other funcs""""
....

@richm
Copy link
Contributor Author

richm commented Sep 1, 2020

@nhosoi note that if you use this, you will have to rename the python script to be lsr_role2collection.py

@nhosoi
Copy link
Contributor

nhosoi commented Sep 1, 2020

Thank you, @richm!!
I checked out this pr and ran pylint, black, etc. against my local changes (and I got lots of errors/warnings :) which make sense.
One error not clear to me is from tox -e shellcheck. Is the command line wrong to start shellcheck?

shellcheck create: /home/nhosoi/linux-system-roles/auto-maintenance/.tox/shellcheck
shellcheck run-test-pre: PYTHONHASHSEED='1524971774'
shellcheck run-test: commands[0] | bash -c 'shellcheck -e SC1090 *.sh'
/usr/bin/bash: shellcheck: command not found
ERROR: InvocationError for command /usr/bin/bash -c 'shellcheck -e SC1090 *.sh' (exited with code 127)
___________________________________ summary ____________________________________
ERROR:   shellcheck: commands failed

@richm
Copy link
Contributor Author

richm commented Sep 1, 2020

Thank you, @richm!!
I checked out this pr and ran pylint, black, etc. against my local changes (and I got lots of errors/warnings :) which make sense.
One error not clear to me is from tox -e shellcheck. Is the command line wrong to start shellcheck?

You have to install shellcheck manually since it isn't a python pypi package: dnf -y install shellcheck

shellcheck create: /home/nhosoi/linux-system-roles/auto-maintenance/.tox/shellcheck
shellcheck run-test-pre: PYTHONHASHSEED='1524971774'
shellcheck run-test: commands[0] | bash -c 'shellcheck -e SC1090 *.sh'
/usr/bin/bash: shellcheck: command not found
ERROR: InvocationError for command /usr/bin/bash -c 'shellcheck -e SC1090 *.sh' (exited with code 127)
___________________________________ summary ____________________________________
ERROR:   shellcheck: commands failed

@nhosoi
Copy link
Contributor

nhosoi commented Sep 1, 2020

Nice. Thanks! (did you know dnf is case sensitive? Even worse, dnf search shellcheck does not return ShellCheck but just ghc-ShellCheck and its friends... Very confusing...):

$ tox -e shellcheck
shellcheck run-test-pre: PYTHONHASHSEED='2970326927'
shellcheck run-test: commands[0] | bash -c 'shellcheck -e SC1090 *.sh'
____________________________________________________ summary ____________________________________________________
  shellcheck: commands succeeded
  congratulations :)

Copy link
Contributor

@nhosoi nhosoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

add support for tox with pylint, pyunit, flake8, black, shellcheck
@richm
Copy link
Contributor Author

richm commented Sep 2, 2020

Nice. Thanks! (did you know dnf is case sensitive? Even worse, dnf search shellcheck does not return ShellCheck but just ghc-ShellCheck and its friends... Very confusing...):

added a check for shellcheck - if it is not in your PATH, you will get an error message like this:
ERROR: shellcheck not found - try dnf -y install ShellCheck

@richm
Copy link
Contributor Author

richm commented Sep 3, 2020

@nhosoi is this latest commit working for you?

@nhosoi
Copy link
Contributor

nhosoi commented Sep 3, 2020

@nhosoi is this latest commit working for you?

Yes, it is. My approval is for the latest commit you mentioned. Please merge this pr.
(And sorry for my comment I mistakenly put, which removed it....:p)

@richm richm merged commit 1429f2e into linux-system-roles:master Sep 3, 2020
@richm richm deleted the tox branch September 3, 2020 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants