Some of the best practices of Continuous Integration (CI) are as follows:
- Build Automation: In CI, we create such a build environment that even with one command build can be triggered. This automation is done all the way up to deployment to Production environment.
- Main Code Repository: In CI, we maintain a main branch in code repository that stores all the Production ready code. This is the branch that we can deploy to Production any time.
- Self-testing build: Every build in CI should be self-tested. It means with every build there is a set of tests that runs to ensure that changes are of high quality.
- Every day commits to baseline: Developers will commit all of theirs changes to baseline everyday. This ensures that there is no big pileup of code waiting for integration with the main repository for a long time.
- Build every commit to baseline: With Automated Continuous Integration, every time a commit is made into baseline, a build is triggered. This helps in confirming that every change integrates correctly.
- Fast Build Process: One of the requirements of CI is to keep the build process fast so that we can quickly identify any problem.
- Production like environment testing: In CI, we maintain a production like environment also known as pre-production or staging environment, which is very close to Production environment. We perform testing in this environment to check for any integration issues.
- Publish Build Results: We publish build results on a common site so that everyone can see these and take corrective actions.
- Deployment Automation: The deployment process is automated to the extent that in a build process we can add the step of deploying the code to a test environment. On this test environment all the stakeholders can access and test the latest delivery.