FlexUnit and Continuous Integration Updates

Brian LeGros | January 19th, 2010 | programming  

This past weekend, I finished my port of the Hudson Xvnc plugin to the FlexUnit Ant task. I’m hoping this will help those who don’t have access to the plugin, or dont’ use Hudson, but want to execute headless builds using FlexUnit and Xvnc. In addition to this work, I’ve added a few wiki pages to the newly launched FlexUnit.org’s wiki instance. A break down of the all the features available in the FlexUnit Ant task can be found @ http://docs.flexunit.org/index.php?title=Ant_Task. Additionally, to see the Ant task in action in a few variations, check out the FlexUnit4SampleCIProject on Github; I also show a basic POM using Flexmojos and FlexUnit4. For a general culmination of FlexUnit and continuous integration experience for running headless builds, check out http://docs.flexunit.org/index.php?title=Continuous_Integration_Support. Hopefully this information can help to prevent some people from experiencing the painstaking lessons I had to go through.

Next I’m off to update the FlexUnit 4 CI builds to work with versioning as well as integrate the new FlexPMD (CPD, Metrics) to get some more sexy Hudson reporting going on. If you’re interested in seeing the latest rendition of our CI process, check out http://flexunit.digitalprimates.net.

FlexUnit 4 Beta 2 Released

Brian LeGros | August 24th, 2009 | news  

Today the 2nd beta release of FlexUnit4 was published. This release comes with a large list of bug fixes and improvements. This past weekend I burned the midnight oil with Mike and we buttoned up the FlexUnit4AntTasks project and I threw together a new sample project for FlexUnit4 showing how to integrate with Ant and Maven (via the Flex-Mojos plugin). Currently xvfb support isn’t available but we hope to add it in the next beta along with a few bug fixes and refactorings that we have time to finish. If you’re running your CI server on Windows using the Local System account, you should be able to take advantage of the new FlexUnit Ant task; the MacOS X and Linux crowd will have to work with source for now.

If your interested in more details, check out Mike’s latest blog post on the Beta 2 release.

Fluint 1.1.1 ready to be released

Brian LeGros | April 29th, 2009 | programming  

After a busy couple of months, I’ve finally gotten off of my ass and decided to do the integration for Fluint 1.1.1 and created the new branch for Fluint 1.2. We’re in the process of getting the artifacts into Google Code, but the release tag is in Subversion now for those who are interested. In this release we had a couple small fixes:

  • Issue #34 – Assets are not located in net/digitalprimates/fluint folder
  • Issue #35 – Can’t find TestResponder
  • Issue #37 – Air Test Runner needs better error handling
  • Added new target to ant build for building the airtestrunner as an .airi file (target => “airtestrunner-intermediary”)
  • Added flex builder metadata files to the samples project

I’ve already added my stubs for HTTPService and RemoteObject to the 1.2 branch for those who want to play around with them. Matt Hughes’ sequence improvements will also be included in 1.2 once I figure out where they ended up. For 1.2 I’m hoping to add some documentation for the wiki to address some really early issues as well as #28. In terms of bug fixes and new features, I’m hoping to tackle issues 32, 38, 41, 42, 44, 45, and 46 (#44 being the highest priority).

With a new baby coming in May, I’m unsure of my schedule, but I’m gonna do my best to get what I can ready (=who knows). In the mean time, kick the tires for us and let us know if there are any issues with 1.1.1.

Code and slides finally posted from FlexCamp Miami

Brian LeGros | March 29th, 2009 | conferences  

Sorry to everyone who’s been asking about a copy of my presentation from FlexCamp Miami. I’ve just posted the source and slides for my presentation @ http://svn.adogo.us/200903-FlexCampMiami/ along with Max, who had his stuff up pretty quickly after the conference. I wanted to take some time to add a better example of an integration test which is now available in the RestaurantGrid component project. What delayed me was finding an easy way to explain how to test the DataGrid embedded within the RestaurantGrid; I tried to provide the most basic of examples with and without the help of the Flex Automation API.

