Ask HN: Merge the branch into main before build/test in CI
1 aljgz 0 7/16/2025, 9:15:47 PM
TL/DR: Is it a good idea in CI to always merge the PR's branch into main (inside the runner, not pushing to origin) before doing build and test?
Generally, In CI we do all steps like build/test, etc on the branch.
What if the CI actually does this:
- checkout main
- if the target branch is not main:
- fetch the branch from origin
- merge the branch into main (no push to origin)
- perform all other steps on this merge
This will lead to these benefits: 1- If parallel works would lead to build/test failures, there's a much higher chance of knowing this before merging
2- If there are merge conflicts, the author would know earlier. This can be a benefit or drawback depending on how each team works
3- If the build artifacts are used in any other process (like a manual or automatic E2E test), they better reflect what can be expected after the PR is merged.
My questions: a. is this a practice done by some teams? If not, is there any reason?
b. Are there other benefits or drawbacks for this?
No comments yet