Code Monkey home page Code Monkey logo

jacoco-reporter's Introduction

JaCoCo Code Coverage Reporter v5.0

GitHub Action to Publish JaCoCo Format Code Coverage XML and attach it to the Workflow Run as a Check Run. You can even set threshold coverage percentage and fail the action.

Note:-

  • The scope of this project is limited to Report and Quality Gate. Any ideas are welcome.
  • I wrote this action as opensource during my vacation time.
  • This actions is used by hundreds of repos in my organization and many other prviate org repos.

Just one request. If you are using my Github Action, please STAR ⭐ it.

Samples

This Action allows you to specify your JaCoCo Code Coverage XML Path, and then generate a markdown report from the test results and then it attaches it to the Workflow Run as a Check Run. You can even set threshold coverage percentage and fail the action.

Here's a quick example of how to use this action in your own GitHub Workflows.

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    
      # generates coverage-report.md and publishes as checkrun
      - name: JaCoCo Code Coverage Report
        id: jacoco_reporter
        uses: PavanMudigonda/[email protected]
        with:
          coverage_results_path: jacoco-report/test.xml
          coverage_report_name: Coverage
          coverage_report_title: JaCoCo
          github_token: ${{ secrets.GITHUB_TOKEN }}
          skip_check_run: false
          minimum_coverage: 80
          fail_below_threshold: false
          publish_only_summary: false
      
      # Publish Coverage Job Summary  # Optional
      - name: Add Jacocoo report to workflow run summary
        run: |
          echo "| Outcome | Value |" >> $GITHUB_STEP_SUMMARY
          echo "| --- | --- |" >> $GITHUB_STEP_SUMMARY
          echo "| Code Coverage % | ${{ steps.jacoco_reporter.outputs.coverage_percentage }} |" >> $GITHUB_STEP_SUMMARY
          echo "| :heavy_check_mark: Number of Lines Covered | ${{ steps.jacoco_reporter.outputs.covered_lines }} |" >> $GITHUB_STEP_SUMMARY
          echo "| :x: Number of Lines Missed | ${{ steps.jacoco_reporter.outputs.missed_lines }} |" >> $GITHUB_STEP_SUMMARY
          echo "| Total Number of Lines | ${{ steps.jacoco_reporter.outputs.total_lines }} |" >> $GITHUB_STEP_SUMMARY
          
      # uploads the coverage-report.md artifact  # Optional
     - name: Upload Code Coverage Artifacts
        uses: actions/upload-artifact@v4
        with:
          name: code-coverage-report-markdown
          path: */coverage-results.md 
          retention-days: 1  

Inputs

This Action defines the following formal inputs.

Name Req Description
coverage_results_path true Path to the JaCoCo Code Coverage XML format file which will be used to generate a report.
coverage_report_name false The name of the code coverage report object that will be attached to the Workflow Run. Defaults to the name COVERAGE_RESULTS_<datetime> where <datetime> is in the form yyyyMMdd_hhmmss.
coverage_report_title false The title of the code coverage report that will be embedded in the report itself, which defaults to the same as the coverage_report_name input.
github_token false Input the GITHUB TOKEN Or Personal Access Token you would like to use. Defaults to the auto generated token. Recommended to use GitHub auto generated token ${{ secrets.GITHUB_TOKEN }}.
minimum_coverage false Input the minimum code coverage recommended.
fail_below_threshold false Set True to fail the action and False to let it pass.
skip_check_run false If true, will skip attaching the Coverage Result report to the Workflow Run using a Check Run. Useful if your report has 65k characters that is not accepted by Github REST and GraphQL APIs
publish_only_summary false If true, will publish only a summary table of the Coverage Result report to the Workflow Run using a Check Run. Useful if your full coverage report has 65k characters that is not accepted by Github REST and GraphQL APIs

Outputs

This Action defines the following formal outputs.

Name Description
coverage_percentage Coverage Percentage. Rounded to two decimals.
coveragePercentage Coverage Percentage. Rounded to two decimals.
coveragePercentageString Coverage Percentage. Rounded to two decimals with % symbol attached.
covered_lines Total Covered Lines
missed_lines Total missed Lines
total_lines Total Code Lines