Hope this helps those who were interested; sorry again about the delay. If you have any questions, please don’t hesitate to contact me via comments or email me @ me at brianlegros dot com. Also, if you find yourself in the Orlando area, always feel free to drop by an Adogo meeting. This month we’ve got a great JavaScript topic being presented by Adam as well as Max giving his FlexCamp Miami presentation with, if we’re lucky, working AOP in AS3 via Loom! Check out the Adogo blog for more information on time and location. Hope you can make it!

Fluint 1.1.0 Released!

Brian LeGros | February 12th, 2009 | programming  

Over the last few months, I’ve been working with Michael Labriola on the next minor version release of Fluint. Well, this evening Michael and I put the finishing touches on release 1.1.0. This release brought all of the changes I made to get Fluint working at the office for our CI process to the community. There are a couple of cool little gems that I think will be helpful for some:

  • Separation of failures and errors in test reporting (visual and XML).
  • XML compliant output with most CI servers as well as the JUnitReport task in Ant and the Surefire Reporting plugin in Maven.
  • Support in the Ant task for truly headless executions of the AIR Test Runner via xvfb-run.
  • Support for relative paths in the Ant task and AIR Test Runner.
  • Better error handling for non-compliant modules loaded into the AIR Test Runner.
  • LogBook integration for debugging
  • A big folder re-organization and Ant scripts to support developers when they need specialty builds.
  • Agreed upon a branching and tagging strategy so the community can have stable snapshots of source to build.

We probably should put together a ChangeLog wiki page, so that may be available soon. We did a few updates to the wiki, so stop by the Google Code site and check out the changes. Also, provide feedback on the discussion list, if there are features you’d like to see implemented, bugs that you find, or just general questions you need help with. People are great about helping on the list, so don’t feel discouraged.

This is my first major release of an OSS project that I’ve had code go into, so thanks to everyone who helped with the release, especially my wife for putting up with a lot of late nights. There is a lot more to come with Fluint over the next year that is going to be really exciting. Look for announcements during my presentation at FlexCamp Miami and on the discussion mailing list. Hope you enjoy the new release!

Thanks for the invitation KSC

Brian LeGros | January 17th, 2009 | programming  

Big thanks to Doug, Bill, Jim, Mike, Don, Boss boss, and everyone else who joined me for my presentation on Continuous Integration and Flex at Kennedy Space Center. I ended up running around an hour and forty minutes giving an overview of the Adobe Flex domain and continuous integration as a whole. Thank you everyone for taking the time out of your busy schedules to tough through the presentation; I hope I have failed you all equally.

As promised, below are links to the materials from the presentation that I used as well as links to other resources you may find helpful.

Subversion – http://subversion.tigris.org/
Apache Ant – http://ant.apache.org/
Flex Ant Tasks – Use the libraries included in the Flex SDK 3.2 distribution
Fluint Library and Ant Tasks – http://code.google.com/p/fluint/
mock-as3 – http://code.google.com/p/mock-as3/
Hudson – https://hudson.dev.java.net/
Example Application and Component – http://brianlegros.com/blog/files/example_apps.zip
Slides – http://brianlegros.com/blog/files/slides.pdf

If you have any questions, please don’t hesitate email @ me at brianlegros dot com.

NOTE: The Fluint test runners and reports that you saw in my presentation were using a code base that has yet to be released by the Fluint team, but will be hopefully soon. We have a lot of great working going on at the Fluint project, so I’d encourage you all to check out the Google Code site as well as the Fluint mailing list.

Getting AIR to run headless for Continuous Integration

Brian LeGros | January 7th, 2009 | programming  

Here’s the thing about proof-of-concept projects, they always get the high risk technology questions out of the way, but they never manage to expose the stupid gotchas that are coming down the line when you go to make them into a reality. Case in point, unit testing in Flex and continuous integration. In my last post, I spoke about how I got flex-mojos, ant, fluint, and Hudson all playing nice together. Please preface the following with the fact that I’m a terrible server admin, so there may be work arounds for the roadblocks I ran into, I’m just not aware of them.

So when our team went to deploy the PoC, we decided to use Windows. Our hope was that with the lack of headless support in AIR, Windows would provide us access to a windowing system even when a user isn’t authenticated thanks to the dreaded LocalSystem account. As expected, I was able to get Hudson up and running and the AIR test runner was working without issue while running as LocalSystem. I then needed to integrate a series of CI builds which we put together to automatically release our components. All of sudden, I had the need for user specific settings to interact with putty, plink, and SVN, then LocalSystem failed me. I setup a special user to run the service hosting Hudson and placed that user into the Administrator group to start; I figured once I had it working again, I’d restrict its rights … <crickets chirping>. So when I had finally gotten the automatic release builds working with the new user, I re-ran one of my previous CI builds only to find that the build would hang when the AIR runner for Fluint was executed. After hours of pouring over a solution (I even tried this registry hack for the service with no success), I decided that Windows just wasn’t going to work.

I decided to give Linux a shot and I have to say I had much better results; I chose Ubuntu for my PoC due to its simplicity for guys like me. As a nice plus, all of the SSH/SVN woes I experienced disappeared because I had a native SSH client and integration was just easy. I still had the issue however of needing to run AIR in a truly headless mode. I started with some tips I found on the Fluint mailing list and was able to get Xvfb up and running as a service. Integration with the Fluint Ant Task didn’t pan out easily though, so I again looked for another solution. I did some digging and as it turns out a lot of the Java/Swing folks had to solve the same problems we’re having to solve now before Java gained the ability to run Swing apps headlessly. I found this post on xvfb-run and it did the trick. In fact it worked out so well, that I went ahead and integrated it into the Fluint Ant task as an option. Effectively I just had it execute the AIR application with the “-a” flag so sysadmins who are picky about how xvfb-run is used may not like the lack of granularity I’ve built in, but it’s working for us. I know that FlexUnit has a similar issue since the Flash Player can’t be run in a headless-mode either, so this may be a good feature to add to the FlexUnit Ant task eventually too. On a side note, my changes to Fluint are being reviewed right now and it looks like I may get my branch merged into the next release fairly soon for anyone who is interested in finding binaries.

We’re still working to deploy on a different Linux distro at the moment, but I think we’ve finally managed to mitigate the risk of running a Flex build on a CI server for the different variations we’ve thrown together. If you see another post from me really soon, you’ll know the edge of the PoC sword got me again … stupid sneaky sword.

Continuous Integration with Maven, Flex, Fliunt, and Hudson

Brian LeGros | December 17th, 2008 | programming  

Recently I was tasked with streamlining our build process at work so we could get a continuous integration (CI) server up and running. We use the common stack of technologies found in most Flex shops (basic SDK, some libraries, and Flex Builder) as well as Maven. I ran into some challenges getting our CI process to work as we wanted, so I figured I’d go through some of the gotchas I encountered.

On the build side of things, when I came on, Maven was already in place using flex-mojos. Now I’m a big fan of the simplicity that Ant brings to the mix, but the issue of dependency management being baked into Maven makes it extremely appealing; I do like Ivy as an alternative when using Ant, but I wasn’t going to re-write the company’s build process. So we had flex-mojos building our source and producing artifacts for deployment to our team’s Maven repository, but we needed to integrate our unit tests into our build. We were using dpuint and were excited to see that fluint had been released with Ant support. Currently flex-mojos doesn’t support Fluint, although my colleagues tell me they’re working on it, so I knew I was going to have to use Ant. To start I had to get flex-mojos building my test SWF so I could use the Fluint Ant task. The Ant support in Fluint requires that you produce a module SWF that will work with their test runner written in AIR. After an hour of messing with flex-mojos, I was unable to get the compile, or test-compile, goal to do what I wanted, so I decided to use the maven-ant-run plugin to compile our tests as well.

Below is the snippet I was able to get working to compile our tests and execute the Fluint test runner:

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
96
97
98
99
100
101
102
103
104
105
<properties>
   <flex.home>PATH_TO_FLEX_SDK_HOME</flex.home>
   <fluint.testrunner>PATH_TO_FLUINT_AIR_RUNNER_EXECUTABLE</fluint.testrunner>
