Skip to content

Commit

Permalink
Merge pull request #5 from Madrapps/v1.2
Browse files Browse the repository at this point in the history
v1.2
  • Loading branch information
thsaravana committed Sep 3, 2021
2 parents ba3d337 + 5e258a2 commit fd4800e
Show file tree
Hide file tree
Showing 14 changed files with 1,399 additions and 663 deletions.
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
# jacoco-report

[![Tests](https://github.com/Madrapps/jacoco-report/actions/workflows/check.yml/badge.svg)](https://github.com/Madrapps/jacoco-report/actions/workflows/check.yml)

A Github action that publishes the JaCoCo report as a comment in the Pull Request with customizable pass percentage for modified files and for the entire project.

## Usage

### Pre-requisites

Create a workflow `.yml` file in your repositories `.github/workflows` directory. An [example workflow](#example-workflow) is available below. For more information, reference the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file).

### Inputs

* `path` - [**required**] Path of the generated xml file.
* `token` - [**required**] Github personal token to add commits to Pull Request
* `min-coverage-overall` - [*optional*] The minimum code coverage that is required to pass for overall project
* `min-coverage-changed-files` - [*optional*] The minimum code coverage that is required to pass for changed files
- `paths` - [**required**] Comma separated paths of the generated jacoco xml files.
- `token` - [**required**] Github personal token to add commits to Pull Request
- `min-coverage-overall` - [*optional*] The minimum code coverage that is required to pass for overall project
- `min-coverage-changed-files` - [*optional*] The minimum code coverage that is required to pass for changed files
- `title` - [*optional*] Title for the Pull Request comment

### Outputs

* `coverage-overall` - The overall coverage of the project
* `coverage-changed-files` - The total coverage of all changed files
- `coverage-overall` - The overall coverage of the project
- `coverage-changed-files` - The total coverage of all changed files

### Example Workflow

Expand All @@ -44,19 +47,23 @@ jobs:
- name: Add coverage to PR
id: jacoco
uses: madrapps/jacoco-report@v1.1
uses: madrapps/jacoco-report@v1.2
with:
path: ${{ github.workspace }}/build/reports/jacoco/testCoverage/testCoverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 40
min-coverage-changed-files: 60
```

<br>
<img src="/preview/screenshot.png" alt="output screenshot" title="output screenshot" width="500" />

### Example Project
For a working project refer to [jacoco-playgound](https://github.com/thsaravana/jacoco-playground) project. Check out the PR's in

For a working project refer to [jacoco-playgound](https://github.com/thsaravana/jacoco-playground). Check out the PR's in
the project to get an idea on how the report is shown on a pull request comment.
For multi module gradle project, refer [jacoco-android-playground](https://github.com/thsaravana/jacoco-android-playground)

## License

The scripts and documentation in this project are released under the [MIT License](LICENSE)
141 changes: 141 additions & 0 deletions __tests__/__fixtures__/multi_module/appCoverage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE report PUBLIC
"-//JACOCO//DTD Report 1.1//EN" "report.dtd">
<report name="app">
<sessioninfo dump="1630475844131" id="FWS-CHE-LT-2648-93125f81" start="1630475843423" />
<package name="com/madrapps/playground">
<class name="com/madrapps/playground/MainViewModel" sourcefilename="MainViewModel.kt">
<method name="&lt;init&gt;" desc="()V" line="5">
<counter covered="3" missed="0" type="INSTRUCTION" />
<counter covered="1" missed="0" type="LINE" />
<counter covered="1" missed="0" type="COMPLEXITY" />
<counter covered="1" missed="0" type="METHOD" />
</method>
<method name="validate" desc="(Ljava/lang/String;)Z" line="8">
<counter covered="7" missed="0" type="INSTRUCTION" />
<counter covered="1" missed="0" type="LINE" />
<counter covered="1" missed="0" type="COMPLEXITY" />
<counter covered="1" missed="0" type="METHOD" />
</method>
<method name="verifyAccess" desc="(Ljava/lang/String;)Z" line="12">
<counter covered="0" missed="7" type="INSTRUCTION" />
<counter covered="0" missed="1" type="LINE" />
<counter covered="0" missed="1" type="COMPLEXITY" />
<counter covered="0" missed="1" type="METHOD" />
</method>
<counter covered="10" missed="7" type="INSTRUCTION" />
<counter covered="2" missed="1" type="LINE" />
<counter covered="2" missed="1" type="COMPLEXITY" />
<counter covered="2" missed="1" type="METHOD" />
<counter covered="1" missed="0" type="CLASS" />
</class>
<class name="com/madrapps/playground/MainActivity$onCreate$$inlined$viewModels$default$2"
sourcefilename="ActivityViewModelLazy.kt">
<method name="invoke" desc="()Landroidx/lifecycle/ViewModelStore;" line="47">
<counter covered="0" missed="9" type="INSTRUCTION" />
<counter covered="0" missed="1" type="LINE" />
<counter covered="0" missed="1" type="COMPLEXITY" />
<counter covered="0" missed="1" type="METHOD" />
</method>
<counter covered="0" missed="9" type="INSTRUCTION" />
<counter covered="0" missed="1" type="LINE" />
<counter covered="0" missed="1" type="COMPLEXITY" />
<counter covered="0" missed="1" type="METHOD" />
<counter covered="0" missed="1" type="CLASS" />
</class>
<class name="com/madrapps/playground/MainActivity$onCreate$$inlined$viewModels$default$1"
sourcefilename="ActivityViewModelLazy.kt">
<method name="invoke" desc="()Landroidx/lifecycle/ViewModelProvider$Factory;" line="44">
<counter covered="0" missed="9" type="INSTRUCTION" />
<counter covered="0" missed="1" type="LINE" />
<counter covered="0" missed="1" type="COMPLEXITY" />
<counter covered="0" missed="1" type="METHOD" />
</method>
<counter covered="0" missed="9" type="INSTRUCTION" />
<counter covered="0" missed="1" type="LINE" />
<counter covered="0" missed="1" type="COMPLEXITY" />
<counter covered="0" missed="1" type="METHOD" />
<counter covered="0" missed="1" type="CLASS" />
</class>
<class name="com/madrapps/playground/MainActivity" sourcefilename="MainActivity.kt">
<method name="&lt;init&gt;" desc="()V" line="10">
<counter covered="0" missed="3" type="INSTRUCTION" />
<counter covered="0" missed="1" type="LINE" />
<counter covered="0" missed="1" type="COMPLEXITY" />
<counter covered="0" missed="1" type="METHOD" />
</method>
<method name="onCreate" desc="(Landroid/os/Bundle;)V" line="13">
<counter covered="0" missed="71" type="INSTRUCTION" />
<counter covered="0" missed="12" type="LINE" />
<counter covered="0" missed="1" type="COMPLEXITY" />
<counter covered="0" missed="1" type="METHOD" />
</method>
<method name="onCreate$lambda-0"
desc="(Lkotlin/Lazy;)Lcom/madrapps/playground/MainViewModel;" line="18">
<counter covered="0" missed="10" type="INSTRUCTION" />
<counter covered="0" missed="1" type="LINE" />
<counter covered="0" missed="1" type="COMPLEXITY" />
<counter covered="0" missed="1" type="METHOD" />
</method>
<method name="&lt;clinit&gt;" desc="()V" line="18">
<counter covered="0" missed="1" type="INSTRUCTION" />
<counter covered="0" missed="1" type="LINE" />
<counter covered="0" missed="1" type="COMPLEXITY" />
<counter covered="0" missed="1" type="METHOD" />
</method>
<counter covered="0" missed="85" type="INSTRUCTION" />
<counter covered="0" missed="13" type="LINE" />
<counter covered="0" missed="4" type="COMPLEXITY" />
<counter covered="0" missed="4" type="METHOD" />
<counter covered="0" missed="1" type="CLASS" />
</class>
<sourcefile name="ActivityViewModelLazy.kt">
<line cb="0" ci="0" mb="0" mi="9" nr="44" />
<line cb="0" ci="0" mb="0" mi="9" nr="47" />
<counter covered="0" missed="18" type="INSTRUCTION" />
<counter covered="0" missed="2" type="LINE" />
<counter covered="0" missed="2" type="COMPLEXITY" />
<counter covered="0" missed="2" type="METHOD" />
<counter covered="0" missed="2" type="CLASS" />
</sourcefile>
<sourcefile name="MainActivity.kt">
<line cb="0" ci="0" mb="0" mi="3" nr="10" />
<line cb="0" ci="0" mb="0" mi="3" nr="13" />
<line cb="0" ci="0" mb="0" mi="3" nr="14" />
<line cb="0" ci="0" mb="0" mi="2" nr="17" />
<line cb="0" ci="0" mb="0" mi="15" nr="18" />
<line cb="0" ci="0" mb="0" mi="10" nr="19" />
<line cb="0" ci="0" mb="0" mi="10" nr="20" />
<line cb="0" ci="0" mb="0" mi="4" nr="23" />
<line cb="0" ci="0" mb="0" mi="10" nr="24" />
<line cb="0" ci="0" mb="0" mi="10" nr="25" />
<line cb="0" ci="0" mb="0" mi="4" nr="28" />
<line cb="0" ci="0" mb="0" mi="10" nr="29" />
<line cb="0" ci="0" mb="0" mi="1" nr="30" />
<counter covered="0" missed="85" type="INSTRUCTION" />
<counter covered="0" missed="13" type="LINE" />
<counter covered="0" missed="4" type="COMPLEXITY" />
<counter covered="0" missed="4" type="METHOD" />
<counter covered="0" missed="1" type="CLASS" />
</sourcefile>
<sourcefile name="MainViewModel.kt">
<line cb="0" ci="3" mb="0" mi="0" nr="5" />
<line cb="0" ci="4" mb="0" mi="0" nr="8" />
<line cb="0" ci="0" mb="0" mi="4" nr="12" />
<counter covered="10" missed="7" type="INSTRUCTION" />
<counter covered="2" missed="1" type="LINE" />
<counter covered="2" missed="1" type="COMPLEXITY" />
<counter covered="2" missed="1" type="METHOD" />
<counter covered="1" missed="0" type="CLASS" />
</sourcefile>
<counter covered="10" missed="110" type="INSTRUCTION" />
<counter covered="2" missed="16" type="LINE" />
<counter covered="2" missed="7" type="COMPLEXITY" />
<counter covered="2" missed="7" type="METHOD" />
<counter covered="1" missed="3" type="CLASS" />
</package>
<counter covered="10" missed="110" type="INSTRUCTION" />
<counter covered="2" missed="16" type="LINE" />
<counter covered="2" missed="7" type="COMPLEXITY" />
<counter covered="2" missed="7" type="METHOD" />
<counter covered="1" missed="3" type="CLASS" />
</report>
83 changes: 83 additions & 0 deletions __tests__/__fixtures__/multi_module/mathCoverage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE report PUBLIC
"-//JACOCO//DTD Report 1.1//EN" "report.dtd">
<report name="math">
<sessioninfo dump="1630475836741" id="FWS-CHE-LT-2648-dd5996a5" start="1630475831008" />
<package name="com/madrapps/math">
<class name="com/madrapps/math/MathOperation$MathOp" sourcefilename="MathOperation.kt" />
<class name="com/madrapps/math/MathOperation" sourcefilename="MathOperation.kt" />
<class name="com/madrapps/math/Arithmetic" sourcefilename="Math.kt">
<method name="&lt;init&gt;" desc="()V" line="3">
<counter covered="3" missed="0" type="INSTRUCTION" />
<counter covered="1" missed="0" type="LINE" />
<counter covered="1" missed="0" type="COMPLEXITY" />
<counter covered="1" missed="0" type="METHOD" />
</method>
<method name="add" desc="(II)I" line="6">
<counter covered="4" missed="0" type="INSTRUCTION" />
<counter covered="1" missed="0" type="LINE" />
<counter covered="1" missed="0" type="COMPLEXITY" />
<counter covered="1" missed="0" type="METHOD" />
</method>
<method name="subtract" desc="(II)I" line="10">
<counter covered="4" missed="0" type="INSTRUCTION" />
<counter covered="1" missed="0" type="LINE" />
<counter covered="1" missed="0" type="COMPLEXITY" />
<counter covered="1" missed="0" type="METHOD" />
</method>
<method name="multiply" desc="(II)I" line="14">
<counter covered="4" missed="0" type="INSTRUCTION" />
<counter covered="1" missed="0" type="LINE" />
<counter covered="1" missed="0" type="COMPLEXITY" />
<counter covered="1" missed="0" type="METHOD" />
</method>
<method name="divide" desc="(II)I" line="18">
<counter covered="4" missed="0" type="INSTRUCTION" />
<counter covered="1" missed="0" type="LINE" />
<counter covered="1" missed="0" type="COMPLEXITY" />
<counter covered="1" missed="0" type="METHOD" />
</method>
<method name="modulo" desc="(II)I" line="22">
<counter covered="0" missed="4" type="INSTRUCTION" />
<counter covered="0" missed="1" type="LINE" />
<counter covered="0" missed="1" type="COMPLEXITY" />
<counter covered="0" missed="1" type="METHOD" />
</method>
<method name="area" desc="(II)I" line="26">
<counter covered="0" missed="4" type="INSTRUCTION" />
<counter covered="0" missed="1" type="LINE" />
<counter covered="0" missed="1" type="COMPLEXITY" />
<counter covered="0" missed="1" type="METHOD" />
</method>
<counter covered="19" missed="8" type="INSTRUCTION" />
<counter covered="5" missed="2" type="LINE" />
<counter covered="5" missed="2" type="COMPLEXITY" />
<counter covered="5" missed="2" type="METHOD" />
<counter covered="1" missed="0" type="CLASS" />
</class>
<sourcefile name="Math.kt">
<line cb="0" ci="3" mb="0" mi="0" nr="3" />
<line cb="0" ci="4" mb="0" mi="0" nr="6" />
<line cb="0" ci="4" mb="0" mi="0" nr="10" />
<line cb="0" ci="4" mb="0" mi="0" nr="14" />
<line cb="0" ci="4" mb="0" mi="0" nr="18" />
<line cb="0" ci="0" mb="0" mi="4" nr="22" />
<line cb="0" ci="0" mb="0" mi="4" nr="26" />
<counter covered="19" missed="8" type="INSTRUCTION" />
<counter covered="5" missed="2" type="LINE" />
<counter covered="5" missed="2" type="COMPLEXITY" />
<counter covered="5" missed="2" type="METHOD" />
<counter covered="1" missed="0" type="CLASS" />
</sourcefile>
<sourcefile name="MathOperation.kt" />
<counter covered="19" missed="8" type="INSTRUCTION" />
<counter covered="5" missed="2" type="LINE" />
<counter covered="5" missed="2" type="COMPLEXITY" />
<counter covered="5" missed="2" type="METHOD" />
<counter covered="1" missed="0" type="CLASS" />
</package>
<counter covered="19" missed="8" type="INSTRUCTION" />
<counter covered="5" missed="2" type="LINE" />
<counter covered="5" missed="2" type="COMPLEXITY" />
<counter covered="5" missed="2" type="METHOD" />
<counter covered="1" missed="0" type="CLASS" />
</report>
54 changes: 54 additions & 0 deletions __tests__/__fixtures__/multi_module/textCoverage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE report PUBLIC
"-//JACOCO//DTD Report 1.1//EN" "report.dtd">
<report name="text">
<sessioninfo dump="1630475840767" id="FWS-CHE-LT-2648-35e84bdf" start="1630475837836" />
<package name="com/madrapps/text">
<class name="com/madrapps/text/StringOperation" sourcefilename="StringOperation.java" />
<class name="com/madrapps/text/StringOp" sourcefilename="StringOp.java">
<method name="&lt;init&gt;" desc="()V" line="3">
<counter covered="3" missed="0" type="INSTRUCTION" />
<counter covered="1" missed="0" type="LINE" />
<counter covered="1" missed="0" type="COMPLEXITY" />
<counter covered="1" missed="0" type="METHOD" />
</method>
<method name="endsWith" desc="(Ljava/lang/String;Ljava/lang/String;)Z" line="7">
<counter covered="4" missed="0" type="INSTRUCTION" />
<counter covered="1" missed="0" type="LINE" />
<counter covered="1" missed="0" type="COMPLEXITY" />
<counter covered="1" missed="0" type="METHOD" />
</method>
<method name="startsWith" desc="(Ljava/lang/String;Ljava/lang/String;)Z" line="12">
<counter covered="4" missed="0" type="INSTRUCTION" />
<counter covered="1" missed="0" type="LINE" />
<counter covered="1" missed="0" type="COMPLEXITY" />
<counter covered="1" missed="0" type="METHOD" />
</method>
<counter covered="11" missed="0" type="INSTRUCTION" />
<counter covered="3" missed="0" type="LINE" />
<counter covered="3" missed="0" type="COMPLEXITY" />
<counter covered="3" missed="0" type="METHOD" />
<counter covered="1" missed="0" type="CLASS" />
</class>
<sourcefile name="StringOp.java">
<line cb="0" ci="3" mb="0" mi="0" nr="3" />
<line cb="0" ci="4" mb="0" mi="0" nr="7" />
<line cb="0" ci="4" mb="0" mi="0" nr="12" />
<counter covered="11" missed="0" type="INSTRUCTION" />
<counter covered="3" missed="0" type="LINE" />
<counter covered="3" missed="0" type="COMPLEXITY" />
<counter covered="3" missed="0" type="METHOD" />
<counter covered="1" missed="0" type="CLASS" />
</sourcefile>
<sourcefile name="StringOperation.java" />
<counter covered="11" missed="0" type="INSTRUCTION" />
<counter covered="3" missed="0" type="LINE" />
<counter covered="3" missed="0" type="COMPLEXITY" />
<counter covered="3" missed="0" type="METHOD" />
<counter covered="1" missed="0" type="CLASS" />
</package>
<counter covered="11" missed="0" type="INSTRUCTION" />
<counter covered="3" missed="0" type="LINE" />
<counter covered="3" missed="0" type="COMPLEXITY" />
<counter covered="3" missed="0" type="METHOD" />
<counter covered="1" missed="0" type="CLASS" />
</report>
Loading

0 comments on commit fd4800e

Please sign in to comment.