r70927 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70926‎ | r70927 | r70928 >
Date:02:45, 12 August 2010
Author:mah
Status:deferred
Tags:
Comment:
Think I've got a way to notify IRC now for broken builds… will test
Modified paths:
  • /trunk/test-server/README (modified) (history)
  • /trunk/test-server/cc-home/config.xml (modified) (history)
  • /trunk/test-server/cc-home/projects/mw/build.properties (modified) (history)
  • /trunk/test-server/cc-home/projects/mw/build.xml (modified) (history)
  • /trunk/test-server/cc-home/projects/mw/irc-publisher.xsl (added) (history)
  • /trunk/test-server/cc-home/projects/mw/userinfo-to-xml.php (added) (history)

Diff [purge]

Index: trunk/test-server/cc-home/config.xml
@@ -24,7 +24,8 @@
2525 </log>
2626 <publishers>
2727 <antpublisher anthome="apache-ant-1.7.0"
28 - buildfile="projects/${project.name}/irc-publisher.xml"/>
 28+ buildfile="projects/${project.name}/build.xml"
 29+ target="irc-publish"/>
2930 <artifactspublisher dir="projects/${project.name}/build/api"
3031 dest="artifacts/${project.name}" subdirectory="api"/>
3132 <artifactspublisher dir="projects/${project.name}/build/coverage"
Index: trunk/test-server/cc-home/projects/mw/build.properties
@@ -1,5 +1,10 @@
22 builddir=${basedir}/build
33 sourcedir=${basedir}/source
 4+apache.root=/var/www/irc
45
56 # This is the part of the source checkout we're going to do things like PHPDoc, etc
67 sourcepart=includes/api
 8+
 9+javax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl
 10+
 11+
Index: trunk/test-server/cc-home/projects/mw/irc-publisher.xsl
@@ -0,0 +1,51 @@
 2+<?xml version="1.0" encoding="UTF-8"?>
 3+<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 4+ xmlns:c="http://exslt.org/common"
 5+ xmlns:fn="http://www.w3.org/2005/xpath-functions"
 6+ xmlns:set="http://exslt.org/sets">
 7+ <xsl:param name="userinfo"/>
 8+
 9+ <xsl:output
 10+ method="text"
 11+ encoding="UTF-8" />
 12+
 13+ <xsl:template match="/cruisecontrol/build[@error]">
 14+Something broke: <xsl:value-of select="string(@error)"/>
 15+ <xsl:call-template name="get-last-modified"/>
 16+ </xsl:template>
 17+
 18+ <xsl:template name="get-last-modified"><xsl:text>
 19+Possible culprits: </xsl:text>
 20+ <xsl:for-each select="set:distinct(c:node-set(
 21+ /cruisecontrol/modifications/modification/user |
 22+ /cruisecontrol/modifications/modification/revision))">
 23+ <xsl:if test="name() = 'user'">
 24+ <xsl:call-template name="irc-nick-lookup">
 25+ <xsl:with-param name="id">
 26+ <xsl:value-of select="."/>
 27+ </xsl:with-param>
 28+ </xsl:call-template>
 29+ </xsl:if>
 30+ <xsl:if test="name() = 'revision'">/r<xsl:value-of select="."/>
 31+ <xsl:text> </xsl:text>
 32+ </xsl:if>
 33+ </xsl:for-each>
 34+ </xsl:template>
 35+
 36+ <xsl:template name="irc-nick-lookup">
 37+ <xsl:param name="id"/>
 38+ <xsl:variable name="nick"
 39+ select="document($userinfo)/userinfo/committer[@id=$id]/irc"/>
 40+ <xsl:choose>
 41+ <xsl:when test="$nick">
 42+ <xsl:value-of select="$nick"/>
 43+ </xsl:when>
 44+ <xsl:otherwise>
 45+ <xsl:value-of select="$id"/>
 46+ </xsl:otherwise>
 47+ </xsl:choose>
 48+ </xsl:template>
 49+
 50+ <xsl:template match="text()"/>
 51+
 52+</xsl:stylesheet>
