Continuous Integration with Flex - a better log parser

June 13, 2007

About a year ago, I posted a six part series explaining how to set up a continuous integration process for your Flex projects. Since then I have been refining the process when I have had a spare moment. One of the hassles I found when trying to setup CI on a new machine was getting the python based flash log parser working. I decided to remove the python dependency altogether and create a jar that parses the flash logs.

So, grab the jar from here and unzip it to your externals/lib directory. Then add the following properties to your build:


<property name="logParser" value="${lib}/FlashLogParser.jar"/>
<property name="flashStatus.location" value="${logs}/status.txt"/>
<property name="flashOutput.location" value="${logs}/TEST-testOutput.xml"/>

Then, change your parseFlashLog target to look like this:

<target name="parseFlashLog" description="parses flash log" depends="clean" >
<java jar="${logParser}" failonerror="true" fork="true">
<arg line="'${flashlog.location}'"/>
<arg line="'${flashStatus.location}'"/>
<arg line="'${flashOutput.location}'"/>
</java>
</target>

Now you should be good to go...
In my next post I am going to do a full dissection of my latest build file - I have spent some time refining it over the last year, and I think its probably helpful to spend some time looking at it bit by bit...

CruiseControl on the Mac - modifying the build script to work x-platform

June 12, 2007

So, I thought I was doing pretty well, getting svn working on the mac, installing cruisecontrol, even getting SCPlugin working with unsigned certificates. Then I tried to run my ant build, and ended up having all sorts of problems getting my mac debug player to run. Some investigating and help from the ANT folks later, and I have a solution

So, when I ran my ant build, all went well until the runTest target executed (or at least tried to execute). I got the following build error:

Execute failed: java.io.IOException: debugPlayerMac.app cannot execute

You see the problem is that on a mac, the standalone player (like other applications on the Mac) is actually a folder containing all sorts of cleverness inside. Ant doesn't know how to execute a folder, so I was a bit stuck. Until, after lots of digging, I found the answer in an old osflash mailing list archive. Basically I have to use the 'open' command to launch the app - something like this:


<exec executable="open">
<arg line="${pathToFlashPlayer}"/>
<arg line="${pathToSWFToPlay}"/>
</exec>


I tried this, and it worked nicely. The problem is that my ant build needs to wait until the test harness runs and closes the player before reading the log and parsing the results. In the ant script above, the open command only stalls the ant script until it has finished doing its opening magic, so ant gets upset as the test results haven't been written yet. I slept on this, then couldn't think of an answer so I sent an email to the ant users mailing list. Mere minutes later I got a reply that helped me work out how to crack this.
Basically, ant has the ability to run two threads, and move on when they are both complete. So in one thread we launch the player, and in another thread we first wait for the file to be available, then we do a check to see if it contains what we want (I am testing against the flag -----------------TESTRUNNEROUTPUTENDS---------------- which I used in my result printer). It worked like a charm:

<target name="runTest" description="runs the test harness" depends="compileTest">
<parallel>
<exec executable="open" spawn="no">
<arg line="${debugPlayer}" />
<arg line="'${testHarness.swf}'"/>
</exec>
<sequential>
<waitfor>
<available file="${flashlog.location}"/>
</waitfor>
<waitfor>
<isfileselected file="${flashlog.location}">
<contains text="-----------------TESTRUNNEROUTPUTENDS----------------"/>
</isfileselected>
</waitfor>
</sequential>
</parallel>
</target>


The last step to making this properly cross platform was to have the right <exec> command called depending on the OS. Fortunatly there is an os attribute you can specify on <exec> and the task will only run if the os matches the platform you are running the task on. A few minutes later, I had my amended runTest target:
<target name="runTest" description="runs the test harness" depends="compileTest">
<parallel>
<exec executable="${debugPlayerWin}" spawn="no" os="Windows XP">
<arg line="'${testHarness.swf}'"/>
</exec>
<exec executable="open" spawn="no" os="Mac OS X">
<arg line="${debugPlayerMac}" />
<arg line="'${testHarness.swf}'"/>
</exec>
<sequential>
<waitfor>
<available file="${flashlog.location}"/>
</waitfor>
<waitfor>
<isfileselected file="${flashlog.location}">
<contains text="-----------------TESTRUNNEROUTPUTENDS----------------"/>
</isfileselected>
</waitfor>
</sequential>
</parallel>
</target>

I'm planning to post my completed project build script and step through it in more detail than I did previously. I've updated it quite a lot in the last year, and so far, I think its a lot neater. Before I do that, I'm going to post about my removing the python dependency from my CI process.

Restarting cruisecontrol on Mac OSX

