Search code examples
gitcontinuous-integrationtravis-cishallow-cloneappveyor

Disadvantages of shallow cloning on Travis and other CI services?


Most CI services provide a way to shallow clone a repository. For example, on Travis:

git:
  depth: 1

or on AppVeyor:

clone_depth: 1
or
shallow_clone: true

This has the obvious benefit of speed, since you don't have to clone the whole repository.

Is there any disadvantages to shallow cloning on CI services? Is there any situation where a shallow clone would make a CI build fail? Otherwise, why isn't shallow cloning the default setting for these CI services?


Solution

  • There's two reasons why it doesn't usually happen.

    Firstly, the hash of a shallow clone is going to be different from any version that you may have in the repository. As a result, it's not going to be possible to track a build that you've done to any particular result.

    Secondly most Git servers have the ability to send the optimised 'everything.pack' if you have no details. Otherwise the server will have to provide a custom commit pack which contained just your shallow copy to send to you. So although there may be more data transmitted across the wire, it may actually result in more work on the server.

    Finally quite a lot of CI builds will perform some kind of tag operation and upload it to the repository, and you can't practically tag a shallow clone (see point 1).