diff --git a/.gitignore b/.gitignore index 899cd25..2e105a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ data/*.json www token -pullrequests/data/*.json -roadmap/data/*.xml +pullrequests/data/ +roadmap/data/ +appci/data/ diff --git a/appci/analyze.py b/appci/analyze.py new file mode 100644 index 0000000..ba8fac2 --- /dev/null +++ b/appci/analyze.py @@ -0,0 +1,43 @@ +import json +import glob + + +def main(): + + apps = [] + + for f in glob.glob("data/*"): + + app = f.replace("data/","") + appdata = open(f).read().strip() + + if appdata == "": + continue + + data = {} + data["name"] = app + data["statuses"] = [] + + applevel = appdata.split("\n")[1][0] + appdata = appdata.split("\n")[0] + data["level"] = applevel + + for c in appdata: + if c == "0": + s = "danger" + elif c == "1": + s = "success" + else: + s = "unknown" + + data["statuses"].append(s) + + apps.append(data) + + apps.sort(key=lambda a: a["level"], reverse=True) + + with open("apps.json", "w") as f: + json.dump(apps, f) + +main() + diff --git a/appci/data/.gitkeep b/appci/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/appci/fetch.sh b/appci/fetch.sh new file mode 100644 index 0000000..fc10d2e --- /dev/null +++ b/appci/fetch.sh @@ -0,0 +1,15 @@ + +while read APP; +do + APPNAME=$(echo $APP | awk '{print $1}') + echo $APPNAME + wget -O data/$APPNAME "https://ci-apps.yunohost.org/jenkins/job/$APP/lastBuild/consoleText" + + CHECKS=$(cat data/$APPNAME | grep "Package linter:" -A15 | tail -n 16 | sed -e 's/FAIL/0/g' -e 's/SUCCESS/1/g' -e 's/Not evaluated./X/' | awk '{print $NF}' | tr -d '\n') + LEVELS=$(cat data/$APPNAME | grep 'Level of this application' -A10 | tail -n 11 | sed -e 's@N/A@X@g' -e 's/ Level //g' -e 's/Level of this application//g' | awk '{print $2}' | tr -d '\n') + + echo $CHECKS > data/$APPNAME + echo $LEVELS >> data/$APPNAME + +done < apps + diff --git a/appci/publish.py b/appci/publish.py new file mode 100755 index 0000000..9f4bda7 --- /dev/null +++ b/appci/publish.py @@ -0,0 +1,49 @@ +#!/usr/bin/python3 + +import os +import json + +from jinja2 import Template +from ansi2html import Ansi2HTMLConverter +from ansi2html.style import get_styles + +############################################################################### + +output_dir = "../www/" + +template_path = os.path.join(output_dir,"template_appci.html") +output_path = os.path.join(output_dir,"appci.html") + +summary_path = os.path.join("./", "summary.json") + +############################################################################### + +conv = Ansi2HTMLConverter() +shell_css = "\n".join(map(str, get_styles(conv.dark_bg, conv.scheme))) + +def shell_to_html(shell): + return conv.convert(shell, False) + +############################################################################### + +if __name__ == '__main__': + + # Fetch the list of all reports, sorted in reverse-chronological order + + #summary = json.load(open(summary_path)) + + + summary = { "testnames" : ["Package linter","Installation","Deleting","Installation in a sub path","Deleting from a sub path","Installation on the root","Deleting from root","Upgrade","Installation in private mode","Installation in public mode","Multi-instance installations","Malformed path","Port already used","Backup","Restore","Change URL"]} + + summary["apps"] = json.loads(open("apps.json").read()) + + # Generate the output using the template + + template = open(template_path, "r").read() + t = Template(template) + + result = t.render(data=summary, convert=shell_to_html, shell_css=shell_css) + + open(output_path, "w").write(result) + + print("Done.")