summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi>2024-02-18 21:53:48 +0200
committerAineopintojen-harjoitustyo-Algoritmit-j <github-hy-tiralabra@v.hix.fi>2024-02-18 21:53:48 +0200
commit854e8468ea035b7d588ca7cc26a96f8f700541e7 (patch)
treebadfb3484902ac282eb2fd94c111df87a8389acd
parentf8452c313ca78e5f04714331c4a222e8aed53805 (diff)
Improved developer commands menu.
-rw-r--r--.github/workflows/auto.yml2
-rw-r--r--dev/__init__.py9
-rw-r--r--dev/commands.py66
-rw-r--r--pyproject.toml7
4 files changed, 51 insertions, 33 deletions
diff --git a/.github/workflows/auto.yml b/.github/workflows/auto.yml
index adec8b0..f0c280f 100644
--- a/.github/workflows/auto.yml
+++ b/.github/workflows/auto.yml
@@ -35,7 +35,7 @@ jobs:
# Run coverage xml
- name: Run unittests with coverage and generate xml
- run: poetry run covxml
+ run: poetry run dev covxml
# xml -> codecov
- name: Upload coverage reports to Codecov
diff --git a/dev/__init__.py b/dev/__init__.py
index 52cc7d9..796c8ef 100644
--- a/dev/__init__.py
+++ b/dev/__init__.py
@@ -1,8 +1 @@
-from .commands import (
- dev_pylint,
- dev_pytest,
- dev_coverage,
- dev_covhtml,
- dev_covxml,
- dev_covff,
- dev_all)
+from .commands import dev_command
diff --git a/dev/commands.py b/dev/commands.py
index ed9341a..ff94eb2 100644
--- a/dev/commands.py
+++ b/dev/commands.py
@@ -1,36 +1,66 @@
-import pytest
-import pylint
from subprocess import run
+from sys import argv
-def dev_pylint():
- return pylint.run_pylint(argv=["-v", "src/miinaharava"])
+usage = """
+Komentoja kehitykseen:
+
+poetry run dev <komento>
+
+Komennot:
+ pytest Ajaa yksikkötestit
+ pylint Tarkistaa koodin ulkoasun
+ coverage Tutkii haarakattavuuden
+ covhtml Tekee coverage haarakattavuusraportin HTML muodossa
+ covxml Tekee coverage haarakattavuusraportin XML muodossa
+ covff Tekee haarakattavuusraportin ja avaa sen firefoxilla
+ all Sama kuin <covff> + <pylint>
+"""
+
+def dev_command():
+ if len(argv)==2:
+ match argv[1]:
+ case "pytest":
+ import pytest
+ return pytest.main(["-v"])
+ case "pylint":
+ return run_pylint()
+ case "coverage":
+ return run_coverage()
+ case "covhtml":
+ return run_covhtml()
+ case "covxml":
+ return run_covxml()
+ case "covff":
+ return run_covff()
+ case "all":
+ if e := run_covff(): return e
+ return run_pylint()
+ print(usage)
+ return 0
-def dev_pytest():
- return pytest.main(["-v"])
+def run_pylint():
+ import pylint
+ return pylint.run_pylint(argv=["-v", "src/miinaharava"])
-def dev_coverage():
+def run_coverage():
return run(
"poetry run python3 -m coverage run --branch -m pytest -v ".split()
).returncode
-
-def dev_covhtml():
- if e := dev_coverage(): return e
+
+def run_covhtml():
+ if e := run_coverage(): return e
return run(
"poetry run python3 -m coverage html".split()
).returncode
-def dev_covxml():
- if e := dev_coverage(): return e
+def run_covxml():
+ if e := run_coverage(): return e
return run(
"poetry run python3 -m coverage xml".split()
).returncode
-def dev_covff():
- if e := dev_covhtml(): return e
+def run_covff():
+ if e := run_covhtml(): return e
return run(
"firefox htmlcov/index.html".split()
).returncode
-
-def dev_all():
- if e := dev_covff(): return e
- return dev_pylint()
diff --git a/pyproject.toml b/pyproject.toml
index 8cfad68..a14ef19 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -15,12 +15,7 @@ coverage = "^7.4.0"
pylint = "^3.0.3"
[tool.poetry.scripts]
-pylint = "dev:dev_pylint"
-pytest = "dev:dev_pytest"
-covhtml = "dev:dev_covhtml"
-covxml = "dev:dev_covxml"
-covff = "dev:dev_covff"
-all = "dev:dev_all"
+dev = "dev:dev_command"
[build-system]
requires = ["poetry-core"]