Adding appci stuff

This commit is contained in:
Alexandre Aubin 2017-08-26 15:01:31 +02:00
parent 16fe5a3416
commit 497b2d13f0
5 changed files with 110 additions and 2 deletions

5
.gitignore vendored
View file

@ -1,5 +1,6 @@
data/*.json
www
token
pullrequests/data/*.json
roadmap/data/*.xml
pullrequests/data/
roadmap/data/
appci/data/

43
appci/analyze.py Normal file
View file

@ -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()

0
appci/data/.gitkeep Normal file
View file

15
appci/fetch.sh Normal file
View file

@ -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

49
appci/publish.py Executable file
View file

@ -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.")