WIP: include lhcb-hooks in gitlab-ci
This change is part of the simplification process of some scripts that should run before changes are merged to a branch. This is especially important for the master branch.
Up until now, every repository needed to include their own jobs that would contain an implementation of the said scripts. For example, if i wanted to check that the formatting is ok in my files before merging, i would have to create a job that includes a script that does that. And if i wanted to have this in my other repository as well, i would have to write it there too.
We have found a way to make this simpler and with much less duplication. This solution comes in the form of a python package called "pre-commit". I will not go into much detail on what pre-commit is, as you can find more information here (https://pre-commit.com/) and another explanation as well as a guide on exactly how to use it, here (https://gitlab.cern.ch/lhcb-core/pre-commit-hooks).
So, each repository should have its own .pre-commit-config.yaml file, which shows what scripts need to be run before commiting/merging and where to find them. If a repository does not contain a .pre-commit-config.yaml file, an lhcb default .pre-commit-config.yaml is used instead, containing some standard scripts (a check for copyright comment on the start of the file, a check for the formatting of files and a check for a license file in the repository). If all the checks pass, the pipeline continues normally, usually by running the unit tests. If a check fails, the whole pipeline fails as well, indicating that these changes should not be merged.
The logic above, is captured in the included yaml file. That way, a common way to include this kind of scripts is provided, while customization is still available by having your own .pre-commit-config.yaml. This limits duplication while needing to include only 2-3 lines in your gitlab-ci.yaml
To use this yaml file properly, the stage "pre-commit-hooks" needs to be added to the pipeline if other stages are already defined.