Git Clone with references / cache
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
Or perhaps making an option to toggle between fetch and clone?
Sounds like this would be a good idea. Happy to look at any pull requests that come our way related to this.
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?
+1
+1
:+1:
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.
@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.
+1 :)
+1 :D
Sorry for reopen this, how we do config for this to work?
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.
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...
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 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... ^^