Geeks With Blogs
.net alternatives by Michel Grootjans

Part 1: The problem

coffee I have a need for a regular coffee break when I'm working. Most people from our team share that need. I'll describe a typical situation.

I'm doing my day job, pair programming a component that will probably save the world. After a while, a feeling of drowsiness starts dulling my senses. Time for a cup of coffee. I look up to the table where the coffee thermos is supposed to be. No coffee!

Someone must have made coffee. But who? When? Should I go and get the coffee now, or is it still dripping? I have no choice but to raise my voice and ask everyone in the team: "Who made coffee?".

"I made coffee a while ago" says one of my teammates. "Not sure how long ago though". Hmm... ok, let me go and get it. I get out of the room, walk through the corridor. All the way to the back, enter the other office that has the luxury of having a coffee machine. There it is. Damn, it's still running, I'll have to come back in five minutes. I walk back to the other end of the hall and get back to work. The workout has awakened me enough to be able to concentrate again.

After an hour someone exclaims: "Who made coffee?" Arghh! Forgot about it. It's probably cold by now.

Part 2: The analysis

imageSomething has to be done about the business process of making coffee. The actors are well known and have their set of responsibilities. The different states and operations are clearly defined. Maybe the process can be partially automated.

Once a geek, always a geek. This had to become an application. And this had to be integrated in our continuous integration.

The basic idea is simple. It follows these easy steps:

  1. You go and make coffee
  2. You start the coffee build on the CI
  3. 10 minutes later, the build fails. This causes Homer to yell his famous "D'oh!".
  4. Everyone looks up! Someone broke the build. Oh, ok. It's only the coffee build.
  5. You go and get the coffee.
  6. You start the coffee build again and it instantly turns green.

Part 3: The implementation

Ok, so we need an application that runs a preset time then fails. If run again, it succeeds instantly. A kind of toggle.

This is the basic idea:

private static void Main(string[] args)
{
var parser = new ArgumentParser(args);
if (Coffee.IsRunning)
Coffee.StopRunning();
else
 Coffee.StartRunningFor(parser.MinutesToRun);
}

The coffee implementation was easy enough now:

public class Coffee
{
private const string coffeeFile = "coffeeIsRunning";

public static bool IsRunning
{
get { return File.Exists(coffeeFile); }
}

public static void StartRunningFor(int minutesToRun)
{
File.Create(coffeeFile);
        Thread.Sleep(TimeSpan.FromMinutes(minutesToRun));
throw new Exception("Coffee should be ready by now.);
}

public static void StopRunning()
{
File.Delete(coffeeFile);
}
}

Integrate in CruiseControl.net and all our problems are solved.

Part 4: A month later

After a month, we're still faithfully running our coffee build. We still regularly have a laugh about this silly geeky solution. Maybe that was the real point after all ;-)

Posted on Thursday, October 2, 2008 10:29 PM .net | Back to top


Comments on this post: How coffee broke our build

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Michel Grootjans | Powered by: GeeksWithBlogs.net