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:
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 agit fetch
as per this StackOverflow post: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?