2

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 git@github.com:<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?

daltonfury42
  • 3,103
  • 2
  • 30
  • 47
  • Sorry, we [can't accept images of code, data or errors](https://meta.stackoverflow.com/a/285557). Post those as *text*, so that we can try to reproduce the problem without having to re-type everything, and your question can be properly indexed or read by screen readers. – Martijn Pieters May 02 '22 at 02:28
  • Run diagnostics with and without `cloneDepth: 1`: (a) compare execution timings by phase using `aws codebuild batch-get-builds` from the cli (b) compare `.git` dir size in the codebuild container using a `du -sh .git` command in the buildspec. What are the results? – fedonev May 02 '22 at 10:20

0 Answers0