ADR: Introduce Code Coverage metric in deployment pipelines.
Decision Title
Introduce Code Coverage metric in deployment pipelines
Status
-
Proposed -
Trialing -
Under review -
Approved -
Retired
Context & Scope
Currently build pipeline normally consists of following jobs
- Build
- Azure Code Coverage
- Scan
- Containerize
- Deploy
- Integration
- Additional steps specific to services.
For code changes to be deployed, they are dependent on build job for all cloud providers.
To ensure better code quality, we propose to introduce an additional step in build job. This step will help us to maintain code coverage percentage for core module and if at any given time the code coverage goes below threshold levels, we can stop the build further.
We will keep this as a continuous process. We can start with a comparatively low value as coverage threshold and keep updating the value as our code coverage improves with time.
Decision
- Add code coverage plugin to core module.
- Add coverage test step in build job to check code coverage values against specified threshold value.
- If code coverage limit is not met, break the pipeline.
Consequences
If code coverage threshold is not met for any branch the build will stop with appropriate exit code and output message.
Rationale
This will help us to maintain consistent code coverage metrics across the services and in turn help us to enhance overall code quality.
Example
- I have added jacoco plugin for measuring code coverage in azure module pom.xml
- I have added code coverage step for azure module. azure_code_coverage
- Updated deploy step for azure to verify code coverage metric before proceeding. azure_deploy_step
I have also updated service's gitlab-ci.yml file for threshold value gitlab-ci.yml
The final pipeline consists of azure_code_coverage step to measure code coverage metric and deploy step checks for this metric >= threshold value passed in gitlab-ci.yml file. If this condition is true build proceeds as expected, else fails and deploy stops to proceed further. Sample Pipeline