summaryrefslogtreecommitdiffstats
path: root/scripts/GeneratePostPublishReport.py
blob: c496debb61aeff57befd4080e7a5ef0492032600 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import argparse, requests

parser = argparse.ArgumentParser(description="Post-publish report generator")
parser.add_argument("version", type=str, help="Vaadin version that was just built")
parser.add_argument("teamcityUrl", type=str, help="Address to the teamcity server")
parser.add_argument("buildTypeId", type=str, help="The ID of this build step")
parser.add_argument("buildId", type=str, help="ID of the build to generate this report for")
parser.add_argument("projectId", type=str, help="The ID of this project")
args = parser.parse_args()

buildResultUrl = "http://{}/viewLog.html?buildId={}&tab=buildResultsDiv&buildTypeId={}".format(args.teamcityUrl, args.buildId, args.buildTypeId)

(major, minor, maintenance) = args.version.split(".", 2)
prerelease = "." in maintenance

def checkUrlStatus(url):
	r = requests.get(url)
	return r.status_code == 200

def createTableRow(*columns):
    html = "<tr>"
    for column in columns:
        html += "<td>" + column + "</td>"
    return html + "</tr>"

traffic_light = "<svg width=\"20px\" height=\"20px\" style=\"padding-right:5px\"><circle cx=\"10\" cy=\"10\" r=\"10\" fill=\"{color}\"/></svg>"

def getTrafficLight(b):
	return traffic_light.format(color="green") if b else traffic_light.format(color="red")

content = "<html><head></head><body><table>"

tagOk = checkUrlStatus("https://github.com/vaadin/framework/releases/tag/{ver}".format(ver=args.version))
content += createTableRow(getTrafficLight(tagOk), "Tag ok on github.com")

# Tag and pin build
content += createTableRow("", "<a href=\"{url}\">Tag and pin build</a>".format(url=buildResultUrl))

# Traffic light for archetype metadata
archetypeMetadataUrl = ""
if not prerelease:
    archetypeMetadataUrl = "http://vaadin.com/download/maven-archetypes.xml"
else:
    archetypeMetadataUrl ="http://vaadin.com/download/maven-archetypes-prerelease.xml"

archetype_metadata_request = requests.get(archetypeMetadataUrl)
if archetype_metadata_request.status_code != 200:
    content += createTableRow(traffic_light.format(color="black"), "<a href='{url}'>Check archetype metadata: unable to retrieve metadata</a>".format(url=archetypeMetadataUrl))
else:
    if "version=\"{version}\"".format(version=args.version) in archetype_metadata_request.content:
        content += createTableRow(traffic_light.format(color="green"), "<a href='{url}'>Check archetype metadata: metadata is correct</a>".format(url=archetypeMetadataUrl))
    else:
        content += createTableRow(traffic_light.format(color="red"), "<a href='{url}'>Check archetype metadata: metadata is incorrect</a>".format(url=archetypeMetadataUrl))

# TODO GitHub milestones

# Inform marketing and PO
content += createTableRow("", "Inform marketing and PO about the release")

# Link to version update in teamcity
content += createTableRow("", "<a href=\"http://{}/admin/editProject.html?projectId={}&tab=projectParams\">Update vaadin.version.latest and vaadin.version.next parameters in TeamCity</a>".format(args.teamcityUrl, args.projectId))

# Link to GH release notes
content += createTableRow("", "<a href=\"https://github.com/vaadin/framework/releases/new\">Write release notes in GH</a>")

content += "</table></body></html>"

with open("result/report.html", "wb") as f:
    f.write(content)