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 ability to create issues on Github repo that will flag the app as broken or low quality #77

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 50 additions & 1 deletion package_linter.py
Expand Up @@ -7,6 +7,7 @@
import json
import shlex
import urllib.request
import requests
import codecs

reader = codecs.getreader("utf-8")
Expand Down Expand Up @@ -67,7 +68,14 @@ def print_warning(str):

def print_error(str):
global return_code
return_code = 1
if return_code == 0:
return_code = 1
print(c.FAIL + "✘", str, c.END)


def print_error_broken(str):
global return_code
return_code = 2
print(c.FAIL + "✘", str, c.END)


Expand Down Expand Up @@ -105,6 +113,7 @@ def analyze(self):
self.check_helper_consistency()
self.check_source_management()
self.check_manifest()
self.check_issues()

# Copypasta of lines from __init__ instead of using
# self.script.values() because dict are unordered until python 3.7
Expand Down Expand Up @@ -438,6 +447,46 @@ def license_mentionned_in_readme(path):
"already be playing with are only available on 3.x..."
)

def check_issues(self):

manifest = os.path.join(self.path, 'manifest.json')
with open(manifest, encoding='utf-8') as data_file:
manifest = json.loads(data_file.read(), object_pairs_hook=check_for_duplicate_keys)

app_id = manifest["id"]
catalog = requests.get("https://raw.githubusercontent.com/YunoHost/apps/master/apps.json").json()
if app_id not in catalog:
print_error("Your app does not appears to be listed in YunoHost's app catalog.")
return
elif catalog[app_id]["state"] != "working":
print_warning("Your app is not flagged as 'working' in Yunohost's app catalog.")

repo_url = catalog[app_id]["url"]
if "github.com" not in repo_url:
print_warning("Can't check if there are any blocking issues pending, can only do this for apps hosted on github for now.")
return

uri = 'repos/{}/issues'.format(repo_url.replace("https://github.com/", ""))

r = requests.get('https://api.github.com/{}'.format(uri)).json()
if "message" in r and r["message"] == "Not Found":
print('https://api.github.com/{}'.format(uri))
print(r["message"])
return

issues = [ i["title"] for i in r if not "pull_request" in i ]

blocking_issues = [ i for i in issues if i.upper().startswith("[LOW QUALITY]") or i.upper().startswith("[BROKEN]") ]
if blocking_issues:
print_error("There are important pending issues on the git repo to be solved :\n - "+"\n - ".join(blocking_issues))
else:
return

if [ i for i in issues if i.startswith("[BROKEN]") ]:
print_error_broken("The app will be considered BROKEN (level 0) as long as it's not solved.")
else:
print_error("The app will be considered low quality as long as it's not solved.")



class Script():
Expand Down