February 10, 2009

Cruise controlling Adobe Flex/AIR development using Tamarin

In the last few years I have been involved in several software development projects. Some projects in pure Java, Some projects in Pure Adobe Flex, and a few mixtures of these flavors.

I am also a big proponent of continuous integration. An awesome tool for that is Cruise Control. I have used Cruise Control in one of the above projects, and that made life in that project so much easier. It takes some effort (a few days) to setup and fine tune Cruise Control, but once you have done that, you gain the following enormous advantages:

  • immediate feedback on broken builds,
  • always up-to-date API documentation,
  • immediate feedback on code quality.
Cruise Control basically works like this: It monitors the state of your project's source code repository (CVS, Subversion, ...). If anything changes in that repository, it gets an update from the repository, and rebuilds your project. Depending on what you specify in your build script, this could be anything a developer could do from his work station. Usually, the following artifacts are produced by a full project build:
  • Deployable/installable binaries of the target system's components,
  • Unit test reports,
  • Code metrics reports,
  • API documentation.
In the Java/C++/C#/.Net communities, doing continuous integration is already pretty much a default project practice. Been there, done that and bought the T-shirt! Now I come to think of it: setting up continuous integration probably moves you well into level 3 on the CMMI scale (but don't quote me on this, because I haven't verified that).

In the Flash/Flex/AIR community, continuous integration is probably very rarely used. I have often thought about setting up Cruise Control for a Flex development project, but I always got stuck at the following inabilities:
  • can't produce unit test reports,
  • can't produce code metric reports.
For automatically running your unit test cases, you need to be able to run actionscript bytecode in "console mode" (i.e., no GUI). The unit tests would produce success/failure reports in a format (usually XML) that Cruise Control later combines into a single XML stream and transform it to a neat human readable HTML report by running it through an XSLT script. In spite of the grandness of the Flex SDK and Flex Builder, the Flash Player doesn't have a console mode.

And as far as I can see, there is no decent (or even half-way decent) code metrics and quality analyzer (such as PMD and Checkstyle for Java) for Actionscript. And again, these analysers should be able to run in "console mode" and produce a report that can be processed by Cruise Control.

But, today, I have seen the light! And it comes from the Tamarin project. Tamarin is an open source ECMAScript Virtual Machine, contributed by Adobe to the Mozilla fondation. I found this rather dated but still very useful blogpost by Zwetan Kjukov explaining how to build the Tamarin VM. Following the instructions on that blog, you would obtain an executable binary named avmplus, which you can use to run Actionscript bytcode in console mode!

Now, I haven't tried to reproduce the steps in Zwetan Kjukov's article, but I intend to whenever I find the time and oportunity to do that. And the results from that will be nice material again for a blog post.

On the Tamarin pages, I also found these instructions on how to build the latest stable release of Tamarin.

Has any of you already experimented with continuous integration in Flex/AIR projects? Please share your experiences!

No comments: