Albathor: Albacore Build in 10 Seconds

Albathor is my experiment (not yet released) in trying to create an Albacore build generator system. The goal is to provide a killer bootstrapping or ‘getting started’ experience with Albacore for existing .Net projects.

I’ve decided to start testing Albathor on seemingly random open source solutions. Here, I start with Shouldly.

C:\Users\Dotan\Downloads\tests\shouldly-shouldly-d5a7871>dir

03/31/2011  06:03 PM    <DIR>          .
03/31/2011  06:03 PM    <DIR>          ..
03/31/2011  06:03 PM               104 .gitignore
03/31/2011  06:03 PM    <DIR>          build
03/31/2011  06:03 PM    <DIR>          lib
03/31/2011  06:03 PM             1,510 LICENSE.txt
03/31/2011  06:03 PM             2,038 README.markdown
03/31/2011  06:03 PM             1,365 Shouldly.sln
03/31/2011  06:03 PM             1,391 Shouldly2010.sln
03/31/2011  06:03 PM    <DIR>          src

Now lets albathor init the Shouldly solution.

C:\Users\Dotan\Downloads\tests\shouldly-shouldly-d5a7871>albathor init Shouldly
Creating Albacore build for Shouldly.sln
      create  Rakefile
      create  Gemfile
      apply  C:/Ruby187/lib/ruby/gems/1.8/gems/albathor-0.0.1/templates/default.alba
Done. Run 'bundle install' once to set up your dependencies.

Lets look at our albacore build options with rake -T.

C:\Users\Dotan\Downloads\tests\shouldly-shouldly-d5a7871>rake -T
(in C:/Users/Dotan/Downloads/tests/shouldly-shouldly-d5a7871)
rake build  # Build release

That’s it. Albacore is ready to build, lets verify:

C:\Users\Dotan\Downloads\tests\shouldly-shouldly-d5a7871>rake build
(in C:/Users/Dotan/Downloads/tests/shouldly-shouldly-d5a7871)
I, [2011-04-08T19:17:39.301646 #7320]  INFO -- : Generating Assembly Info File At: C:/Use
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation 2007. All rights reserved.

Build started 4/8/2011 7:17:41 PM.
Project "C:\Users\Dotan\Downloads\tests\shouldly-shouldly-d5a7871\Shouldly.sln" on node 1
ValidateSolutionConfiguration:
  Building solution configuration "Release|Any CPU".
Project "C:\Users\Dotan\Downloads\tests\shouldly-shouldly-d5a7871\Shouldly.sln" (1) is bu
..
..
..
Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:05.11

And we have Shouldly driven by an Albacore build (+AssemblyVersion task as a bonus) in 10 seconds.

Auto Configuring Tests

Story not done yet. Now I’m going to re-do the process with a custom albathor template. The template is located here http://pastie.org/pastes/1747874. In it you’ll find the nunit command which will fetch, configure and find your tests project into your albacore build along with NUnit itself.

C:\Users\Dotan\Downloads\tests\shouldly-shouldly-d5a7871>albathor init Shouldly http://pastie.org/pastes/1747874/download
Creating Albacore build for Shouldly.sln
      create  Rakefile
      create  Gemfile
      apply  http://pastie.org/pastes/1747874/download
Downloading nunit...
      create    tools/nunit.zip
Done. Run 'bundle install' once to set up your dependencies.

After this ran I have the following tasks magically pointing to the correct test assembly and tools (which were downloaded and unpacked for my by Albathor):

desc "Run tests"
nunit :nunit do |nunit|
  nunit.command = "tools/NUnit-2.5.9.10348/bin/net-2.0/nunit-console.exe"
  nunit.assemblies "src/Tests/bin/Release/Tests.dll"
end

And now I’m able to run the tests happily:

C:\Users\Dotan\Downloads\tests\shouldly-shouldly-d5a7871>rake nunit
(in C:/Users/Dotan/Downloads/tests/shouldly-shouldly-d5a7871)
NUnit version 2.5.9.10348
Copyright (C) 2002-2009 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.

Runtime Environment -
  OS Version: Microsoft Windows NT 6.1.7600.0
  CLR Version: 2.0.50727.4952 ( Net 2.0 )

ProcessModel: Default    DomainUsage: Single
Execution Runtime: Default
.........................................................
Tests run: 57, Errors: 0, Failures: 0, Inconclusive: 0, Time: 2.4151326 seconds
  Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0

The fun thing is that I didn’t customize anything at all.

Cool? I’d love to hear your suggestions/opinion, tweet me up @jondot.