Newbie to devops here and apologies this is probably a stupid question, but, what is the point of CI platforms? It seems to me that just by using git hooks I can automatically run all my unit tests before a commit and block the commit if needed. If I need to run tests in a production clone environment (I don't, but for argument sake), then I should be able to do this by spinning up a clone server and using git server hooks no? It's just that every article I'm reading on CI seems to imply that a CI platform is necessary. But so far nothing has said why. What essential component of CI can I not get unless I use Travis/Circle/Jenkins or whatever?
1 Answer
The git hooks approach could probably work fine for lone developers. But when multiple developers work on the same project it doesn't work so well, especially in large scale projects.
Several reasons:
- the git hooks are local to your copy of the repository, there is no check for consistency across all developers. Anyone can "adjust" their hook script as they see fit, or even forget to get them set up (they're not automatically installed when cloning git repositories for example). A CI platform will consistently run the same scripts for all changes.
- the verifications performed are typically done on the developer's computer, so you're right into the typical "it worked for me" case. Again - consistency: a CI platform will perform the same verifications, in the same context, on a pool of resources much easier to keep consistent than developers' environments
- the verifications performed by a developer are fundamentally silo'd, performed in isolation, on the local snapshot of the repository branch, before the changeset is actually integrated into the branch - they do not take into account the changes from the other developers which can happen at any time. Results obtained that way could be significantly misleading, see How can successfully pre-verified changes cause regressions which should have been caught?. CI platforms focus on the repository branch itself, checking how a particular changeset performs on that branch at that particular moment, with all other changesets already taken into account, reflecting the actual branch integration status.
- (in larger projects) a CI tool can perform verifications which are impractical for the individual developers. For example multi-platform build lasting hours and requiring high performance build machines well above the typical developer laptop. The centralized verifications performed by a CI platform can be much more resource frugal than when performed by each individual developer.
Side note: not all projects benefit from the developer ability to spin up on demand a production-like environment/clone server ;) But even if possible, most of the above reasons still stand
-
4
-
1Server-side hooks should be OK, forgot about that. Functionally those make your git server the (custom) CI platform ;) You only need to care about scaling it to be able to handle the extra load associated with the verifications. Commented Jun 28, 2019 at 11:08