Important Notes:-

  • When action is run in a pull request by dependabot or a forked repo (e.g. when bumping up a version in a pull request) this step will fail with the default github token ${{ secrets.GITHUB_TOKEN }} due to a lack of permissions. Resolution: on consumer side of workflow please add below

Possible fix The workflow needs check: write permissions.

permissions:
  checks: write
  1. Or Alternatively use Personal Authorization Token from GitHub.

Sample Screenshot (Full Coverage Report): publish_only_summary: false

image

Sample Screenshot (Summary Coverage Report): publish_only_summary: true

image

Sample Build Summary Screenshot

image

Sample PR Check Screenshot: only one Code Coverage Check Appears.

image

Sample Gradle Build Repo

https://github.com/PavanMudigonda/jacoco-playground

Sample Gradle Github Actions workflow

https://github.com/PavanMudigonda/jacoco-playground/blob/main/.github/workflows/coverage.yml

Sample Maven Build Repo

https://github.com/PavanMudigonda/java-maven-playground/

Sample Maven Github Actions workflow

https://github.com/PavanMudigonda/java-maven-playground/blob/master/.github/workflows/ci.yml

Sample Ant Build Repo

Sample Ant Github Actions workflow

PowerShell GitHub Action

This Action is implemented as a PowerShell GitHub Action.

Please checkout my Lines of Code Reporter

https://github.com/PavanMudigonda/lines-of-code-reporter/

jacoco-reporter's People

Contributors

pavanmudigonda avatar pavanmudigondatr avatar josephearl avatar github-actions[bot] avatar dependabot[bot] avatar

Stargazers

Joshua Davis avatar Pavlos Tzegiannakis avatar John Burns avatar  avatar Luis Filipe de Sousa avatar Pedro Palma avatar Ananya Shreya Soni avatar Pouria Alikhanifard avatar Bruno P. avatar  avatar Martin Reinhardt avatar Andy Nguyen avatar Jasmin Keller avatar Hwangbo Gyumin avatar  avatar Gustavo Tiengo avatar Caio Silva avatar Arnaud Bakyono  avatar SamuelSeblak avatar Alena Ryzhova avatar  avatar Aparna Chinya Ramachandra avatar  avatar Rodrigo Lopes  avatar Stanley Shen avatar Fabian Strathaus avatar  avatar Devonte Amos avatar Juan Barberio avatar 안검성(Geomseong Ahn) avatar Ignacio Pastor avatar Pavel S. avatar André Oliveira avatar Naoki Takahashi avatar Lukas Freiseis avatar Gregory Williams avatar Reinaldo Riant Kurnia Perdana avatar Andrey Grigorov avatar Oscar Westra van Holthe - Kind avatar Florian Wilhelm avatar Edward van de Vorst avatar  avatar Rafal Wisniewski avatar Robert Sigler avatar William Polinchak avatar Baptiste Candellier avatar  avatar  avatar Satheesh avatar Maximilian Schirm avatar Karl avatar  avatar Gang Cheng avatar  avatar  avatar  avatar  avatar Vyom Yadav avatar Nick Mancuso avatar Chandu Mudigonda avatar  avatar FMusher0011 avatar Thomas Happich avatar  avatar

Watchers

Gustavo Tiengo avatar Luis Filipe de Sousa avatar  avatar  avatar

jacoco-reporter's Issues

Unable to locate executable file: pwsh on Self-hosted GitHub Runner

Describe the bug
Error: Unable to locate executable file: pwsh. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.

I've used Self-Hosted Github Runner on my own Kubernetes Cluster (1.28)
Runner work on image - summerwind/actions-runner-dind:v2.311.0-ubuntu-20.04

    - name: Publish Test Coverage Report
      id: jacoco_report
      uses: PavanMudigonda/[email protected]
      with:
        coverage_results_path: ${{ github.workspace }}/build/jacoco.xml
        coverage_report_name: Coverage
        coverage_report_title: JaCoCo
        github_token: ${{ secrets.GITHUB_TOKEN }}
        skip_check_run: false
        minimum_coverage: 80
        fail_below_threshold: false
        publish_only_summary: false

