In Gitlab there is a simple way to configure the pipeline so that if a job fails (for example a job that runs all unit tests) then the merge is not gonna happen. https://doc