Skip to content

Commit

Permalink
Show coverage of the Changed Files (Diff) (#56)
Browse files Browse the repository at this point in the history
* Checking information exposed by github for the changed files

* Updating the index.js

* Finding the modified line numbers from the patch

* Logging the changedLines

* Modifying the changedLines logs

* Finished the logic to get changed line numbers for files

* Updating all tests

* Parsing line coverage information from jacoco report

* Sharing constants between tests

* Making process.js use getFilesWithCoverage but with same functionality

* Adding line information to the result files

* Adding line number to the line object

* Adding coverageDifference to Files Table

* Building index.js

* Fixing the 'instruction' undefined issue

* Experimenting with design for the coverage diff

* Removing the parenthesis for the coverage diff element

* Left align the Coverage column

* Remove the coverage information from column header

* Updating TestData (tests are not yet updated)

* Fixed tests

* Fixed more tests

* Logging patch to test

* Fixing all tests

* Adding coverage diff for module table

* Updating tests

* Refactoring

* Correcting the module coverage diff

* Adding coverage diff to project table

* Coverage diff percentage was not multiplied by 100

* Left align all Coverage columns

* Left align all Coverage columns

* Show status column only if min-coverage input is available

* Fixing the status hide logic for all rows

* Revert "Fixing the status hide logic for all rows"

This reverts commit 15e7995.

* Revert "Show status column only if min-coverage input is available"

This reverts commit 9905a6c.

* Update default value of the min coverage

* Using coverageDiff for status calculation in Files Table

* Using coverageDiff for status calculation in Modules Table

* Adding the Changed Files row

* Update README.md

* Adding space between overallTable and the following table

* Removed the getOverallCoverage method

* Refactor: Added overall block at project level

* Refactor: Added overall block at module level

* Refactor: Added overall block at file level

* Refactor: Added changed block at file level

* Refactor: Added changed block at module level

* Refactor: Added changed block at project level

* Refactor: Removed sumReducer logic in render.js

* Content rename

* Refactor: Passing minCoverage object to getPRComment

* Using changedFiles coverage instead of the dip for calculating status

* Updating screenshots

* Update README.md

* Update README.md
  • Loading branch information
thsaravana committed Jul 30, 2023
1 parent 61088be commit 963d839
Show file tree
Hide file tree
Showing 20 changed files with 2,672 additions and 1,206 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![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 modules, files and for the entire project.
modified modules, files and the overall project. You can view the coverage of just the changed files in your pull request.

## Usage

Expand All @@ -18,8 +18,8 @@ for [Creating a workflow file](https://help.github.com/en/articles/configuring-a

- `paths` - [**required**] Comma separated paths of the generated jacoco xml files (supports wildcard glob pattern)
- `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
- `min-coverage-overall` - [*optional* {default: 80%}] The minimum code coverage that is required to pass for overall project
- `min-coverage-changed-files` - [*optional* {default: 80%}] The minimum code coverage that is required to pass for changed files
- `update-comment` - [*optional* {default: false}] If true, updates the previous coverage report comment instead of creating new one.
Requires `title` to work properly
- `title` - [*optional*] Title for the Pull Request comment
Expand Down Expand Up @@ -71,9 +71,9 @@ jobs:
```

<br>
<img src="/preview/single-module-screenshot.png" alt="single module screenshot" title="single module screenshot" width="500" />
<img src="/preview/single-module-screenshot.png" alt="single module screenshot" title="single module screenshot" width="700" />
<br>
<img src="/preview/multi-module-screenshot.png" alt="multi-module screenshot" title="multi-module screenshot" width="500" />
<img src="/preview/multi-module-screenshot.png" alt="multi-module screenshot" title="multi-module screenshot" width="700" />

### Example Project

Expand Down
4 changes: 2 additions & 2 deletions __tests__/__fixtures__/aggregate-report.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
<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="5" 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" />
Expand Down Expand Up @@ -279,4 +279,4 @@
<counter type="COMPLEXITY" missed="1271" covered="2645"/>
<counter type="METHOD" missed="683" covered="2194"/>
<counter type="CLASS" missed="40" covered="353"/>
</report>
</report>
143 changes: 92 additions & 51 deletions __tests__/__fixtures__/multi_module/appCoverage.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE report PUBLIC
"-//JACOCO//DTD Report 1.1//EN" "report.dtd">
"-//JACOCO//DTD Report 1.1//EN" "report.dtd">
<report name="app">
<sessioninfo dump="1630475844131" id="FWS-CHE-LT-2648-93125f81" start="1630475843423" />
<sessioninfo dump="1690537657266" id="Admins-MBP-102-fd20ba3e" start="1690537656947" />
<package name="com/madrapps/playground">
<class name="com/madrapps/playground/MainViewModel" sourcefilename="MainViewModel.kt">
<method name="&lt;init&gt;" desc="()V" line="5">
Expand All @@ -16,41 +16,49 @@
<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">
<method name="verifyAccess1" 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" />
<method name="verifyPassword" desc="(Ljava/lang/String;)Z" line="16">
<counter covered="0" missed="11" type="INSTRUCTION" />
<counter covered="0" missed="2" type="BRANCH" />
<counter covered="0" missed="1" type="LINE" />
<counter covered="0" missed="2" type="COMPLEXITY" />
<counter covered="0" missed="1" type="METHOD" />
</method>
<counter covered="10" missed="18" type="INSTRUCTION" />
<counter covered="0" missed="2" type="BRANCH" />
<counter covered="2" missed="2" type="LINE" />
<counter covered="2" missed="3" type="COMPLEXITY" />
<counter covered="2" missed="2" type="METHOD" />
<counter covered="1" missed="0" type="CLASS" />
</class>
<class name="com/madrapps/playground/MainActivity$onCreate$$inlined$viewModels$default$2"
sourcefilename="ActivityViewModelLazy.kt">
sourcefilename="ActivityViewModelLazy.kt">
<method name="invoke" desc="()Landroidx/lifecycle/ViewModelStore;" line="47">
<counter covered="0" missed="9" type="INSTRUCTION" />
<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="0" missed="9" type="INSTRUCTION" />
<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" />
<counter covered="0" missed="1" type="CLASS" />
</class>
<class name="com/madrapps/playground/MainActivity$onCreate$$inlined$viewModels$default$1"
sourcefilename="ActivityViewModelLazy.kt">
sourcefilename="ActivityViewModelLazy.kt">
<method name="invoke" desc="()Landroidx/lifecycle/ViewModelProvider$Factory;" line="44">
<counter covered="0" missed="9" type="INSTRUCTION" />
<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="0" missed="9" type="INSTRUCTION" />
<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" />
Expand All @@ -64,34 +72,28 @@
<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="91" 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" />
<method name="onCreate$lambda$0"
desc="(Lkotlin/Lazy;)Lcom/madrapps/playground/MainViewModel;" line="18">
<counter covered="0" missed="6" 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="100" 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="3" type="COMPLEXITY" />
<counter covered="0" missed="3" 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" />
<line cb="0" ci="0" mb="0" mi="7" nr="44" />
<line cb="0" ci="0" mb="0" mi="7" nr="47" />
<counter covered="0" missed="14" type="INSTRUCTION" />
<counter covered="0" missed="2" type="LINE" />
<counter covered="0" missed="2" type="COMPLEXITY" />
<counter covered="0" missed="2" type="METHOD" />
Expand All @@ -102,40 +104,79 @@
<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="10" nr="18" />
<line cb="0" ci="0" mb="0" mi="14" nr="19" />
<line cb="0" ci="0" mb="0" mi="14" 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="14" nr="24" />
<line cb="0" ci="0" mb="0" mi="14" 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="14" nr="29" />
<line cb="0" ci="0" mb="0" mi="1" nr="30" />
<counter covered="0" missed="85" type="INSTRUCTION" />
<counter covered="0" missed="100" 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="3" type="COMPLEXITY" />
<counter covered="0" missed="3" 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" />
<line cb="0" ci="0" mb="2" mi="8" nr="16" />
<counter covered="10" missed="18" type="INSTRUCTION" />
<counter covered="0" missed="2" type="BRANCH" />
<counter covered="2" missed="2" type="LINE" />
<counter covered="2" missed="3" type="COMPLEXITY" />
<counter covered="2" missed="2" 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="10" missed="132" type="INSTRUCTION" />
<counter covered="0" missed="2" type="BRANCH" />
<counter covered="2" missed="17" type="LINE" />
<counter covered="2" missed="8" 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>
<package name="com/madrapps/playground/events">
<class name="com/madrapps/playground/events/OnClickEvent" sourcefilename="OnClickEvent.kt">
<method name="&lt;init&gt;" desc="()V" line="3">
<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="onClick" desc="()V" line="7">
<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="4" 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="1" type="CLASS" />
</class>
<sourcefile name="OnClickEvent.kt">
<line cb="0" ci="0" mb="0" mi="3" nr="3" />
<line cb="0" ci="0" mb="0" mi="1" nr="7" />
<counter covered="0" missed="4" 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="1" type="CLASS" />
</sourcefile>
<counter covered="0" missed="4" 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="1" type="CLASS" />
</package>
<counter covered="10" missed="136" type="INSTRUCTION" />
<counter covered="0" missed="2" type="BRANCH" />
<counter covered="2" missed="19" type="LINE" />
<counter covered="2" missed="10" type="COMPLEXITY" />
<counter covered="2" missed="9" type="METHOD" />
<counter covered="1" missed="4" type="CLASS" />
</report>

0 comments on commit 963d839

Please sign in to comment.