views:

121

answers:

2

I'm currently trying to reduce the time taken to compile and unit test projects in TeamCity.

Currently my project takes about between 5 to 8 minutes to build.

What it does is:

  1. Clean any existing files
  2. Compile each project
  3. Create the installer

Once that is done the unit tests are kicked off and it takes about 2 minutes to run.

What it does is:

  1. Clean any existing files
  2. Compile each project
  3. Run all the unit tests

Now, running the unit tests only takes 5 seconds....so the clean and compile step takes about 2 minutes....and the create installer step about 3 to 6 minutes.

My first question is: Is there any way to configure team city so that it doesn't have to do the clean and compile steps again when it runs the unit tests. I believe the main reason why we have it that way is because the project build and unit tests can be run by different build agents.

My second question is: Is 5 to 8 minutes a reasonable time for a project build to take? Are there ways to optimize the compile of the projects in the solution as well as the installer creation?

Please let me know if there are any additional details I can supply that might help you to point me in the right direction of either optimising the build or just leaving things as they are.

Update to answer some questions from Nate:

When you run the build outside TeamCity, does it do a clean/compile again before the unit tests? No, because when you run it on your own machine you can specify which parts of the build script to run. We have sections for clean, compile, unit-test etc which get specified differently in team city for project build vs unit test running.

If so, can you make the build not do that before the tests? The reason we don't do this at the moment is because when different build agents are used the files needed for the unit test would not be available and thus would fail.

What are you using to build your project? we use Nant to build our project, wix for the installer, and NUnit and NCover for the unit tests and coverage reports.

What source control system are you using? Subversion

+1  A: 

Regarding #1: When you run the build outside TeamCity, does it do a clean/compile again before the unit tests? If so, can you make the build not do that before the tests?

What are you using to build your project? What source control system are you using?

Another option consider is having multiple build configurations. At my work, we have several configurations. One that runs after each commit. It does a clean/compile and some quick tests. We then have a nightly config that does a clean/compile and all the tests. Can you do something like that?

Nate
At the moment our project compile is kicked off after each commit. If the build succeeds then the unit tests are run. And once a day we run the integration tests.
mezoid
A: 

As a rule of thumb you should keep the build that is triggered on commit as short as posible, so you should try to refactor the build configuration into a slim on commit build, and run the current configuration once every hour or so.

Kasper