</properties>
...
<build>
   <plugins>
      <plugin>
         <groupId>info.flex-mojos</groupId>
         <artifactId>flex-compiler-mojo</artifactId>
         <version>2.0M9</version>
         <extensions>true</extensions>
         <configuration>
            <skipTests>true</skipTests>
         </configuration>
      </plugin>
      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-antrun-plugin</artifactId>
         <executions>
            <execution>
               <id>fluint-test-compile</id>
               <phase>test-compile</phase>
               <configuration>
                  <tasks>
                     <!-- Pull in Flex Ant Tasks -->
                     <taskdef resource="flexTasks.tasks" />
 
                     <property name="FLEX_HOME" location="${flex.home}" />
 
                     <!-- Create test-classes directory -->
                     <mkdir dir="${project.build.testOutputDirectory}" />
 
                     <mxmlc file="${project.build.testSourceDirectory}/AirRunner.mxml" 
                        output="${project.build.testOutputDirectory}/AirRunner.swf" 
                        keep-generated-actionscript="false">
 
                        <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
                        <source-path path-element="${FLEX_HOME}/frameworks"  />
                        <compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
                           <include name="libs" />
                        </compiler.library-path>
                        <compiler.library-path dir="${project.build.directory}/.." append="true">
                           <include name="libs" />
                        </compiler.library-path>
                        <compiler.library-path dir="${project.build.directory}" append="true">
                           <include name="*.swc" />
                        </compiler.library-path>
                     </mxmlc>      
                  </tasks>
               </configuration>
               <goals>
                  <goal>run</goal>
               </goals>
            </execution>
            <execution>
               <id>fluint-test-run</id>
               <phase>test</phase>
               <configuration>
                  <tasks>
                     <!-- Pull in Fluint Ant Task -->
                     <taskdef name="fluint" classname="net.digitalprimates.ant.tasks.fluint.Fluint" />     
 
                     <property name="test.report.loc" location="${project.build.directory}/surefire-reports" />
 
                     <!-- Create reporting directory -->
                     <mkdir dir="${test.report.loc}" />
 
                     <fluint debug="true" 
                        headless="true"
                        testRunner="${fluint.testrunner}" 
                        outputDir="${test.report.loc}" 
                        workingDir="${project.build.testOutputDirectory}">
 
                        <fileset dir="${project.build.testOutputDirectory}">
                           <include name="**/AirRunner.swf"/>
                        </fileset>
                     </fluint>      
                  </tasks>
               </configuration>
               <goals>
                  <goal>run</goal>
               </goals>
            </execution>
         </executions>
         <dependencies>
            <dependency>
               <groupId>org.apache.ant</groupId>
               <artifactId>ant</artifactId>
               <version>1.7.0</version>
            </dependency>
            <dependency>
               <groupId>flex.ant</groupId>
               <artifactId>flexTasks</artifactId>
               <version>1.0.0</version>
            </dependency>
            <dependency>
               <groupId>net.digitalprimates</groupId>
               <artifactId>FluintAnt</artifactId>
               <version>1.0.1-SNAPSHOT</version>
            </dependency>
         </dependencies>
      </plugin>
   </plugins>
</build>

Couple of things to point out about the above snippet:

  • There are two dependencies on resources being available on the disk, the Flex SDK (flex.home property) and the Fluint Air Runner (fluint.testrunner property).
  • Using Ant I had to create the “test-classes” and “surefire-report” directory to stick with Maven conventions.
  • We adhered to the convention of naming our test runners for the Fluint Ant task “AirRunner.mxml” so we could use this snippet in a parent POM.
  • I had to change the dependency for the maven-ant-run plugin from Ant 1.6.5, which is the default, to Ant 1.7.0, which is required by the Fluint Ant task.

You may also notice that I’m using snapshot versions of the Fluint library and the Fluint Ant task. I ended up having to change the source of the Fluint library, Ant task, and AIR runner to get Fluint to work as I wanted it to with my build. Fluint is an awesome unit testing library, it just needed some tweaks. I made changes to fix the following:

  • The XML output from the Fluint AIR runner wasn’t compliant with what the Surefire Report plugin was expecting.
  • The name of output file from the Fluint AIR runner was in the convention “TEST-*.xml” which the SureFire reporting plugin expects.
  • Fluint had the notion of an error and failure being separate but it wasn’t implemented for the Flash or AIR test runners.
  • The Ant task didn’t allow the user to specify a working directory so that the AIR runner could be launched from the appropriate directory.

