Correctly implementing Continuous Integration (CI) tools and practices can reduce errors in code, shorten development cycles, and help your team ship software faster. In this article, we’ll take a closer look at CI and outline the processes, best practices, and team culture you’ll need to be successful. We’ll also discuss how GitHub can help make it an intuitive part of your workflow.

What is Continuous Integration?

Continuous Integration is a development practice where developers regularly merge and integrate changes to code into a central repository. These changes are then run through automated builds that test it for early stage errors. Catching bugs early and automatically is critical for reducing the number of defects introduced into production, increasing the overall quality and efficiency, and shortening the feedback cycle. The CI process is especially effective when coupled with a version control system like Git. Git helps maintain integrity and quality of the code through version control, adding to the benefits of CI, which require regular merges to code.

Adopting Continuous Integration

With new tools and increasingly simplified setups, implementing CI is still a challenge for many organizations. More than tools, successfully implemented CI requires both an organization’s technology and its culture to support flexibility and collaboration. The right organizational and operational structures can help engineers share knowledge, contribute across teams, and do their best work.

To help evolve and scale your team’s workflow, we’ve collected three key insights from other teams with successful CI practices:

  1. Successful CI adoption requires both the right technology and a collaborative culture to be successful.
  2. Both your tooling and mindset need to evolve as fast your team does.
  3. What works for other teams might not be what’s best for you. It’s important to be flexible and choose an option that works for your team.

Organizations often find themselves fumbling to adapt when faced with increases in product complexity, growing teams, and evolving development practices. Adopting a flexible company culture allows them to change as their teams and products do. When an organization is built on collaborative work, it’s built to evolve—and inevitable changes are no longer disruptions but opportunities.


How does GitHub fit into CI?

With CI and automated testing in place to reduce bugs and maintain build quality, developers can confidently merge code multiple times a day. On GitHub, your team can work together with the tools they need for reliable version control and build a foundation for successfully implemented CI practices.

GitHub Flow makes tasks manageable

The GitHub Flow is a lightweight, branch-based workflow that makes it easier for teams to review both the quality and intent of their code.

With all manual code review happening in pull requests, they’re an intuitive place for status checks and other automated checks. Compared to the Git flow, which is geared towards a “release” process, the GitHub Flow works best for developers deploying code constantly throughout the day.

The GitHub Flow:

  • Create a short but descriptively named branch off of master
  • Make your changes
  • Open a pull request when it’s ready for feedback, review or merge. You can also measure the pull request against a set of criteria before it can be merged
  • Once the review is complete, the pull request is ready to be merged
  • Remember with any merge, that master should always be deployable

Culture and mindset

Along with the tools you choose, your company’s culture can have unexpected effects on the development practices that work for your engineering teams—and the quality of software you build.

Shaping company culture to be flexible and transparent isn’t easy. Some companies have found success adopting Innersource—a development methodology modeled after open source software development practices—that runs from within a firewall.

Automated builds, tests, and version control are powerful tools that can transform your products. In order to take full advantage of CI tools, developers need processes that encourage them to give feedback on code, share ideas, and make the changes they want to see. These regular changes are what make CI patterns work.

The freedom to integrate

Every organization is unique, and every team needs the flexibility to choose the right toolset. GitHub integrates with hundreds of third party tools, including some of the most popular and well-documented integrations around, available from GitHub Marketplace and the Works with GitHub directory.

Developers can also find more options through third parties, as well as open source integrations on GitHub.com. If you can’t find the right tools for your team, you can build your own with our robust API and webhooks.


Technology and features

Protected branches for branch level permissions

Mistakes can happen if every team member can commit and change code on the master branch. GitHub provides counter measures that keep the chaos and help teams maintain the consistency and quality of their code.

Protected branches allow you to define which individuals or teams have write access to a given branch, preventing accidental deletions and force pushes. You can also set required status checks and enforce code reviews before merging.

Learn how to protect branches

Codeowner

Code owners add another layer of security to your projected branches. All pull requests made to a repository with code owner(s) automatically requires a review from them. To get started, simply add a CODEOWNERS file to define the ownership of the code, check Require review from code owners in the “Branch” tab of your repository’s “Settings”, and you’re ready to go.

Pull request reviews are incredibly useful, but organizations still have to account for human error.

Over time, assigning code owners decreases the overall time spent fixing bugs, connects developers and teams, and encourages discussions that ensure code is the best it can be.

Learn more about setting code owners

ChatOps for DevOps - Hubot

ChatOps lets your developers automate parts of their work with the communication channels they already use. Developers can reduce the feedback loop and receive notifications when issues arise, right from their chat platform. Using ChatOps commands in chat applications like Slack can instantly return CI job statuses and other useful information.

Here are a few of the common operational commands we use at GitHub:

  • hubot ci setup <name>
  • hubot ci build <repo>/<branch>
  • hubot deploy ci to production
  • hubot ci node reboot <node>
  • hubot ci node start <node>
  • hubot ci node stop <node>

For example:

chatops


When developers can collaborate transparently with the right tools for the job, better software is inevitable. Successful development teams depend on a cultural and technological foundation of flexibility and speed. Teams that have the right checks in place can move quickly but not recklessly, allowing developers the freedom to experiment and explore new ways to approach problems. GitHub and CI can help your team build this foundation.


Next steps

Learn how GitHub uses GitHub

Our webinar series run from July to November 2017 and best of all, they’re free!

GitHub Services team

We provide trainings to GitHub and non-GitHub customers alike. Contact us to find out more, or visit us at services.github.com.

  • Workflow consultation: Consult with a Services Engineer to review useful Git workflow strategies and design a workflow that is tailored for your organization, maximizing collaboration through Git and GitHub.
  • CI/CD class: Learn from GitHub Trainers how to start using integrations that specialize in continuous integration and continuous deployment, like CircleCI or TravisCI, without leaving GitHub. Developers in this class will learn how to use automated feedback on the quality and functionality of their code, make the most of the tools in their development pipeline, and ship higher quality code faster.

Find more training, guides, and cheatsheets on our Resources Page