aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/GeneratePublishReportPart1.py
blob: d3eda80284be20e8bb3d5416b9039fb7badcaf6a (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#coding=UTF-8

try:
	import requests
except Exception as e:
	print("GeneratePublishReportPart1 depends on requests library. Install it with `pip install requests`")
	sys.exit(1)
import argparse, cgi, re
from os.path import exists, isdir
from os import makedirs

metadataChecks = {
	'https://vaadin.com/download/LATEST7': '^7\..*',
	'https://vaadin.com/download/VERSIONS_7': '^7\..*',
	'https://vaadin.com/download/release/7.7/LATEST': '^7\..*',
	'https://vaadin.com/download/LATEST': '^6\..*',
	'https://vaadin.com/download/PRERELEASES': '^{ver}'
}

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")
args = parser.parse_args()

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

resultPath = "result"
if not exists(resultPath):
	makedirs(resultPath)
elif not isdir(resultPath):
	print("Result path is not a directory.")
	sys.exit(1)

(major, minor, maintenance) = args.version.split(".", 2)
prerelease = "." in maintenance
if prerelease:
	maintenance = maintenance.split('.')[0]

def checkUrlContents(url, regexp):
	r = requests.get(url)
	return re.match(regexp, r.text) != None

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

metadataOk = True
for url in metadataChecks:
	metadataOk = metadataOk and checkUrlContents(url, metadataChecks[url].format(ver=args.version))

tagOk = checkUrlStatus("https://github.com/vaadin/framework/releases/tag/{ver}".format(ver=args.version))

if not prerelease:
	downloadPageOk = checkUrlStatus("https://vaadin.com/download/release/{maj}.{min}/{ver}/".format(maj=major, min=minor, ver=args.version))
else:
	downloadPageOk = checkUrlStatus("https://vaadin.com/download/prerelease/{maj}.{min}/{maj}.{min}.{main}/{ver}".format(maj=major, min=minor, main=maintenance, ver=args.version))

content = """<html>
<head></head>
<body>
<table>
<tr><td>{metadataOk}</td><td>Metadata ok on vaadin.com</td></tr>
<tr><td>{downloadPageOk}</td><td>Download folder on vaadin.com contains the version</td></tr>
""".format(metadataOk=getTrafficLight(metadataOk), downloadPageOk=getTrafficLight(downloadPageOk))

mavenUrl = ""
if not prerelease:
	mavenUrl = "http://repo1.maven.org/maven2/com/vaadin/vaadin-server/{ver}".format(ver=args.version)
	content += "<tr><td></td><td><a href='{mvnUrl}'>Check {ver} is published to maven.org (might take a while)</td></tr>".format(ver=args.version, mvnUrl=mavenUrl)
else:
	mavenUrl = "http://maven.vaadin.com/vaadin-prereleases/com/vaadin/vaadin-server/{ver}".format(ver=args.version)
	content += "<tr><td></td><td><a href='{mvnUrl}'>Check {ver} is published as prerelease to maven.vaadin.com</td></tr>".format(ver=args.version, mvnUrl=mavenUrl)

content += "<tr><td></td><td><a href=\"https://github.com/vaadin/framework/milestones\">Create milestone for next version in GitHub</a></td></tr>"

content += """
<tr><td></td><td><a href="http://test.vaadin.com/{version}/run/LabelModes?restartApplication">Verify uploaded to test.vaadin.com</a></td></tr>
""".format(version=args.version)

if not prerelease:
	content += '<tr><td></td><td><a href="http://vaadin.com/api">Verify API version list updated</a></td></tr>'

content += """
<tr><td></td><td><a href="http://{teamcityUrl}/viewLog.html?buildId={buildId}&buildTypeId={buildTypeId}&tab=dependencies"><h2>Start Post-Publish Release from dependencies tab</a></td></tr>
</table>
</body>
</html>""".format(teamcityUrl=args.teamcityUrl, buildTypeId=args.buildTypeId, buildId=args.buildId, version=args.version)

f = open("result/report.html", 'w')
f.write(content)
="w"> getDefaultFormat(), isDefaultInMemory(), getDefaultTempDirectory(), readOnly); } return LinkResolver.DEFAULT.resolveLinkedDatabase(linkerDb, linkeeFileName); } /** * Creates a temporary database for holding the table data from * linkeeFileName. * * @param customFile custom file state returned from {@link #loadCustomFile} * @param format the access format for the temp db * @param inMemory whether or not the temp db should be entirely in memory * (while this will be faster, it should only be used if * table data is expected to fit entirely in memory) * @param tempDir the temp dir for a file based temp db ({@code null} for * the system default temp directory) * * @return the temp db for holding the linked table info */ protected Database createTempDb(Object customFile, FileFormat format, boolean inMemory, Path tempDir, boolean readOnly) throws IOException { Path dbFile = null; FileChannel channel = null; boolean success = false; try { if(inMemory) { dbFile = Paths.get(MEM_DB_PREFIX + DB_ID.nextLong() + format.getFileExtension()); channel = MemFileChannel.newChannel(); } else { dbFile = ((tempDir != null) ? Files.createTempFile(tempDir, FILE_DB_PREFIX, format.getFileExtension()) : Files.createTempFile(FILE_DB_PREFIX, format.getFileExtension())); channel = FileChannel.open(dbFile, DatabaseImpl.RW_CHANNEL_OPTS); } TempDatabaseImpl.initDbChannel(channel, format); TempDatabaseImpl db = new TempDatabaseImpl(this, customFile, dbFile, channel, format, readOnly); success = true; return db; } finally { if(!success) { ByteUtil.closeQuietly(channel); deleteDbFile(dbFile); closeCustomFile(customFile); } } } private static void deleteDbFile(Path dbFile) { if((dbFile != null) && dbFile.getFileName().toString().startsWith(FILE_DB_PREFIX)) { try { Files.deleteIfExists(dbFile); } catch(IOException ignores) {} } } private static void closeCustomFile(Object customFile) { if(customFile instanceof Closeable) { ByteUtil.closeQuietly((Closeable)customFile); } } /** * Called by {@link #resolveLinkedDatabase} to determine whether the * linkeeFileName should be treated as a custom file (thus utiliziing a temp * db) or a normal access db (loaded via the default behavior). Loads any * state necessary for subsequently loading data from linkeeFileName. * <p> * The returned custom file state object will be maintained with the temp db * and passed to {@link #loadCustomTable} whenever a new table needs to be * loaded. Also, if this object is {@link Closeable}, it will be closed * with the temp db. * * @param linkerDb the primary database in which the link is defined * @param linkeeFileName the name of the linked file * * @return non-{@code null} if linkeeFileName should be treated as a custom * file (using a temp db) or {@code null} if it should be treated as * a normal access db. */ protected abstract Object loadCustomFile( Database linkerDb, String linkeeFileName) throws IOException; /** * Called by an instance of a temp db when a missing table is first requested. * * @param tempDb the temp db instance which should be populated with the * relevant table info for the given tableName * @param customFile custom file state returned from {@link #loadCustomFile} * @param tableName the name of the table which is requested from the linked * file * * @return {@code true} if the table was available in the linked file, * {@code false} otherwise */ protected abstract boolean loadCustomTable( Database tempDb, Object customFile, String tableName) throws IOException; /** * Subclass of DatabaseImpl which allows us to load tables "on demand" as * well as delete the temporary db on close. */ private static class TempDatabaseImpl extends DatabaseImpl { private final CustomLinkResolver _resolver; private final Object _customFile; protected TempDatabaseImpl(CustomLinkResolver resolver, Object customFile, Path file, FileChannel channel, FileFormat fileFormat, boolean readOnly) throws IOException { super(file, channel, true, false, fileFormat, null, null, null, readOnly); _resolver = resolver; _customFile = customFile; } @Override protected TableImpl getTable(String name, boolean includeSystemTables) throws IOException { TableImpl table = super.getTable(name, includeSystemTables); if((table == null) && _resolver.loadCustomTable(this, _customFile, name)) { table = super.getTable(name, includeSystemTables); } return table; } @Override public void close() throws IOException { try { super.close(); } finally { deleteDbFile(getPath()); closeCustomFile(_customFile); } } static FileChannel initDbChannel(FileChannel channel, FileFormat format) throws IOException { FileFormatDetails details = getFileFormatDetails(format); transferDbFrom(channel, getResourceAsStream(details.getEmptyFilePath())); return channel; } } }