提交 e1fab646 authored 作者: Thomas Mueller's avatar Thomas Mueller

Automated build

上级 39e71307
......@@ -111,20 +111,6 @@ public class Build extends BuildBase {
"org.h2.test.TestAll" });
}
/**
* Upload the Emma code coverage results to the web site.
*/
public void coverageUpload() {
String password = System.getProperty("h2.ftpPassword");
if (password == null) {
throw new Error("h2.ftpPassword not set");
}
String cp = "temp" + File.pathSeparator + "bin";
exec("java", new String[] { "-Xmx128m", "-cp", cp,
"-Dh2.ftpPassword=" + password,
"org.h2.build.doc.UploadCoverage" });
}
/**
* Switch the source code to the current JDK.
*/
......@@ -557,6 +543,22 @@ public class Build extends BuildBase {
}
}
/**
* This build target is used for the automated build. It copies the result
* of the automated build (including test results, newsfeed, code coverage)
* to the public web site.
*/
public void uploadBuild() {
String password = System.getProperty("h2.ftpPassword");
if (password == null) {
throw new Error("h2.ftpPassword not set");
}
String cp = "bin" + File.pathSeparator + "temp";
exec("java", new String[] { "-Xmx128m", "-cp", cp,
"-Dh2.ftpPassword=" + password,
"org.h2.build.doc.UploadBuild" });
}
/**
* Build the h2console.war file.
*/
......
package org.h2.build.doc;
/*
* Copyright 2004-2009 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.build.doc;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.StringReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.util.zip.CRC32;
import java.util.zip.Deflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import org.h2.dev.ftp.FtpClient;
import org.h2.test.utils.OutputCatcher;
import org.h2.tools.RunScript;
import org.h2.util.FileUtils;
import org.h2.util.IOUtils;
import org.h2.util.StringUtils;
......@@ -22,7 +33,7 @@ import org.h2.util.StringUtils;
/**
* Upload the code coverage result to the H2 web site.
*/
public class UploadCoverage {
public class UploadBuild {
/**
* This method is called when executing this application from the command
......@@ -55,19 +66,54 @@ public class UploadCoverage {
FileUtils.delete("details/coverage_files.zip");
FileUtils.delete("details");
String password = System.getProperty("h2.ftpPassword");
if (password != null) {
FtpClient ftp = FtpClient.open("h2database.com");
ftp.login("h2database", password);
ftp.changeWorkingDirectory("/httpdocs");
if (ftp.exists("/httpdocs", "coverage")) {
ftp.removeDirectoryRecursive("/httpdocs/coverage");
}
ftp.makeDirectory("/httpdocs/coverage");
ftp.store("/httpdocs/coverage/overview.html", new FileInputStream("coverage/overview.html"));
ftp.store("/httpdocs/coverage/coverage.zip", new FileInputStream("coverage.zip"));
ftp.close();
FileUtils.delete("coverage.zip");
if (password == null) {
return;
}
FtpClient ftp = FtpClient.open("h2database.com");
ftp.login("h2database", password);
ftp.changeWorkingDirectory("/httpdocs");
if (ftp.exists("/httpdocs", "coverage")) {
ftp.removeDirectoryRecursive("/httpdocs/coverage");
}
ftp.makeDirectory("/httpdocs/coverage");
String testOutput = IOUtils.readStringAndClose(new FileReader("docs/html/testOutput.html"), -1);
boolean error = testOutput.indexOf(OutputCatcher.START_ERROR) >= 0;
if (!ftp.exists("/httpdocs", "automated")) {
ftp.makeDirectory("/httpdocs/automated");
}
String buildSql;
if (ftp.exists("/httpdocs/automated", "history.sql")) {
buildSql = new String(ftp.retrieve("/httpdocs/automated/history.sql"));
} else {
buildSql = "create table item(id identity, title varchar, issued timestamp, desc varchar);\n";
}
String ts = new java.sql.Timestamp(System.currentTimeMillis()).toString();
String now = ts.substring(0, 16);
String sql = "insert into item(title, issued, desc) values('Build " + now + (error ? " FAILED" : "") +
"', '" + ts + "', '<a href=\"http://www.h2database.com/html/testOutput.html\">Output</a>" +
" - <a href=\"http://www.h2database.com/coverage/overview.html\">Coverage</a>');\n";
buildSql += sql;
Class.forName("org.h2.Driver");
Connection conn = DriverManager.getConnection("jdbc:h2:mem:");
RunScript.execute(conn, new StringReader(buildSql));
InputStream in = UploadBuild.class.getResourceAsStream("buildNewsfeed.sql");
ResultSet rs = RunScript.execute(conn, new InputStreamReader(in, "ISO-8859-1"));
in.close();
rs.next();
String content = rs.getString("content");
conn.close();
ftp.store("/httpdocs/automated/history.sql", new ByteArrayInputStream(buildSql.getBytes()));
ftp.store("/httpdocs/automated/newsfeed.xml", new ByteArrayInputStream(content.getBytes()));
ftp.store("/httpdocs/html/testOutput.html", new ByteArrayInputStream(testOutput.getBytes()));
ftp.store("/httpdocs/coverage/overview.html", new FileInputStream("coverage/overview.html"));
ftp.store("/httpdocs/coverage/coverage.zip", new FileInputStream("coverage.zip"));
ftp.close();
FileUtils.delete("coverage.zip");
}
private static void zip(String destFile, String directory, boolean storeOnly) throws IOException {
......
/*
* Copyright 2004-2009 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
CREATE TABLE CHANNEL(TITLE VARCHAR, LINK VARCHAR, DESC VARCHAR,
LANGUAGE VARCHAR, PUB TIMESTAMP, LAST TIMESTAMP, AUTHOR VARCHAR);
INSERT INTO CHANNEL VALUES('H2 Database Automated Build' ,
'http://www.h2database.com/html/build.html#automated', 'H2 Database Automated Build', 'en-us', NOW(), NOW(), 'Thomas Mueller');
SELECT XMLSTARTDOC() ||
XMLNODE('feed', XMLATTR('version', '0.3') || XMLATTR('xmlns', 'http://purl.org/atom/ns#') || XMLATTR('xml:lang', C.LANGUAGE),
XMLNODE('title', XMLATTR('type', 'text/plain') || XMLATTR('mode', 'escaped'), C.TITLE) ||
XMLNODE('author', NULL, XMLNODE('name', NULL, C.AUTHOR)) ||
XMLNODE('link', XMLATTR('rel', 'alternate') || XMLATTR('type', 'text/html') || XMLATTR('href', C.LINK), NULL) ||
XMLNODE('modified', NULL, FORMATDATETIME(C.LAST, 'yyyy-MM-dd''T''HH:mm:ss.SSS', 'en', 'GMT')) ||
GROUP_CONCAT(
XMLNODE('entry', NULL,
XMLNODE('title', XMLATTR('type', 'text/plain') || XMLATTR('mode', 'escaped'), I.TITLE) ||
XMLNODE('link', XMLATTR('rel', 'alternate') || XMLATTR('type', 'text/html') || XMLATTR('href', C.LINK), NULL) ||
XMLNODE('id', NULL, XMLTEXT(C.LINK || '/' || I.ID)) ||
XMLNODE('issued', NULL, FORMATDATETIME(I.ISSUED, 'yyyy-MM-dd''T''HH:mm:ss.SSS', 'en', 'GMT')) ||
XMLNODE('modified', NULL, FORMATDATETIME(I.ISSUED, 'yyyy-MM-dd''T''HH:mm:ss.SSS', 'en', 'GMT')) ||
XMLNODE('content', XMLATTR('type', 'text/html') || XMLATTR('mode', 'escaped'), XMLCDATA(I.DESC))
)
ORDER BY I.ID DESC SEPARATOR '')
) CONTENT
FROM CHANNEL C, ITEM I;
\ No newline at end of file
......@@ -587,4 +587,4 @@ consistently springfuse grep signatures wrote symbolic parents caches readers
animate scaladoc models disadvantages vladykin sergi trims requesting
handing bonita placed euros embeds reliability singular unregister quotas
overall httpdocs tigris eclemma separates underscore yajsw she her truncating
relocating smtps smtp osde joist
\ No newline at end of file
relocating smtps smtp osde joist catching
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论