I later found out that AIR and relative paths don’t play nicely together (= at all, unless there is helper code), so we also had to re-factor our test suites to NOT rely on any assets unless they are embedded or referenced with absolute URIs. This made the change to the Fluint Ant task kinda worthless, but I kept it in anyway for when AIR works in the future. Additionally, it’s important to note, that the “headless” mode in the Fluint AIR runner is really just a minimized window that closes after the XML report is written; if you plan on running your CI build on an OS without a windowing solution, then FLuint will not work since AIR does not support running in a true headless mode. On a side note, my changes should address issues #5 and #22 on the Fluint Google Code site; issue #21 should be solved by the Ant dependency fix I spoke about above and issue #20 is just a matter of the fluintAnt15.jar being compiled with Java 1.6 instead of 1.5, I believe. I’ve submitted these fixes along with my code to the Fluint guys in an email, just haven’t heard anything back yet.

So at this point I had the build process working as I wanted such that I could run “mvn clean deploy site” and find a snapshot in our team’s maven repository and site documentation generated. On to CI. I have used CruiseControl many times in the past, but the idea of being entrenched in XML, especially with all the Maven and Ant fun, was discouraging so I decided to give Hudson a try this time around. Wow … Hudson is amazing improvement over CruiseControl. Completely UI driven, I have yet to find myself digging through XML and best of all. The post-build support feel a little lighter than CruiseControl’s, but I think that’s just because I haven’t come across an X10 plugin so we can get a stop light or glowing orb setup. Hudson provides trend reporting on builds and unit tests as well as embedded reporting for unit tests and xdoclet-like documentation; it also has tons of Groovy integration which I really like (not that we’re using it … yet). Initially I chose to go with the pure Maven build for our projects, but I then decided to switch back to the free-style build; I couldn’t get trend reporting for unit tests to work with the pure Maven build, so I think my conventions are off for the Fluint reporting. In the free-style build I set the “site” directory as the Javadoc location and the “surefire-report” directory as the test report directory. Even though there is more configuration in a free-style build, it was simpler in the short run to get what I wanted in Hudson running. If unit test trend reporting isn’t as important to your CI needs, then the pure maven build may be more along the lines of what you’d like to use so that you can get the additional build trigger “Build whenever a SNAPSHOT dependency is built”. On a side note, I’m working towards using the FlexCover support in flex-mojos to make our site reports complete, but haven’t had a chance to dive in yet.

I hope some of the hurdles I encountered can help if you’re trying to get your CI process working with Flex. The flex-mojos, Fluint, and Hudson guys have some good walkthroughs/tutorials to cover the details I left out. I’m always up for suggestions, so definitely feel free to rip into my solutions. :)

Adogo October Meeting Tomorrow – Build Tool Shoot Out

Brian LeGros | October 2nd, 2007 | news  

Just in case anyone had forgotten, the Adogo (http://adogo.us) meeting for October is tomorrow. We’re going to be having the “Build Tool Shoot Out” to continue our series on “Ideas on Software Configuration Management”. I’ll be presenting on Ant and I’ve just finished putting some finishing touches on my presentation; I’m hoping it’ll turn out well. I’m really excited to see Max, Daniel, and Tyler’s presentations. Ant has always been the defacto build tool for Adobe folks, so I’m hoping that the group can walk away with quite a few options to consider when thinking about building.

I’m also hoping that quite a few folks from the ORUG will make it out to our meeting tomorrow night since 2 Ruby build tools are being represented (Rake and Buildr). We didn’t publicize this meeting with the other UG’s that much, which was probably a mistake on our part, but I hope a few stragglers find their way over to the meeting.

No word on sponsors yet, so we may be doing cookies, but come on out and support the Adogo in what promises to be a great meeting. If anything, come out to see me forgot tons of details on Ant so that you can publicly “boo” and “hiss” my presentation. See you there!