Continuous Integration Explained
Continuous Integration Explained
semaphoreci.com
1
Extension with Continuous Delivery
all automated tests on every commit. Based on the total result of tests, it either accepts
or rejects the code commit.
Read more: on software integration problems.
CI and CD pipeline
CI and CD are often represented as a pipeline, where new code enters on one end, flows
through a series of stages (build, test, staging, production), and published as a new pro-
duction release to end users on the other end.
Each stage of the CI/CD pipeline is a logical unit in the delivery process. Developers
usually divide each unit into a series of subunits that run sequentially or in parallel.
Published by Semaphore: CI/CD for teams that don’t like bottlenecks - semaphoreci.com 2
Prerequisites for doing Continuous Integration
For example, we can split testing into low-level unit tests, integration tests of system
components working together, and high-level tests of the user interface.
Additionally, each stage in the pipeline acts as a gate that evaluates a certain aspect
of the code. Problems detected in an early stage stop the code from progressing fur-
ther through the pipeline. It doesn’t make sense to run the entire pipeline if we have
fundamental bugs in code to fix first. Detailed results and logs about the failure are
immediately sent to the team to fix.
Because CI/CD pipelines are so integral to the development process, high performance
and high availability are paramount for developer productivity.
Read more: on CI/CD pipelines.
Published by Semaphore: CI/CD for teams that don’t like bottlenecks - semaphoreci.com 3
A typical development workflow
• Automating builds;
• Automating testing;
• More frequent commits to a single source code repository, and
• Providing visibility of the process and real-time access to CI status to the team.
Teams that don’t practice CI yet should take small steps, continuously improve, and iter-
ate on code and process in a way that helps the organization grow.
On every step in the journey to full CI/CD, the development team’s productivity will rise,
as well as the velocity of the entire business.
Published by Semaphore: CI/CD for teams that don’t like bottlenecks - semaphoreci.com 4
Continuous integration tools
Continuous integration is a way for your team to automatically build and test every single
change in the source code. This is the foundation that enables your broader software
delivery process to be efficient, resilient, fast, and secure.
The automated testing process can include many different types of checks:
• Verify code correctness;
• Validate application behavior from a customer’s perspective;
• Compare coding style with industry-standard conventions;
• Test code for common security holes;
• Detect security updates in third-party dependencies;
• Measure test coverage: how much of your application’s features are covered by
automated tests.
Building these tests into your CI pipeline, measuring and improving the score in each is
a guaranteed way to maintain a high quality of your software.
A CI tool provides instant feedback to developers on whether the new code they wrote
works, or introduces bugs or regression in quality. Mistakes caught early on are the
easiest to fix.
Published by Semaphore: CI/CD for teams that don’t like bottlenecks - semaphoreci.com 5
Continuous Integration best practices
ular languages on Linux and iOS, with the ability to run any Docker container that you
specify.
With the advantages of tight integration with GitHub and ability to model custom
pipelines that can communicate with any cloud endpoint, Semaphore is highly flexible.
Embracing the serverless computing model, your CI process scales automatically with
no time spent on queues. Your organization has nothing to maintain and pays based
on time spent on execution.
Whatever CI tool you choose, we recommend that you pick the one which maximizes
your organization’s productivity. Feature-wise, your CI provider should be a few steps
ahead of your current needs, so that you’re certain that it can support you as you grow.
You can consider all tools used within your build and test steps as your CI value chain.
This includes tools like code style and complexity analyzer, build and task automation
tool, unit and acceptance testing frameworks, browser testing engine, security and per-
formance testing tools, etc.
Choose tools which are widely adopted, are well documented and are actively main-
tained.
Wide adoption is reflected by a large number of package downloads (often in millions)
and open source contributors. Googling common use cases returns a solid number of
examples from credible sources.
Well documented tools are easy to get started with. A searchable documentation web-
site provides information on accomplishing more complex tasks. You will often find
books covering their use in depth.
Actively maintained tools have had their latest release recently, at least within the last
6 months. The last commit in source code happened less than a month ago. The best
tools evolve with the ecosystem and provide timely bug fixes and security updates.
Published by Semaphore: CI/CD for teams that don’t like bottlenecks - semaphoreci.com 6
Continuous Integration best practices
Parallelize tests. Start by splitting by type (eg. unit and integration), then adopt tools
that can parallelize each.
Have all developers commit code to master at least 10 times per day. Avoid long-
running feature branches which result in large merges. Build new features iteratively
and use feature flags to hide work-in-progress from end users.
Wait for tests to pass before opening a pull request. Keep in mind that a pull request
is by definition a call for another developer to review your code. Be mindful of their time.
Test in a clone of the production environment. You can define your CI environment
with a Docker image, and make the CI environment fully match production. An alterna-
tive is to customize the CI environment so that bugs due to difference with production
almost never happen.
Use CI to maintain your code. For example, run scheduled workflows to detect newer
versions of your libraries and upgrade them.
Keep track of key metrics: total CI build time (including queue time, which your CI tool
should maintain at zero) and how often your master is red.
Published by Semaphore: CI/CD for teams that don’t like bottlenecks - semaphoreci.com 7
Continuous Integration best practices
Published by Semaphore: CI/CD for teams that don’t like bottlenecks - semaphoreci.com 8