Action Fails With "Resource not accessible by integration"

Describe the bug
When the action is run in a pull request by dependabot or a forked repo (e.g. when bumping up a version in a pull request) this step will fail with the default github token ${{ secrets.GITHUB_TOKEN }} due to a lack of permissions.

Error Log

##[group]Run PavanMudigonda/[email protected]
with:
  coverage_results_path: target/site/jacoco/jacoco.xml
  coverage_report_name: Coverage
  coverage_report_title: JaCoCo
  github_token: ***
  skip_check_run: false
  minimum_coverage: 80
  fail_below_threshold: true
  publish_only_summary: false
env:
  JAVA_HOME: /opt/hostedtoolcache/Java_Zulu_jdk/17.0.4-8/x64
  JAVA_HOME_17_X64: /opt/hostedtoolcache/Java_Zulu_jdk/17.0.4-8/x64
##[endgroup]
[command]/usr/bin/pwsh -f /home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v4.6/action.ps1
Module [GitHubActions] not found, INSTALLING...
Running from [/home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v4.6]

Creating test results space

/home/runner/work/ms-address/ms-address/_TMP

Publishing Report to GH Workflow

Building human-readable code-coverage report

VERBOSE: Resolving XML file relative to current directory: /home/runner/work/ms-address/ms-address/target/site/jacoco/jacoco.xml
VERBOSE: Resolving default XSL file: /home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v4.6/jacoco-report/jacocoxml2md.xsl
VERBOSE: Loaded XSL transformer
VERBOSE: Transforming XML to MD
Publishing Report to GH Workflow

Resolving REF 

Resolving PR REF

Resolved REF as 60b3899ccde75d92444458b181f8e69bbb46bdd0

Resolve Repo Full Name as suniastar/ms-address

Adding Check Run

