Move buildbot and buildcaching logic out into its own file