Why builds break on our team? Because we have no idea how to add precommit hook to perforce intellij client so it tries to build and test the whole thing locally before pushing changes to repo.
Why not have local pre-commit hooks? Even if you are not using git-p4 clobbering some sort of frontend tool to p4 submit that first runs make etc that everyone would use would be a big win for your team.
Everybody uses intellij. We couldn't find ability to add local precommit hooks there and we didn't have resources to build our own custom tool for such basic operation.
You are using perforce so just write a bash script called p4 that if you are doing a commit first does checks followed by the real commit and otherwise passed every command to the real p4.
and your team isn't disciplined enough to do it manually ("nothing is stopping us" is an explanation why things happen sometimes, but it is a bad excuse)
As I heard it, one of the late-nineties projects at Microsoft had a big problem with build breakages. They finally instituted a policy of tracking down every build breakage, and conducting a little humiliation ritual of awarding the offender a "big sucker" award at the weekly project meeting. This award had to be displayed on the developer's office door for a week or something.
You could dodge the award even if you did break the build by showing that you had run the full unit test suite before you submitted your code.
Yeah. We considered that but that's horrible social solution for purely technical problem. It's like beating your child so he won't put fingers in the wall socket instead of childproofing it.
One shouldn't make a big deal about it, but something like "whoever breaks the build on an important branch (and doesn't immediately remember and reverts it) brings cookies/makes a coffee run/... for everybody in the same office" can work if it happens to often. You are right, occasional mistakes happen, so it has to be something simple.