Have you ever ever imagined having the ability to get some particulars about how a lot your newest pull request elevated or decreased the whole code protection within the mission that you’re engaged on?
Now that is potential utilizing Bitrise, Github and a few scripts. Let’s get caught into it 👊🏽
- A Jacoco plugin to generate code protection out of your unit exams. For instance, I’ll point out some gradle duties that Android-Root-Protection-Plugin presents. This SDK permits using a multi-module mission and get both an general or a person module protection report.
- A Github repository linked with Bitrise.
- Admin permissions on Bitrise, so as to have the ability to configure your Workflows.
- Create a Comparator Workflow (unit_test_and_coverage_comparison). This workflow shall be in control of operating the exams, create the code protection of the PR department and it’ll execute a code protection comparability script, to then present these values comparability within the PR feedback.
- Configure the Bitrise PR Set off (linking the earlier Comparator Workflow), with a view to run a construct every time a PR is raised.
- Create a Code Protection Saver Workflow (unit_test_and_save_coverage). This workflow shall be in control of saving the newest code protection in Bitrise Secrets and techniques, after operating the unit exams and parse such worth from the code protection report.
- Configure the Bitrise Push Set off (linking the earlier Code Protection Saver Workflow), with a view to run a construct when the PR will get merged with important/grasp (or some other focused) department.
- Generate a Bitrise Private Entry Token to have the ability to execute some Bitrise API calls to entry the secrets and techniques from the scripts. Then set it up in your Bitrise Secrets and techniques, as a brand new variable (BITRISE_PERSONAL_ACCESS_TOKEN).
- Generate a Github Private entry token. It is going to be wanted by the Step that provides a message within the present PR. Then set it up in your Bitrise Secrets and techniques, as a brand new variable (GITHUB_BOT_CODE_COVERAGE).
- Create one other variable in your Bitrise Secrets and techniques (CODE_COVERAGE), to have the ability to save the code protection in some unspecified time in the future throughout the course of.
- Increase a PR on Github, wait till the construct passes the entire checks arrange on Bitrise. After which, take a look on the Github message generated in your PR. This message will comprise the code protection comparability 🤩
- Clone your Github repository.
- Configure your mission, if essential.
- Run the unit exams within the mission.
- Execute Jacoco gradle job to generate studies (i.e. -Pcoverage rootCoverageReport).
- Parse the code protection share from the report file already generated.
- Get the worth, that comprises the important/grasp department code protection share.
- Set these two values within the setting variables supplied by Bitrise (env man).
- Use the Touch upon GitHub Pull Request (Bitrise Step), with a view to write a touch upon the given PR, with the 2 code protection percentages added to the setting variables. ⚠️ The very first time operating this, the worth obtained from the Bitrise Secrets and techniques, will be empty.
Code Protection Saver Workflow
- Clone your Github repository.
- Configure your mission if essential.
- Run the unit exams within the mission.
- Execute Jacoco gradle job to generate studies (i.e. -Pcoverage rootCoverageReport).
- Parse the code protection share from the report file already generated.
- Set that code protection share within the Secrets and techniques. This new worth shall be obtainable when a brand new PR is raised.