June 11, 2007

OK, so for those of you who know Unix better than me (which is probably most of you) this post will be like teaching your granny to suck eggs, but for the rest of us, it took me some working out how to stop and start the cruisecontrol server instance on the mac...

You see, on windows, I just press ctrl+c and the process terminates so you can then restart the sever. Well, on the mac, that doesn't happen; if you ctrl+c, the server instance still runs. So, thanks to some friendly assistance, I found out how to kill the server. What you need to do first is type ps -e. This will list all the processes running. The one you are looking for will look something like this:
3267 p2 S 0.15.38 /System/Library/Frameworks/JavaVM.framework/Home/bin/java -Djavax.management.build.
When you have that, note the PID, and then type kill -9 XXXX where XXXX is the pid you found in the previous step.

CruiseControl on Mac OSX

June 08, 2007

So, I've got this shiny new mac provided by my new employers, and so I figured I'd put it to use as a CruiseControl build manager. I found the process reasonably simple but, just like the process of setting up Subversion and SCPlugin, there are a couple of extra steps I figured I'd share...

First step, download the latest source from the downloads page here. Simply expand that to where you want your CruiseControl instance to live. Next open up a terminal window, and type the following:
cruisecontrol.sh
More than likely, you will get the following error message:
-bash: cruisecontrol.sh: command not found
More hunting on the mighty intergoogle and a quick look at 'bash guide for beginners' told me the answer - I need to tell bash which shell to use to execute the cruisecontrol.sh script. I found either of the following lines worked:
sh cruisecontrol.sh
bash -x cruisecontrol.sh

I'm not a Unix geek, so I don't pretend to know what the difference is, or which is preferable - if anyone can tell me I'd love to know..

Subversion and Finder integration for the Mac

June 08, 2007

I just had to sort out getting subversion up and running on a mac. It's not quite as simple a process as on a PC; there are a couple of extra steps I thought I'd share...

So, the first step is to make sure you're logged in with admin rights, then go and grab the latest copy of subversion from here

When you have downloaded this, run it and let it do its magic, and you should have subversion installed. To confirm, open a terminal window (Applications/Utilities/Terminal) and type svn. At this stage, its entirely likely you get a 'command not found' error. So after ab bit of digging on the intergoogle I found that someone had the same problem and fixed it by typing the following into the terminal:
sudo ln -s /usr/local/bin/svn /usr/bin/svn
This adds a link from the svn binary in your local bin folder to /usr/bin

Type in svn and you should now see the more helpful message Type 'svn help' for usage.. So far so good, you can now use svn on the command line. But if you're anything like me, I want my source control to be seamless and have finder integration. Enter SCPlugin.

SCPlugin is an open source plugin based on the idea of TortoiseSVN. Its not quite as mature as TortoiseSVN, but I've found it to be pretty good, barring one gotcha I'll deal with in a minute. For now, download the latest version, and look at the installation instructions. Now when I pull up a contextual menu, I should see a subversion submenu. It doesn't have all subversion commands, but it certainly has the ones I use day to day.

I thought I was doing pretty well, until I tried to checkout the latest source from one of my projects. I got a nasty error:

Error: PROPFIND request failed on '/path/to/SVN'
Error: PROPFIND '/path/to/SVN': could not connect to server (https://sample.svnserver.domain)

more hunting on the intergoogle uncovered a similar problem with Tortoise, so I figured it might be the same thing. Basically my svn repository under https has a self-signed certificate, and SCPlugin just spits the dummy when it comes across this. I went back to my Terminal window and tried to checkout from there:

svn co http://path/to/repos/ 

Sure enough, a message came up telling me that the certificate was unsigned (because my friend self-signed it):


Error validating server certificate for 'https://xxxxx':
- The certificate is not issued by a trusted authority. Use the
fingerprint to validate the certificate manually!
- The certificate hostname does not match.
Certificate information:
- Hostname: eyefodder.com
- Valid: from Jul 22 15:51:42 2004 GMT until Jul 5 15:51:42 2015 GMT
- Issuer: Eyefodder, uk
- Fingerprint: d9:86:9c:31:2a:xx:d2:xx:20:08:f6:78:a6:0f:46:27:a4:52:d1:7b
(R)eject, accept (t)emporarily or accept (p)ermanently?

but in the command line I had the option to accept the certificate permanently (p). I did this, and now when I go back to the SCPlugin contextual, everything works as it should..

Next step - cruisecontrol on the Mac...

« August 2006 | Main | August 2007 »

Syndicate

Add to Technorati Favorites Powered by
Movable Type 3.2

Holiday Fund