test: run mypy in test-src not in GH actions
This commit is contained in:
parent
e330e82cf0
commit
5cb2da55f1
3 changed files with 29 additions and 12 deletions
12
.github/workflows/checks.yml
vendored
12
.github/workflows/checks.yml
vendored
|
|
@ -74,15 +74,3 @@ jobs:
|
|||
-k autopep8 \
|
||||
--rootdir=. \
|
||||
-v
|
||||
|
||||
mypy:
|
||||
name: "Mypy check"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Clone repo
|
||||
uses: actions/checkout@v2
|
||||
- name: Check files with mypy
|
||||
run: |
|
||||
sudo apt install python3-pip -y
|
||||
sudo pip install mypy types-pyyaml jsonschema mako
|
||||
mypy osbuild
|
||||
|
|
|
|||
|
|
@ -57,6 +57,17 @@ def test_pylint(source_files):
|
|||
pytest.fail("pylint issues detected")
|
||||
|
||||
|
||||
@pytest.mark.skipif(not test.TestBase.have_mypy(), reason="mypy not available")
|
||||
def test_mypy():
|
||||
#
|
||||
# Run `mypy` on osbuild sources.
|
||||
#
|
||||
|
||||
r = subprocess.run(["mypy", "osbuild/"], check=False)
|
||||
if r.returncode != 0:
|
||||
pytest.fail("mypy issues detected")
|
||||
|
||||
|
||||
@pytest.mark.skipif(not test.TestBase.have_autopep8(), reason="autopep8 not available")
|
||||
def test_autopep8(source_files):
|
||||
r = subprocess.run(["autopep8-3", "--diff", "--exit-code"] + source_files, check=False)
|
||||
|
|
|
|||
18
test/test.py
18
test/test.py
|
|
@ -185,6 +185,24 @@ class TestBase(unittest.TestCase):
|
|||
|
||||
return r.returncode == 0 and "autopep8" in r.stdout
|
||||
|
||||
@staticmethod
|
||||
def have_mypy() -> bool:
|
||||
"""Check mypy Availability
|
||||
|
||||
This checks whether `mypy` is available in the current path and
|
||||
can be called by this process.
|
||||
"""
|
||||
|
||||
try:
|
||||
r = subprocess.run(
|
||||
["mypy", "--version"],
|
||||
encoding="utf-8", stdout=subprocess.PIPE, check=False
|
||||
)
|
||||
except FileNotFoundError:
|
||||
return False
|
||||
|
||||
return r.returncode == 0 and "mypy" in r.stdout
|
||||
|
||||
@staticmethod
|
||||
def have_rpm_ostree() -> bool:
|
||||
"""Check rpm-ostree Availability
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue