'AWS Codebuild: git clone depth of 1 doesn't work

We have a large repo, where a normal clone would take 10+ minutes. We want to set fetch depth to 1 to minimise the time to download source code on AWS Codebuild.

  • Setting clone depth to 1 doesn't show any improvement in time: enter image description here

  • It takes 600+ seconds on Codebuild regardless of dept 1 or full depth.

  • On local, git clone [email protected]:<org/repo>.git --depth 1 takes less than 1 minute.

  • Shallow clone on Github Action takes less than 30 seconds for the same repo. A wild guess is that clone with fetch depth won't work when you specify a branch/version. Github actions might be getting around this by doing a git init followed by a git fetch as per this StackOverflow post: enter image description here Log output from above screenshot:

/usr/bin/git init /home/runner/work/<repo/name>
/usr/bin/git remote add origin https://github.com/<repo/name>
/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin <sha>:refs/remotes/pull/6981/merge

Any thoughts on how to speed up the time spent in downloading source code?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source