In fact it end up with a matter of trade-off...
There are a lot of variables that make that in the end that's you that will decide where to put the limit (and later perhaps push it further).
You should understand that you won't be able to find and fix all the bugs and problems with your CI workflow so you will have to find the good way to have the expected quality.
It depends on:
- what level of quality you expect in your
master
branch and so the value you give to an early feedback.
- what it will cost you to achieve that.
If you use GitHub, the service simulate a merge of your PR with the target branch and that's what you normally build. So, from this point of view, you don't need to rebuild and test your target branch after the merge.
But there are some corner cases...
If another PR is merged after the last commit pushed in your PR, the PR is not re-built (GitHub just verify if that's still mergeable).
Here you have two solutions:
- You set as mandatory to sync (through a
rebase
or sync merge
) the PR before merging it => No need to rebuild the target branch.
- No mandatory => You need to build the target branch. That will be your "integration build".
From a quality point of view, it's better to build the target branch because it is doing a clean build and there are sometimes corner cases that you don't catch in the PR build.
If you need to avoid these corner cases because you must have a very high quality product because, for example, lives or high amount of money, or whatever the reason depends on the output the build, you should build it again.
So as you see, it all depend of your CI workflow, quality expected and cost to put it in place.
Side note: Most of the time it's still useful to build the target branch to create clean artifacts (so the build that you do in PR is different than the one of the target branch). So it still a good practice...