20

Are there any best practices for enforcing a TFS check-in policy? Are there any good guides on how to implement various types of policies as well as their pros and cons?

Things I'd particularly like to do are ensure that code compiles (note that compilation can take up to five minutes) and that obvious bits of the coding standards are followed (summary tags must exist, naming conventions are followed, etc).

tshepang
  • 12,111
  • 21
  • 91
  • 136
JSWork
  • 1,015
  • 1
  • 12
  • 21
  • I have heard a lot about this functionality in TFS 2010 - but I would like some insight too - especially into the gated checkins as you mentioned. To confirm, you are talking about TFS 2010? I look forward to the answers. – Russell Mar 16 '11 at 22:38

3 Answers3

17

TFS 2010 (and 2008 but I have not used 2008) allows a gated checkin - which forces a build prior to the build being checked in.

Activating this is a (reasonably) straightforward process, see for example these guides: http://blogs.msdn.com/b/patcarna/archive/2009/06/29/an-introduction-to-gated-check-in.aspx http://intovsts.net/2010/04/18/the-gated-check-in-build-in-tfs2010/

There is a step before all this which is required to make all this happen. That is a TFS build server setup. That can be a complex process depending on infrastructure etc. Here is an MSDN guide: http://msdn.microsoft.com/en-us/library/ms181712.aspx

The pros are that the code in the repository can be reasonably stable. For a large team this can save a LOT of time.

There are a lot of cons worth considering for this benefit. Firstly, the installation and maintenance of an extra build server. This include disk space allocation, patches etc. Secondly is the extra time required for each person to check in a file. Waiting for a build to succeed before the code is checked in (and available for others to get) can be a while. Thirdly, when (not if) the build server is not available, a contingency plan needs to be in place to allow developers to continue their work.

There is a lot of extra process required to reap the rewards of gated checkins. However is this process is governed properly it can lead to a much smoother development cycle.

Although we do not use gated checkins, we do use a TFS build server for continuous integration to do scheduled builds. This minimises the dependency minute-to-minute on the build server while ensuring (with reasonably effectiveness) that after a build has broken, we are notified and can rectify it ASAP. This method empowers the developers to have an understanding of integrating code, and how to avoid breaking the code in the repository.

Russell
  • 17,481
  • 23
  • 81
  • 125
5

I think the premise of this question is somewhat wrong. I think a good question of this nature should be something along the lines of; my team is having a problem with code stability, conflicting change-sets, developers not running tests, poor coverage, or other metric reporting to management and we'd like to use TFS to help solve that(those) issue(s). Yes, I do realize that the OP stated that ensuring compilation is considered a goal, but that comes part and parcel with having an automated build server.

I would question any feature that adds friction to a developer's work cycle without a clearly articulated purpose. Although I've never used them, gated check-ins sound like a feature in search of a problem. If the stability of your codebase is impacting developer productivity and you can't fix it by changing the componetization of your software, dev team structure, or a better branching strategy, then I guess it's a solution. I've worked in a large shop on a global project where ClearCase was the mandated tool and I've encountered that kind of corporate induced fail, but the team I worked on didn't go there quietly or willingly.

The ideal policy is not to have one. Let developers work uninhibited and with as little friction as possible. Code reviews do much more than a set of rules enforced by a soul-less server will ever do. A team that supports testing, and is properly structured will do more for stability than a gated check-in will ever achieve. Tools that support branching and local check-ins make it easier for developers to try new things without fear of breaking the build will help mitigate the kind of technical debt that kills large projects.

Ritch Melton
  • 11,498
  • 4
  • 41
  • 54
  • Completely agree with your sentiment, but we want the tightest feedback loop possible. We run our tests, static analysis, code format analysis, etc as a part of builds to ensure or measure code quality. Check in policies provide quicker feedback by allowing the developer to verify quality checks locally. Also, remember that it is *very* simple to override check in policies so these are more reminders than policy. – Ryan Cromwell Mar 20 '11 at 02:37
  • however in TFS you must grant the overide checkin policy permission, so you still need to think about whether you want the whole team to have that ability. – Anonymous Type Jul 21 '11 at 01:11
  • Especially the "local check-ins" part is of interest to me, which is a big miss for me, coming from Git. – Grimace of Despair May 30 '16 at 09:47
4

You should look at chapter 8 of "Patterns & practices: Team Development with Visual Studio Team Foundation Server"

http://tfsguide.codeplex.com/

JP.
  • 5,536
  • 7
  • 58
  • 100
  • 1
    Agreed, I'm not sure that you can really make "code compiles" a check-in policy as such - instead you need decent reporting on a build that is kicked off when a developer checks in some code (a.k.a. "Continuous Integration") so that you're all alerted to the the fact that you have a "Broken Build" and who checked in the code. – Zhaph - Ben Duguid Mar 16 '11 at 22:56
  • 3
    You can make "code compiles" a check-in policy (as a gated checkin). http://blogs.msdn.com/b/patcarna/archive/2009/06/29/an-introduction-to-gated-check-in.aspx – Russell Mar 16 '11 at 23:24
  • Can you please summarize the key points from Chapter 8 that are applicable to this question so that it isn't a link only answer? – Ryan Gates Feb 18 '16 at 20:37