Making code coverage easy to see with the Codecov CircleCI orb
Developer Relations Lead at Codecov
Our goal at Codecov is to provide relevant, timely data to help developers and teams understand and improve their code’s quality. We do this by providing highly integrated tools to group, merge, archive, and compare coverage reports. Using Codecov, an engineering team can create a good testing culture while seeing the impact of each new commit on overall coverage metrics.
Codecov began as a project to solve one developer’s personal frustration with being unable to quickly and easily see what code was being tested. From there, it has grown into a tool that is used by everyone from independent developers to open source projects, from small agencies to massive enterprises. No matter the project or the team size, everyone can benefit from a better understanding of their code’s quality, and we believe that code coverage is an essential part of that understanding.
What does our orb do?
Integrating Codecov with a CI/CD provider ensures that code coverage becomes foundational in how you manage and deploy software. It takes code coverage from an activity a single developer may run in their terminal, to a shared, team-level activity that can be initiated, viewed, and commented on by every developer on your team. Teams can also rely on code coverage to perform checks on each PR, ensuring that no PR will be merged into your master branch unless coverage requirements are met.
After integrating Codecov into a CI/CD workflow, teams can rely on code coverage as a tool to help improve the quality of their test coverage and overall codebase. Codecov’s features provides deep insight into a project’s test coverage and actionable routes (pull request comments, checks, etc.) to improve code quality. Further, when teams incorporate Codecov into their CI/CD pipelines, it’s natural to see code coverage improve over time.
Codecov’s primary purpose is to take your coverage reports and provide easy-to-see, easy-to-digest metrics. CircleCI users now have the Codecov orb that makes it simple to upload coverage reports to Codecov, which gets you to your metrics that much quicker.
Adding an upload of your coverage report to a CircleCI workflow
Using the Codecov orb is as simple as adding in a few lines to your CircleCI config file (.circleci/config.yml
).
Here is an example of uploading your code coverage reports to Codecov:
version: 2.1
orbs:
codecov: codecov/codecov@1.0.2
jobs:
build:
steps:
- codecov/upload:
file: {{ coverage_report_filepath }}
Note that if you have multiple files, you will need to create a step for each file. You can also specify these other optional parameters:
- conf - Used to specify the location of the
.codecov.yml
config file - flags - Flag the upload to group coverage metrics (e.g. unittests, integration, ui, chrome)
- token - Set the private repository token (defaults to environment variable
$CODECOV_TOKEN
) - upload_name - Custom defined name of the upload
Wrapping up
We are very excited to be able to partner with CircleCI and bring code coverage quickly and easily to CircleCI users. At Codecov, we believe that integration among the tools that developers use on a daily basis frees developers to focus on what really matters, rather than trying to wrangle disparate platforms. To that end, we are extremely proud to work with CircleCI and be part of this new program.
Tom Hu works with developers to build and maintain high-quality code and be champions of code coverage in their organizations and networks. Before Codecov, Tom worked for 7 years as a software engineer in all kinds of companies, ranging from pre-funded startups to Fortune 500 companies. In his personal life, Tom is an avid rock climber and cocktail enthusiast.