In a recent post of the future of Continuous Integration , I pondered how the broken build can affect your development team and offered potential solutions. My next topic is what many consider to be the bane of CI, Long-Running Builds. Again, I don’t think there’s a silver bullet answer to this conundrum. But, depending on how the problem manifests, there are some solutions. I spend quite a bit of time in chapter 4 discussing long-running builds, so this is a quick synopsis.
The Problem
- In the context of CI, long-running builds can slow developers from moving onto their next task. For instance, on Agile projects, many employ the rule that you don’t work on your next development task until the integration build is successful
How Long is too Long?
Symptoms
- The obvious: developers complaining about how long it takes for the builds to run
- Developers check in their code less often (making integrations more painful when they do happen)
- People sitting around waiting for the integration build to complete
Possible Solutions
First, as I describe in the book , it’s useful to know what the actual problem is. From my experience, I’ve found that long-running tests are often the cause for a “long-running build”.
- Add some horsepower - Increase your CPU speed, disk speed, and/or your RAM. This is often a cost-effective and quick solution to the problem.
- Stage your Builds - Run a quick commit build that consists of compilation, fast-running automated tests (i.e. unit tests without heavy dependencies), and deployment. After this commit build succeeds, run a slower-running tests, full database integration, inspections, and installation (depending on your build)
- Categorize your Tests - Segment your unit, component, system, functional, etc. tests so that you can run them at different frequencies
- Run Tasks in Parallel - Run certain build tasks in parallel - such as tests. This can only work if the result status of one task is mutually exclusive to another
As I mentioned, this is only a high-level view on a difficult problem. There’s a lot more detail in the book addressing this issue. Depending on the situation, there are simpler and more difficult solutions than others.