mirror of
https://github.com/YunoHost/package_linter.git
synced 2024-09-03 20:06:12 +02:00
Implement new level 7 and 8 definitions
This commit is contained in:
parent
fe90e3acec
commit
d80db3d9a4
1 changed files with 36 additions and 34 deletions
|
@ -261,7 +261,12 @@ def spdx_licenses():
|
||||||
return content
|
return content
|
||||||
|
|
||||||
tests = {}
|
tests = {}
|
||||||
tests_reports = []
|
tests_reports = {
|
||||||
|
"warning": [],
|
||||||
|
"error": [],
|
||||||
|
"info": [],
|
||||||
|
"success": [],
|
||||||
|
}
|
||||||
|
|
||||||
def test(**kwargs):
|
def test(**kwargs):
|
||||||
def decorator(f):
|
def decorator(f):
|
||||||
|
@ -288,7 +293,9 @@ class TestSuite():
|
||||||
for report in reports:
|
for report in reports:
|
||||||
if output == "plain":
|
if output == "plain":
|
||||||
report.display()
|
report.display()
|
||||||
tests_reports.append((test.__qualname__, report))
|
report_type = report.__class__.__name__.lower()
|
||||||
|
test_name = test.__qualname__
|
||||||
|
tests_reports[report_type].append((test_name, report))
|
||||||
|
|
||||||
# ############################################################################
|
# ############################################################################
|
||||||
# Actual high-level checks
|
# Actual high-level checks
|
||||||
|
@ -331,44 +338,45 @@ class App(TestSuite):
|
||||||
|
|
||||||
def report(self):
|
def report(self):
|
||||||
|
|
||||||
self.run_single_test(App.qualify_for_level_7) # That test is meant to be the last test being ran...
|
# These are meant to be the last stuff running, they are based on
|
||||||
|
# previously computed errors/warning/successes
|
||||||
errors = [r for r in tests_reports if isinstance(r[1], Error)]
|
self.run_single_test(App.qualify_for_level_7)
|
||||||
warnings = [r for r in tests_reports if isinstance(r[1], Warning)]
|
self.run_single_test(App.qualify_for_level_8)
|
||||||
success = [r for r in tests_reports if isinstance(r[1], Success)]
|
|
||||||
|
|
||||||
if output == "json":
|
if output == "json":
|
||||||
print(json.dumps({
|
print(json.dumps({
|
||||||
"warnings": [test for test, _ in warnings],
|
"warning": [test for test, _ in tests_reports["warning"]],
|
||||||
"errors": [test for test, _ in errors],
|
"error": [test for test, _ in tests_reports["error"]],
|
||||||
"success": [test for test, _ in success]
|
"success": [test for test, _ in tests_reports["success"]],
|
||||||
|
"info": [test for test, _ in tests_reports["info"]]
|
||||||
}, indent=4))
|
}, indent=4))
|
||||||
return
|
return
|
||||||
|
|
||||||
if errors:
|
if tests_reports["error"]:
|
||||||
print("Uhoh there are some errors to be fixed :(")
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
elif len(warnings) > 3:
|
|
||||||
|
def qualify_for_level_7(self):
|
||||||
|
|
||||||
|
if tests_reports["error"]:
|
||||||
|
print("Uhoh there are some errors to be fixed :(")
|
||||||
|
elif len(tests_reports["warning"]) > 3:
|
||||||
print("Still some warnings to be fixed :s")
|
print("Still some warnings to be fixed :s")
|
||||||
elif len(warnings) > 0:
|
elif len(tests_reports["warning"]) > 0:
|
||||||
print("Only %s warning remaining! You can do it!" % len(warnings))
|
print("Only %s warning remaining! You can do it!" % len(test_reports["warning"]))
|
||||||
else:
|
else:
|
||||||
print_happy("Not even a warning! Congratz and thank you for keeping that package up to date with good practices !")
|
yield Success("Not even a warning! Congratz and thank you for keeping that package up to date with good practices! This app qualifies for level 7!")
|
||||||
|
|
||||||
def qualify_for_level_7(app):
|
def qualify_for_level_8(self):
|
||||||
|
|
||||||
# If any error found, nope
|
successes = [test.split(".")[1] for test, _ in tests_reports["success"]]
|
||||||
if any(isinstance(report, Error) for _, report in tests_reports):
|
|
||||||
return
|
|
||||||
|
|
||||||
# If any warning, nope
|
# Level 8 = qualifies for level 7 + maintained + long term good quality
|
||||||
if any(isinstance(report, Warning) for test_report in tests_reports):
|
catalog_infos = self.app_catalog.catalog_infos
|
||||||
return
|
is_maintained = catalog_infos and catalog_infos.get("maintained", True) is True
|
||||||
|
if not is_maintained:
|
||||||
# Last condition is to be long-term good quality
|
print("The app is flagged as not maintained in the app catalog")
|
||||||
if any(test.split(".")[1] == "is_long_term_good_quality"
|
elif "qualify_for_level_7" in successes and "is_long_term_good_quality" in successes:
|
||||||
for test, report in tests_reports if isinstance(report, Success)):
|
yield Success("The app is maintained and long-term good quality, and therefore qualifies for level 8!")
|
||||||
yield Success("This app qualifies for level 7!")
|
|
||||||
|
|
||||||
#########################################
|
#########################################
|
||||||
# _____ _ #
|
# _____ _ #
|
||||||
|
@ -1036,12 +1044,6 @@ class AppCatalog(TestSuite):
|
||||||
if self.catalog_infos and self.catalog_infos.get("state", "working") != "working":
|
if self.catalog_infos and self.catalog_infos.get("state", "working") != "working":
|
||||||
yield Warning("The application is not flagged as working in YunoHost's apps catalog")
|
yield Warning("The application is not flagged as working in YunoHost's apps catalog")
|
||||||
|
|
||||||
@test()
|
|
||||||
def is_maintained(self):
|
|
||||||
|
|
||||||
if self.catalog_infos and self.catalog_infos.get("maintained", True) is not True:
|
|
||||||
yield Warning("The application is flagged as not maintained in YunoHost's apps catalog")
|
|
||||||
|
|
||||||
@test()
|
@test()
|
||||||
def has_category(self):
|
def has_category(self):
|
||||||
if self.catalog_infos and not self.catalog_infos.get("category"):
|
if self.catalog_infos and not self.catalog_infos.get("category"):
|
||||||
|
|
Loading…
Add table
Reference in a new issue