PHPCI icon indicating copy to clipboard operation
PHPCI copied to clipboard

Git Clone with references / cache

Open adamlc opened this issue 12 years ago • 17 comments

It looks the repository is cloned from a fresh each time a test is run. This can be speeded up dramatically by caching the repository locally.

Try reading this website for more info:

http://randyfay.com/content/reference-cache-repositories-speed-clones-git-clone-reference

adamlc avatar Mar 18 '14 13:03 adamlc

Or perhaps making an option to toggle between fetch and clone?

falk avatar Mar 25 '14 14:03 falk

Sounds like this would be a good idea. Happy to look at any pull requests that come our way related to this.

meadsteve avatar Mar 25 '14 22:03 meadsteve

We have git repo that is 700mb after clone and it is very painful to build each time. I'm not sure how this scenario could hurt (example code that we use for similar purposes):

if [ ! -d "${CLONE_DIR}" ]; then
    git clone "${GIT_REPO}" "${CLONE_DIR}"
fi

cd $CLONE_DIR

git fetch origin
git reset --hard "origin/${BRANCH}"

This is zillion times faster (roughly) than doing full clone each time.

Are there any objections against doing this?

bobrik avatar Sep 19 '14 10:09 bobrik

+1

r3nat avatar Sep 19 '14 10:09 r3nat

+1

Aliance avatar Sep 19 '14 10:09 Aliance

gumeniukcom avatar Sep 19 '14 10:09 gumeniukcom

:+1:

adamlc avatar Sep 19 '14 12:09 adamlc

sanuter avatar Sep 19 '14 12:09 sanuter

Idea is nice, but I wonder how this could work with parallel builds. If you always take the same repo won't there be any conflicts (at testing) if you change the branch/commits etc? If yes this would make parallel builds impossible.

faeron avatar Sep 19 '14 18:09 faeron

@Skullcrasher parallel builds could be achieved with cp, if they are needed. You only need to lock git fetch and cp stage. cp is faster than git clone anyway.

bobrik avatar Sep 20 '14 16:09 bobrik

+1 :)

mikedamoiseau avatar Oct 10 '14 08:10 mikedamoiseau

+1 :D

thinkspill avatar Feb 05 '15 03:02 thinkspill

Sorry for reopen this, how we do config for this to work?

Spiritvn avatar Nov 15 '15 17:11 Spiritvn

build_settings:
    clone_depth: 1 # depth of 1 is a shallow clone, remove this line to clone entire repo

See top of the page here: https://www.phptesting.org/wiki/Adding-PHPCI-Support-to-Your-Projects

edit: this may not be exactly the same as a 'repository mirror' but it does avoid re-cloning the entire repo on every build.

thinkspill avatar Nov 15 '15 20:11 thinkspill

Thanks @thinkspill, i dont really understand the clone_depth setting because when i tried, it still clone the entire repo on every build?

I really need it only build the changes, not clone...

Spiritvn avatar Nov 16 '15 02:11 Spiritvn

clone_depth uses the --depth parameter in git clone it makes a shallow clone, so the cloned copy won't have any history just HEAD (so for instance, if you had a massive file in the repo which was deleted months ago you want need to wait for git to clone that each time).

There is no way to pull in just the files which have changed, and I'm not sure that would be desirable anyway as then things like unit tests would almost certainly fail?

REBELinBLUE avatar Nov 16 '15 17:11 REBELinBLUE

@REBELinBLUE thanks for explaination, and yes that's why i asked for the config to make the https://github.com/Block8/PHPCI/pull/838 to work. It's ok to build the new one to test but shouldn't re-clone entire source, for big project it would be so long on that part.

I just didn't notice that it was closed instead of merged as you did... ^^

Spiritvn avatar Nov 16 '15 17:11 Spiritvn