Invoke-WebRequest: /home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v4.6/action.ps1:165
Line |
 165 |      Invoke-WebRequest -Headers $hdr $url -Method Post -Body ($bdy | C …
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | {"message":"Resource not accessible by
     | integration","documentation_url":"https://docs.github.com/rest/reference/checks#create-a-check-run"}

##[error]The process '/usr/bin/pwsh' failed with exit code 1

To Reproduce

  1. Create a workflow with this github action according to the readme (sample below)
  2. Let in run in a pull request by dependabot or a forked repo

Expected behavior
The action should not fail and append the report to the check

Workflow file

name: Pull Requests Checks

on:
  pull_request:
    branches: [ "dev" ]
  workflow_dispatch:

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/[email protected]
      - name: Set up Java JDK
        uses: actions/[email protected]
        with:
          java-version: '17'
          distribution: 'zulu'
      - name: Build with Maven
        run: mvn --batch-mode --update-snapshots test
      - name: JaCoCo Code Coverage Report
        uses: PavanMudigonda/[email protected]
        with:
          coverage_results_path: target/site/jacoco/jacoco.xml
          coverage_report_name: Coverage
          coverage_report_title: JaCoCo
          github_token: ${{ secrets.GITHUB_TOKEN }}
          skip_check_run: false
          minimum_coverage: 80
          fail_below_threshold: true
          publish_only_summary: false

Possible fix
The workflow needs check: write permissions.

permissions:
  checks: write

fail_below_threshold is not working correctly

Describe the bug
Fail below threshold is not working as expected - step fails, even if the threshold is below the code coverage for version 2.3

Additional context
The fix is in action.ps1 the variable coverage_value already holds the correct coverage percentage.

current version:

if ($coverage_value.coveragePercentage -lt $inputs.minimum_coverage -and $inputs.fail_below_threshold -eq "true") {
        $script:stepShouldFail = $true
    }

correct:

if ($coverage_value -lt $inputs.minimum_coverage -and $inputs.fail_below_threshold -eq "true") {
        $script:stepShouldFail = $true
    }

Should consider checking when $coveredLines is 0

Hi guys,

I'm new here.It seems like a bug as I mentioned below . When $coveredLines is 0, there is no place to check "$coveredLines" . Then it will raise an error about Attempted to divide by zero.
I think when $coveredLines is 0 , $coveragePercentage should be zero directly

$coveragePercentage = [math]::Round(100 - (($missedLines / $coveredLines) * 100))

The actions fails when the generated report is greater than 65535 characters long

Describe the bug
If the action is used with a coverage report that produces an output greater than 65535 characters long, then the action fails,.

Steps to reproduce the behavior:

  1. Supply a coverage report that is large (I used it with a report that was about 1.3Mb)
  2. Attempt run the github action
  3. The coverage reporter fails

Expected behavior
The report gets generated correctly

Screenshots
The report produces the following (partially redacted) log:

/usr/bin/pwsh -f /home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v2.4/action.ps1
Module [GitHubActions] not found, INSTALLING...
Running from [/home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v2.4]

Creating test results space

/home/runner/work/*******/_TMP

Publishing Report to GH Workflow

Covered Lines: 1125
Missed Lines: 7888
-601%


Building human-readable code-coverage report

VERBOSE: Resolving XML file relative to current directory: /home/runner/work/******//app/build/reports/kover/project-xml/report.xml
VERBOSE: Resolving default XSL file: /home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v2.4/jacoco-report/jacocoxml2md.xsl
VERBOSE: Loaded XSL transformer
VERBOSE: Transforming XML to MD
Publishing Report to GH Workflow

Resolving REF

Resolving PR REF

Resolved REF as 56ff9c6acff80bd6a0077cdf30966a15c8a452ec

Resolve Repo Full Name as **********

Adding Check Run

Invoke-WebRequest: /home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v2.4/action.ps1:112
Line |
 112 |      Invoke-WebRequest -Headers $hdr $url -Method Post -Body ($bdy | C …
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | {"message":"Invalid request.\n\nOnly 65535 characters are
     | allowed; 76386 were
     | supplied.","documentation_url":"https://docs.github.com/rest/reference/checks#create-a-check-run"}

Error: The process '/usr/bin/pwsh' failed with exit code 1

Regression: build failure when upgrading from v4.9 to v5.0

Regression Summary

The GitHub Action below works with v4.9, but fails with v5.0.

The action:

name: CI
on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
  workflow_dispatch:
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Publish Test Coverage Results
        # noinspection SpellCheckingInspection
        uses: PavanMudigonda/[email protected]
        with:
          coverage_results_path: 'target/site/jacoco/jacoco.xml'
          coverage_report_title: 'Test Coverage Results'
          coverage_report_name: 'Test-Coverage-Results'
          github_token: ${{ secrets.GITHUB_TOKEN }}

The error:

Error: Unable to process file command 'output' successfully.
Error: Invalid format '# Coverage Report: Test Coverage Results'

With v4.9, the build successfully publishes the code coverage results.

Cannot bind coveragePercentageString argument to parameter 'Value' in actions.ps1:244

Describe the bug
Cannot bind coveragePercentageString argument to parameter 'Value' in actions.ps1:244 because it is an empty string
https://github.com/PavanMudigonda/jacoco-reporter/blob/main/action.ps1#L244

To Reproduce
Steps to reproduce the behavior:

  1. Run 'JaCoCo Code Coverage Report'
  2. If one of the condition is true then coveragePercentageString is never set
    https://github.com/PavanMudigonda/jacoco-reporter/blob/main/action.ps1#L222
  3. Error: Cannot bind argument to parameter 'Value' because it is an empty string.

Expected behavior
coveragePercentageString shouldn't be an empty string

Screenshot
image

embedmissedlines.ps1 parameter 'Path' is null

Describe the bug
I get the following error using your action in the (public) repo https://github.com/ralfstuckert/openpdf-markdown

Run PavanMudigonda/[email protected]
  with:
    coverage_results_path: build/reports/jacoco/test/jacocoTestReport.xml
    coverage_report_name: Coverage
    coverage_report_title: JaCoCo
    github_token: ***
  env:
    JAVA_HOME: /opt/hostedtoolcache/Java_Microsoft_jdk/17.0.10/x6[4](https://github.com/ralfstuckert/openpdf-markdown/actions/runs/8478275832/job/23230361537#step:7:4)
    JAVA_HOME_17_X64: /opt/hostedtoolcache/Java_Microsoft_jdk/17.0.10/x64
    GRADLE_BUILD_ACTION_SETUP_COMPLETED: true
    GRADLE_BUILD_ACTION_CACHE_RESTORED: true
/usr/bin/pwsh -f /home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v[5](https://github.com/ralfstuckert/openpdf-markdown/actions/runs/8478275832/job/23230361537#step:7:5).0/action.ps1
Module [GitHubActions] not found, INSTALLING...
Running from [/home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v5.0]

Creating test results space

/home/runner/work/openpdf-markdown/openpdf-markdown/_TMP

Publishing Report to GH Workflow

Building human-readable code-coverage report

VERBOSE: Resolving XML file relative to current directory: /home/runner/work/openpdf-markdown/openpdf-markdown/build/reports/jacoco/test/jacocoTestReport.xml
VERBOSE: Resolving default XSL file: /home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v5.0/jacoco-report/jacocoxml2md.xsl
VERBOSE: Loaded XSL transformer
VERBOSE: Transforming XML to MD
embedmissedlines.ps1: /home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v5.0/action.ps1:67
Line |
  67 |          & "$PSScriptRoot/jacoco-report/embedmissedlines.ps1" -mdFile  …
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot bind argument to parameter 'Path' because it is null.
Error: The process '/usr/bin/pwsh' failed with exit code 1

I have debugged the run, the file _TMP/coverage-results.md passed as the parameter actually exists... I don't get it :-/

To Reproduce
Since my repo https://github.com/ralfstuckert/openpdf-markdown is public you may clone it, in order to reproduce it. As mentioned, the debug action is included in order to inspect the run.

Invalid format '# Coverage Report: Test coverage results'

Describe the bug
The job fails with the message:
Error: Unable to process file command 'output' successfully.
Error: Invalid format '# Coverage Report: Test coverage results'.

It used to work before but now it fails and not sure where the problem is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://github.com/AnswerConsulting/AnswerKing-Java/actions/runs/3446304463/jobs/5751041279
  2. Re-run the job and see the error.
  3. Scroll down to 'Publish test coverage results' step.

Expected behavior
I shouldn't fail with the output thing as it didn't complain about it before.

Screenshots
image

Desktop (please complete the following information):

  • OS: Ubuntu
  • Browser: Chrome
  • Version

GH Action failing when Covered Lines is 0

Describe the bug
/usr/bin/pwsh -f /home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v2.4/action.ps1
Module [GitHubActions] not found, INSTALLING...
Running from [/home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v2.4]

Creating test results space

/home/runner/work/Projet_devOPS/Projet_devOPS/_TMP

Publishing Report to GH Workflow

Covered Lines: 0
Missed Lines: 6
ParentContainsErrorRecordException: /home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v2.4/action.ps1:130
Line |
130 | $coveragePercentage = [math]::Round(100 - (($missedLines …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Attempted to divide by zero.

Error: The process '/usr/bin/pwsh' failed with exit code 1

To Reproduce
[Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error](https://github.com/ELCALVO/Projet_devOPS/runs/5990246809?check_suite_focus=true)

Expected behavior
Error when covered lines is 0

Screenshots
image

Additional context
Add any other context about the problem here.

Code coverage differs from JaCoCo report

Describe the bug

The code coverage as added to the workflow differs from what JaCoCo reports.

A clear and concise description of what the bug is.

To Reproduce

Steps to reproduce the behaviour:

  1. Add the action to a Java project with interfaces and/or classes that are excluded
  2. Let the workflow run
  3. See the result, e.g.: https://github.com/opwvhk/avro-conversions/actions/runs/5077740253/jobs/9121402487

What we see here is that interfaces, like SimpleContentHandler.java, don't have any details.

Also, excluded classes like FixedXmlSchemaWalker.java mark many lines as missed, whereas this class should not be in the report at all!

Expected behaviour

  • The coverage report does not include excluded classes.
  • The coverage report does not mark interfaces with a cross.

Some errors appearing on action execution (not happening before)

Describe the bug
Getting some errors from last week, was working before and no action inputs were modified. Error shows as:

Error: Unable to process file command 'output' successfully.
Error: Invalid format '# Coverage Report: JaCoCo'

To Reproduce
Steps to reproduce the behavior:

INPUTS

Run PavanMudigonda/[email protected]
  with:
    coverage_results_path: front-api/build/coverage/test/jacocoTestReport.xml
    coverage_report_name: Coverage
    coverage_report_title: JaCoCo
    github_token: ***
    skip_check_run: true
    minimum_coverage: 50
    fail_below_threshold: true
    publish_only_summary: false
  env:
    TOKEN: ***
    GH_TOKEN: ***
    CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE: /home/runner/work/infrastructure/infrastructure/gha-creds-dba5d7e06905db04.json
    GOOGLE_APPLICATION_CREDENTIALS: /home/runner/work/infrastructure/infrastructure/gha-creds-dba5d7e06905db04.json
    GOOGLE_GHA_CREDS_PATH: /home/runner/work/infrastructure/infrastructure/gha-creds-dba5d7e06905db04.json
    CLOUDSDK_CORE_PROJECT: morgan-abx
    CLOUDSDK_PROJECT: morgan-abx
    GCLOUD_PROJECT: morgan-abx
    GCP_PROJECT: morgan-abx
    GOOGLE_CLOUD_PROJECT: morgan-abx
    CLOUDSDK_METRICS_ENVIRONMENT: github-actions-setup-gcloud
    JAVA_HOME: /opt/hostedtoolcache/Java_Zulu_jdk/17.0.5-8/x64
    JAVA_HOME_17_X64: /opt/hostedtoolcache/Java_Zulu_jdk/17.0.5-8/x64

Complete log output:

/usr/bin/pwsh -f /home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v4.6/action.ps1
Module [GitHubActions] not found, INSTALLING...
Running from [/home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v4.6]

Creating test results space

/home/runner/work/infrastructure/infrastructure/_TMP

Publishing Report to GH Workflow

Building human-readable code-coverage report

VERBOSE: Resolving XML file relative to current directory: /home/runner/work/infrastructure/infrastructure/front-api/build/coverage/test/jacocoTestReport.xml
VERBOSE: Resolving default XSL file: /home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v4.6/jacoco-report/jacocoxml2md.xsl
VERBOSE: Loaded XSL transformer
VERBOSE: Transforming XML to MD
Building human-readable code-coverage report

VERBOSE: Resolving XML file relative to current directory: /home/runner/work/infrastructure/infrastructure/front-api/build/coverage/test/jacocoTestReport.xml
VERBOSE: Resolving default XSL file: /home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v4.6/jacoco-report/buildsummary2md.xsl
VERBOSE: Loaded XSL transformer
VERBOSE: Transforming XML to MD
Covered Lines: 6204
Missed Lines: 1785
Total Lines: 7989
Coverage: 77.66
  * fail_below_threshold: true

Error: Unable to process file command 'output' successfully.
Error: Invalid format '# Coverage Report: JaCoCo'

Screenshot

Screen Shot 2022-11-14 at 09 31 50

Expected behavior
Action executes without errors.

Additional context
Github hosted Linux agents

Execution hangs without any visible error

Describe the bug
I have added this action today to see JaCoCo's coverage reports. Right now I'm using it for feature/** project branches, but the execution of the entire GitHub workflow hangs, especially in the part shown in the screenshot below.

The configuration of my action is very basic, it is a Maven project, I share it below:

name: Feature CI

on:
  push:
    branches:
      - feature/**

env:
  MAVEN_OPTS: '-Dhttps.protocols=TLSv1.2 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true'
  MAVEN_CLI_OPTS: '--batch-mode --errors --fail-at-end --show-version'

jobs:
  deploy:
    name: Feature branch
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Set up JDK
        uses: actions/setup-java@v2
        with:
          distribution: 'zulu'
          java-version: '17'
          cache: 'maven'
      - name: Test and compile project
        run: |
          chmod +x ./mvnw
          ./mvnw $MAVEN_CLI_OPTS clean compile test package
      - name: Publish test coverage results
        uses: PavanMudigonda/[email protected]
        with:
          coverage_results_path: 'target/site/jacoco/jacoco.xml'
          coverage_report_title: 'Test coverage results'
          coverage_report_name: 'Test coverage results'
          github_token: ${{ secrets.GITHUB_TOKEN }}

To Reproduce
Steps to reproduce the behavior:

  1. Create branch feature/any-test-here
  2. Push to GitHub
  3. Start workflow execution
  4. Workflow never stops and does not finish executing the action

Expected behavior
It is expected to run normally, or if there is an error it will show it and end the workflow.

Screenshots
Screenshot_6

Desktop (please complete the following information):
Not apply

Smartphone (please complete the following information):
Not apply

Additional context
Add any other context about the problem here.

Support for multi-module projects with multiple coverage reports

Is your feature request related to a problem? Please describe.
Currently this action only supports a single path to an XML coverage file

Describe the solution you'd like
To be able to pass multiple paths to multiple XML coverage files

Describe alternatives you've considered
None

Additional context
N/A

Action doesn't work if `coverage_report_title` is not set

Describe the bug

coverage_report_title is marked as optional, but the action fails if it is not set.

To Reproduce

Use the action with only the required parameters github_token and coverage_results_path.

The action fails with an error:

jacocoxml2md.ps1: /home/runner/work/_actions/PavanMudigonda/jacoco-reporter/v4.8/action.ps1:61
Line |
  61 |          & "$PSScriptRoot/jacoco-report/jacocoxml2md.ps1" -Verbose `
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception calling "AddParam" with "3" argument(s): "Value cannot be
     | null. (Parameter 'parameter')"

Error: The process '/usr/bin/pwsh' failed with exit code 1

I believe the code here https://github.com/PavanMudigonda/jacoco-reporter/blob/2f45a2fe8f51b1254496217e035ddaf357505093/action.ps1#L56C5-L58C6 and in other places should be setting the title to $script:coverage_report_name and not $report_name.

Expected behavior

It works with only the required arguments.

bug in output variable coverage_percentage

Describe the bug

Fix bug in formaule which is causing wrong calculation in output variable coverage_percentage

wrong output coming out of below due to string vs int. Need to convert to int before running formula
$coveragePercentage = [math]::Round(100 - (($missedLines / $coveredLines) * 100))

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Different coverage values between jacoco file and jacoco-reporter

Describe the bug
After unit tests execution and performing jacoco-reporter action with jacoco.xml file produced by jacoco plugin, there's a difference between actual coverage produced by your jacoco-reporter action and jacoco html also produced by jacoco plugin along with jacoco.xml.

Expected behavior
jacoco-reporter should report the same value of coverage as visible in jacoco html / xml file.

Screenshots
I attach screen with visible difference.
45% coverage value is taken from "Missed Instructions" column from jacoco html file.
While jacoco-reporter produces 50.73% value.

There's no other coverage value available in this jacoco html file, which equals the one provided in the jacoco-reporter.
image

Display Coverage Percent along with Check

Is your feature request related to a problem? Please describe.
There is no way to know just coverage percentage in the pull request page. One has to go inside the job to find out coverage.

Describe the solution you'd like
If the check contains coverage percent, it would be super useful.
The attached screenshot contains a Junit Report summary. Something similar containing coverage percentage would be super useful.

image

Can't get coverageSummary from outputs

Describe the bug
When I echo the outputs.coverageSummary, nothing is printed. I noticed that the variable is marked. Does it still work?

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
Get the core coverage summary from outputs variable.

By the way, there is one less white space in the sample code:

     # ...
# ↓ 6 spaces
      - name: JaCoCo Code Coverage Report
         ...

# ↓ 5 spaces
     - name: Add Coverage Job Summary
       ...

And the GitHub will throw an error about yaml syntax:

Invalid workflow file: .github/workflows/java-pipeline.yml#L18
You have an error in your yaml syntax on line 18

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.