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 createTableRow(*columns):
html = "
"
for column in columns:
html += "
" + column + "
"
return html + "
"
traffic_light = ""
content = "
"
# Batch update tickets in trac
content += createTableRow("", "Batch update tickets in Trac")
# Create milestone for next release
content += createTableRow("", "Create milestone for next release")
# Tag and pin build
content += createTableRow("", "Tag and pin build".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"), "Check archetype metadata: unable to retrieve metadata".format(url=archetypeMetadataUrl))
else:
if "version=\"{version}\"".format(version=args.version) in archetype_metadata_request.content:
content += createTableRow(traffic_light.format(color="green"), "Check archetype metadata: metadata is correct".format(url=archetypeMetadataUrl))
else:
content += createTableRow(traffic_light.format(color="red"), "Check archetype metadata: metadata is incorrect".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("", "Update vaadin.version.latest and vaadin.version.next parameters in TeamCity".format(args.teamcityUrl, args.projectId))
# Link to GH release notes
content += createTableRow("", "Write release notes in GH")
content += "
"
with open("result/report.html", "wb") as f:
f.write(content)