Paying homage to the saying “You can’t improve what you haven’t measured,” this blog post will cover some crucial metrics to leverage when improving your Continuous Integration (CI) process and CI pipelines.
How Is DevOps Performance Measured?
After six years’ worth of surveys, the DevOps Research and Assessments (DORA) team identified four key measures for DevOps performance. These four DevOps metrics include deployment frequency, mean lead time for changes, mean time to recover, and change failure rate. By tracking these metrics, teams can better understand their DevOps challenges and take data-driven action.
These metrics align with various DevOps characteristics, including speed, repeatability, visibility, and reliability.
What Does DevOps Mean to Your Organization?
Answering this question is a great way to identify what capabilities and implementations should take priority. Many DevOps teams choose to focus on a cloud or container-native strategy involving Kubernetes, automation, or security. Continuous Integration and Continuous Delivery (CI/CD) is a great place to start to secure a foundation for delivery velocity, feedback loops, and other DevOps capabilities.
Continuous Integration (CI) is a great starting point for many teams to focus on because DevOps relies on delivering well-defined and well-functioning software-developed features. The remainder of this post will go into further detail on improving your Continuous Integration process.
Identifying Your Challenges in Continuous Integration
To identify your challenges in Continuous Integration, we need to define what is Continuous Integration and what does the process involve.
Continuous Integration (CI) is an automated process for continually integrating software development changes. CI processes automate the building, testing, and validation of source code. By working with CI capabilities, developers can accelerate their code release cycles, and facilitate quick feedback, making it less likely to run into long feature development cycles and the challenges of merge conflicts.
The typical CI pipeline automates the following workflow:
- A developer pushes changes into a version-controlled repository and triggers the CI pipeline
- The CI server fetches changes to the application code (sometimes static code analysis is done here)
- The CI server builds the code, creating a compiled executable version of the application
- The CI server launches the test suite
- After the tests run, the CI server fails or passes the build to be tagged, scanned, and deployed
- Notification of the success or failure is sent to the development team
For many teams, a development cycle begins with well-defined requirements that are often sized by story points. Development team members then work through sprints or increments of time to deliver new features or enhancements to existing features. During a sprint, developers will commit and push changes to a code repository for versioning. This often triggers a CI pipeline to build the code-based and launch test processes. These suites of tests can include unit tests, load tests, and other forms of performance testing.
After the tests pass and the CI pipeline succeeds, the CI pipeline solution will produce a packaged artifact suitable for a deployment or CD pipeline. If the build process fails, or if there are failed tests, developers will review their broken builds to make bug fixes and code changes. While this workflow may change for special cases, teams should leverage their CI pipeline as the source of truth for building packaged and well-tested artifacts.
Based on this CI workflow, developers may have particular challenges in version control, building, testing, CI governance, or continuous feedback. It may be worth it for you to read our article, “What is Continuous Integration?” if you’d like to learn more about CI.
Now that we understand CI and the areas for improvement, let’s discuss the KPIs and metrics that will enable CI improvements.
Key Continuous Integration Performance Metrics
The following sections will discuss and define four metrics for improving your CI performance and process.
Code quality is a quantifiable measure for improving your Continuous Integration performance. The better the code quality, the more likely it will pass the CI process. In some cases, measuring code quality and setting it as a standard can also improve your software delivery. Static code analysis tools provide metrics on new code, such as the number of duplicated lines of code, number of code vulnerabilities, and the level of regression in code quality.
The goal in tracking code quality is to reduce the number of broken builds and to enforce a higher standard of code development in teams. This also encourages developers to debug and test their code before making a code commit. Using CI resources to build code that hasn’t been tested can be dangerous if, for example, testing and quality gates are not well defined in the CI pipeline.
Code Coverage and Test Coverage
Code coverage is the percentage of code that is covered by test cases through testing frameworks and suites. Test coverage is a percentage or measure of how many software functions and capabilities are covered by the test suite. Code coverage and test coverage both relate to testing methodologies that can improve code quality and, therefore, your CI process.
When considering code coverage improvements, you can consider the subtypes of code coverage, including branch, statement, function, and line coverage. The benefits of code coverage include the ability for teams to detect bugs in the program flow. It is also a simple way of enhancing your overall code quality and strength of checks. This metric is easy to collect with any open-source or vendor code coverage tool, such as SonarQube.
Like code coverage, test coverage has various practices, including unit, functional, integration, and acceptance testing. These tests focus on the business positions and value of the software. This means that test cases can be created before or without the knowledge of the code itself (this is known as black-box testing). These tests, however, do take more tests and effort to assess and build.
Defect Escape Rate
Software delivery can be a major challenge even for organizations leveraging DevOps and Agile methodologies. The defect escape rate is a measure of the number of bugs and defects reported by end-users or customers of a product. Here are some practices to consider when improving or tracking this metric:
- Introducing code profilers and interactive debuggers to catch potential mistakes during development.
- Introducing more capabilities into the testing strategy, including automated tests and manual quality assurance
- Finding defects in the QA environment
- Finding defects during and after production deployments via load testing and application metrics.
Lead Time to Deploy
Lead time to deploy is the total amount of time it takes to go from code commit to the same code running successfully in a production environment. This is a good metric to track for teams who want to understand how they can better streamline CI/CD and increase their delivery potential. There are many pitfalls in going from code commit to production, which can involve manual configuration changes or deployments, idle time wasted between processes, and lack of overall collaboration and visibility into the process.
Lead time allows teams to understand better the average amount of time needed to get changes to production and where to improve the process by introducing more automation or tooling to alleviate toil.
Improve Your Continuous Integration Process With Harness
Improving your Continuous Integration performance through metrics means understanding your CI process, your development team, and your developer tools and runtimes. Tracking, monitoring, and gaining insights into the performance and quality metrics shared today can be difficult. But CI/CD tools and platforms today solve this. If you’d like to succeed in your CI/CD process and gain continuous insights, try Harness, the intelligent software delivery platform, today.