\ No newline at end of file
Index: trunk/test-server/cc-home/projects/mw/build.xml
@@ -135,4 +135,29 @@
136136 </exec>
137137 </target>
138138
 139+ <available file="${builddir}/data/userinfo" property="userinfo.exists"/>
 140+ <target name="userinfo" unless="userinfo.exists">
 141+ <exec executable="svn">
 142+ <arg line="checkout http://svn.wikimedia.org/svnroot/mediawiki/USERINFO ${builddir}/data/userinfo"/>
 143+ </exec>
 144+ </target>
 145+
 146+ <target name="userinfo-up" depends="userinfo">
 147+ <exec executable="svn" dir="${builddir}/data/userinfo">
 148+ <arg line="up"/>
 149+ </exec>
 150+ <exec executable="php" dir="${builddir}/data/userinfo" output="${builddir}/data/userinfo.xml">
 151+ <arg line="${basedir}/userinfo-to-xml.php ${builddir}/data/userinfo"/>
 152+ </exec>
 153+ </target>
 154+
 155+ <target name="irc-publish" unless="${thisbuildsuccessful}" depends="userinfo-up">
 156+ <!-- $logfile is the file -->
 157+
 158+ <xslt in="${logfile}" out="${apache.root}/irc-publish.txt"
 159+ style="${basedir}/irc-publisher.xsl">
 160+ <param name="userinfo" expression="file://${builddir}/data/userinfo.xml"/>
 161+ </xslt>
 162+ </target>
 163+
139164 </project>
\ No newline at end of file
Index: trunk/test-server/cc-home/projects/mw/userinfo-to-xml.php
@@ -0,0 +1,50 @@
 2+#!/usr/bin/php
 3+<?php
 4+
 5+if(php_sapi_name() !== "cli") {
 6+ echo "You need to run this from the command line.\n";
 7+ exit;
 8+}
 9+
 10+if( !isset( $argv[1] ) ) {
 11+ echo "Please pass a directory.\n";
 12+ exit;
 13+}
 14+
 15+$dir=$argv[1];
 16+
 17+if( !is_dir( $dir ) ) {
 18+ echo "Directory ($dir) doesn't exit.\n";
 19+ exit;
 20+}
 21+
 22+$doc = new SimpleXMLElement("<userinfo/>");
 23+$iter = new DirectoryIterator( $dir );
 24+
 25+foreach( $iter as $file ) {
 26+ if( $file->isDir() ) continue;
 27+ $commitId = $file->getFilename();
 28+
 29+ $text = file_get_contents( $file->getPathname() );
 30+ if( $text === false ) {
 31+ continue;
 32+ }
 33+
 34+ $committer = $doc->addChild( "committer" );
 35+ $committer->addAttribute( "id", $commitId );
 36+
 37+ $rows = preg_split( "#\n#m", $text );
 38+ foreach( $rows as $line ) {
 39+ $bit =
 40+ preg_split( "#[[:space:]]*:[[:space:]]*#", $line, 2 );
 41+
 42+ if( !isset( $bit[1] ) ) continue;
 43+
 44+ $name = preg_replace( "#[_ ]#", "-", strtolower( trim( $bit[0] ) ) );
 45+
 46+ $committer->addChild( $name, trim( $bit[1] ) );
 47+ }
 48+}
 49+
 50+echo $doc->asXML();
 51+echo "\n";
Property changes on: trunk/test-server/cc-home/projects/mw/userinfo-to-xml.php
___________________________________________________________________
Added: svn:eol-syle
152 + native
Index: trunk/test-server/README
@@ -9,8 +9,12 @@
1010 the contents of the cc-home directory (e.g. config.xml,
1111 cruisecontrol.sh, etc) should be copied to your cruisecontrol installation.
1212
13 -Finally, add the cruisecontrol user:
 13+You'll also want to install the Saxon-B XSLT parser:
1414
 15+ aptitude install libsaxonb-java
 16+
 17+Add the cruisecontrol user:
 18+
1519 useradd ci
1620
1721 and put cruisecontrol-init.d in /etc/init.d/cruisecontrol:

Status & tagging log