Giter VIP home page Giter VIP logo

clovercodecoveragesummary's Introduction

Code Coverage Summary

A GitHub Action that reads Clover format code coverage files from your test suite and outputs a markdown summary. This summary can be posted as a Pull Request comment or included in Release Notes by other actions to give you an immediate insight into the health of your code without using a third-party site. Code Coverage Summary is designed for use with any test framework that outputs coverage in Clover XML format. The action has a build in feature to group coverage by package. This currently works with composer.json only.

Inputs

filename

Required

A path to the code coverage file to analyse. Also supports using glob patterns to match multiple files. If there are any spaces in a path or filename this value must be in quotes.

Outputs

Markdown Example Summary

Code Coverage
Package Lines Functions Classes Health
nxdummy 96% 26/27 83% 5/6 93% 31/33
Summary 96% 26/27 83% 5/6 93% 31/33

Markdown Example Details

Code Coverage details
Code Coverage
Class Lines Functions Classes Health
nxdummy
Netlogix\Nxdummy\Exception\OptionNotFoundException NaN% 0/0 NaN% 0/0 NaN% 0/0
Netlogix\Nxdummy\Options\MiddlewareOptions 90% 10/11 66% 2/3 85% 12/14
Netlogix\Nxdummy\Utility\UriUtility 100% 16/16 100% 3/3 100% 19/19 🚀
Summary 96% 26/27 83% 5/6 93% 31/33

Usage

      - name: Code Coverage Summary Report
        uses: saschanowak/[email protected]
        with:
          filename: clover.xml

Add the following to your workflow to include the summary in the job summary:

      - name: 'Add Code Coverage to Job Summary'
        run: |
          cat code-coverage-summary.md >> $GITHUB_STEP_SUMMARY
          cat code-coverage-details.md >> $GITHUB_STEP_SUMMARY

Add the following to your workflow to post the summary as a Pull Request comment:

      - name: 'Add Code Coverage Summary as PR Comment'
        uses: marocchino/sticky-pull-request-comment@v2
        if: github.event_name == 'pull_request'
        with:
          recreate: true
          path: code-coverage-summary.md

Version Numbers

Version numbers will be assigned according to the Semantic Versioning scheme. This means, given a version number MAJOR.MINOR.PATCH, we will increment the:

  1. MAJOR version when we make incompatible API changes
  2. MINOR version when we add functionality in a backwards compatible manner
  3. PATCH version when we make backwards compatible bug fixes

Contributing

Report Bugs

Please make sure the bug is not already reported by searching existing issues.

If you're unable to find an existing issue addressing the problem please open a new one. Be sure to include a title and clear description, as much relevant information as possible, a workflow sample and any logs demonstrating the problem.

Suggest an Enhancement

Please open a new issue.

Submit a Pull Request

Discuss your idea first, so that your changes have a good chance of being merged in.

Submit your pull request against the main branch.

Pull requests that include documentation and relevant updates to README.md are merged faster, because you won't have to wait for somebody else to complete your contribution.

License

Code Coverage Summary is available under the MIT license, see the LICENSE file for more info.

clovercodecoveragesummary's People

Contributors

dasben avatar dependabot[bot] avatar eloisetaylor5693 avatar saschanowak avatar

clovercodecoveragesummary's Issues

Parser fails when multiple classes are declared within single file

First of all, thank you for this useful action, great job!

There is an issue when the codebase contains files that declare multiple classes. The clover.xml will look something like the below:

    <file name="{filePath}">
      <class name="{class1}" namespace="global">
        <metrics complexity="3" methods="3" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="6" coveredstatements="0" elements="9" coveredelements="0"/>
      </class>
      <class name="{class2}" namespace="global">
        <metrics complexity="0" methods="0" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="0" coveredstatements="0" elements="0" coveredelements="0"/>
      </class>
      <line num="17" type="method" name="xxx" visibility="public" complexity="1" crap="2" count="0"/>
      .....    
      <metrics loc="43" ncloc="40" classes="1" methods="3" coveredmethods="0" conditionals="0" coveredconditionals="0" statements="6" coveredstatements="0" elements="9" coveredelements="0"/>
    </file>

That means a single <file> element will have multiple <class> children.

In that case, the parse will fail with ::error::Cannot read properties of undefined (reading '@_statements') here

Missing v-prefix for tags

I try to use this github action but run into trouble.

If I specify the step like this:

        name: Code Coverage Summary Report
        uses: saschanowak/[email protected]

The setup of the job works:

Download action repository 'saschanowak/[email protected]' (SHA:6649100e0418106c712323719258d5c2ace6c0cd)

But fails later on:

Run saschanowak/CloverCodeCoverageSummary@[1](https://github.com/BonnierNews/asap-plainfield/actions/runs/10302498437/job/28516310749#step:6:1).0.1
Error: Cannot read properties of undefined (reading '@_name')

If I specify the step like this:

        name: Code Coverage Summary Report
        uses: saschanowak/[email protected]

It fails in the setup of the job:

Error: Unable to resolve action `saschanowak/[email protected]`, unable to find version `v1.0.1`

I noticed that other actions are using the v-prefix in their tags and maybe that plays nicer with github actions?

reportData.coverage.project.file is not iterable

When using this github action I get the error:
Error: reportData.coverage.project.file is not iterable

My setup

"jest": "^27.0.0",

To generate the clover coverage report I'm running: jest --ci --coverage which generates the folder in the root of my project
image

The workflow file:

permissions:
  checks: write
  contents: read
  packages: read
  pull-requests: write

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version-file: '.nvmrc'
      - uses: actions/cache@v3
        with:
          path: |
            node_modules
            ~/.cache/Cypress
          key: node-${{ hashFiles('yarn.lock') }}
      - run: yarn --frozen-lockfile --check-files
      - run: yarn test:ci
      - name: Clover Code Coverage Summary
        uses: saschanowak/[email protected]
        with:
          filename: ./coverage/clover.xml
      - name: 'Add Code Coverage to Job Summary'
        run: |
          cat code-coverage-summary.md >> $GITHUB_STEP_SUMMARY
          cat code-coverage-details.md >> $GITHUB_STEP_SUMMARY

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.