Continuous Integration

Last modified by chrisby on 2024/05/05 17:22

Integrate code change at least once a day. This means that code changes on a feature branch you are working on should be merged/integrated into the main branch, and main branch changes should be merged into the feature branch.

For example, at the beginning of the day, each developer merges the latest main branch commits into their current feature branch, and at the end of the day, each developer merges their feature branch commits into the main branch.

Benefit

Many Small Integrations Are Cheaper: The longer side branches wait to be merged into the main branch, and the larger the differences between them become, the greater the risk of multiple integration conflicts. It is easier to fix small individual integration problems iteratively than it is to fix multiple problems at once. Therefore, continuous integration has the advantage of catching integration problems early, when they are cheap to fix.

Guidelines

  • Stable Code Only: Just code that passes all tests shall be merged into the main branch. There are tactics for speeding up test execution to help ensure that this practice can be performed frequently. For example, it is common to run acceptance tests only once a day, at night, because they are so time-consuming, and to fix problems, if any, the next day. All other tests are much faster and can be run frequently during development. The faster, the better.
  • Incomplete Features Allowed: It is normal for the main branch code to temporarily contain incomplete features. Feature toggles are a common pattern for turning off incomplete features through simple configuration.
  • Never cheat to make a failed pipeline/test suite pass, e.g. by removing the failed tests.

Code Reviews

Requesting and providing code reviews, as on GitHub or GitLab, is a convenient feature for making code reviews asynchronous and remotely available, but it is not the most time-efficient approach for agile teams that do not need these features. For those teams, it is better to maintain high quality code by following these practices:

  • Code is properly tested, refactored and simplified.
  • Code is implicitly reviewed in real time by pairing up with technically experienced team members.