GithubHelp home page GithubHelp logo

orgoro / coverage Goto Github PK

View Code? Open in Web Editor NEW
93.0 93.0 24.0 1.44 MB

GitHub Action for python coverage publish & analysis

License: MIT License

TypeScript 98.60% JavaScript 1.40%
action coverage github-actions python typescript

coverage's Introduction

 ___   ___    _______     
|\  \ |\  \  /  ___  \    
\ \  \\_\  \/__/|_/  /|   
 \ \______  \__|//  / /   
  \|_____|\  \  /  /_/__  
         \ \__\|\________\
          \|__| \|_______|
                         

coverage's People

Contributors

ciuliene avatar dependabot[bot] avatar john-williams avatar oreporan avatar orgoro avatar paddatrapper avatar samwho avatar seluj78 avatar vinaypuppal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

coverage's Issues

Fails At 100% Code Coverage

I tried setting my overall code coverage to 100%, but it never passes (even with 100% code coverage).

 - name: Display Coverage
    uses: orgoro/coverage@v3
    with:
      coverageFile: ./coverage.xml
      thresholdAll: 1.0
      token: ${{ secrets.GITHUB_TOKEN }}

UnhandledPromiseRejectionWarning: HttpError: Resource not accessible by integration

The action is not doing what it should for me.
See this job for exmaple https://github.com/boschresearch/ros_license_linter/actions/runs/4165753067/jobs/7209189364

(node:2157) UnhandledPromiseRejectionWarning: HttpError: Resource not accessible by integration
    at /home/runner/work/_actions/orgoro/coverage/v3/webpack:/typescript-action/node_modules/@octokit/request/dist-node/index.js:86:1
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:2157) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2157) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Error: "could not read file cover.xml"

``hello,

I am having trouble with this action finding the xml file generated by coverage.

I have tried multiple paths and file names, and I am unsure as to why it does not recognize it.

As far as I have read, the docs don't specify a path where it should be.

What am I doing wrong here?

Here is my workflow yaml:

name: 'coverage'
on:
    pull_request:
        branches:
            - master
            - main
jobs:
    coverage:
        runs-on: ubuntu-latest
        steps:
          - name: Get Cover 
            uses: orgoro/[email protected]
            with:
                coverageFile: cover.xml
                token: ${{ secrets.GITHUB_TOKEN }}

Am I missing the token? or does it grab it automatically?

xml regex validator failing

If the xml report has the keys in a different order than in the regex, e.g.
<?xml version="1.0" ?> <coverage branch-rate="0" branches-covered="0" branches-valid="0" complexity="0" line-rate="0.789" lines-covered="344" lines-valid="436" timestamp="1662319474790" version="6.4.4">

the regex in your action code is .*<coverage.*lines-valid="(?<total>[\\d\\.]+)".*lines-covered="(?<covered>[\\d\\.]+)".*line-rate="(?<ratio>[\\d\\.]+)"
which doesnt validate, the xml attributes are just in a different order than expected.

Support multiple sources

Hi,

We are using your GitHub action but have noticed that it only supports one source for coverage.
We would like to be able to support a few packages as sources for coverage so our pyproject.toml is set up as such

source = [
    "package1",
    "package2",
    "package3",
]

Which leads to a coverage.xml file like this:

...
	<sources>
		<source>package1</source>
		<source>package2</source>
		<source>package3</source>
	</sources>
...

The function parseSource can only return one source.

const regex = new RegExp(`.*<source>(?<source>.*)</source>.*`)

This ends up returning only the first matched source: package1
and so the GitHub comment only displays coverage of files belonging to the first package.

Would it be possible to support multiple sources?
I'm happy to be a contributor if that's what it takes.

Status dot colour configuration

Currently the status dots in the summary are red & green for failure & success, respectively.

It would be nice to allow the colour to be configured to some degree. This would be especially helpful for those users who cannot easily distinguish red & green.

I'm not sure if it is possible to automatically mirror GitHub's theme, and e.g. use the same colours that would be used in the UI for adding and deleting code? That would be quite neat.

Escape file names in coverage table

Underscores are not escaped in filenames so instead of __init__.py file names are rendered as init.py.
My proposed fix would be replacing coverFile.file here with coverFile.file.replaceAll("_", "\\_").
A proper solution would be to find some way to escape markdown, but this should cover the majority of use cases.

Why running only for pull requests events?

Hello and thank you for providing this project, it's really useful!

Currently I'm trying to use it for a project, but it seems like I can not decide about the logic involving the event due the follow condition:

if (eventName !== 'pull_request') {

const eventName = context.eventName
    if (eventName !== 'pull_request') {
      core.setFailed(`action support only pull requests but event is ${eventName}`)
      return
    }

So, basically we are only running nightly and manual workflow_dispatch CI jobs, which means, this project can not be used, because we still are not running for pull requests.

I would like to ask to raise that condition if possible, so users could decide the logic directly in their CI flow, instead:

- name: Coverage report
  if: github.event_name == 'pull_request'
  uses: orgoro/[email protected]
  with:
    coverageFile: xmlcov/coverage.xml
    token: ${{ secrets.GITHUB_TOKEN }}

Regards!

Node version is outdated

during the usage of thes action github publishes the following warning

Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: orgoro/coverage@v3

Bad column name

The table in PR comment has "Lines" as the name of the first column, but it should be "Statements", as it's in coverage table output.

Working directory setting not respected

We have a monorepo and run coverage in each service. The working directory setting in defaults isn't used and requires prepending the working directory path to the coverage file.

You can see the run steps set the working directory in the debug logs:

##[debug]Evaluating condition for step: 'Run tests'
...
Run poetry run pytest --cov --cov-report xml:coverage.xml .
##[debug]Overwrite 'working-directory' base on job defaults.

Example yaml file:

jobs:
  test:
    defaults:
      run:
        working-directory: services/foo
    runs-on: ubuntu-latest
    steps:
      - name: Run tests
        run: poetry run pytest --cov --cov-report xml:coverage.xml .
      - name: Code coverage
        uses: orgoro/coverage@v3
        with:
          coverageFile: services/foo/coverage.xml
          token: ${{ secrets.GITHUB_TOKEN }}
          thresholdAll: .8

Confusing (outdated?) documentation (--cov flag)

You can create a coverage report using python:

pytest $ pytest --cov-report xml:path/to/coverage.xml
coverage $ coverage xml path/to/coverage.xml

First of all, it wasn't clear to me whether I needed BOTH of those, or just one.

Secondly, the given pytest command did not work for me. I had to add '--cov':

poetry run pytest --cov --cov-report xml:coverage.xml

Can you clarify?

HttpError: Resource not accessible by integration

Hi, up until the last few days v3 was working fine and then the below error started. I tried v3.1 too but get the same.

Has something changed that the action relies on?

‘’’
HttpError: Resource not accessible by integration
at /home/runner/work/_actions/orgoro/coverage/v3.1/webpack:/typescript-action/node_modules/@octokit/request/dist-node/index.js:86:1
at processTicksAndRejections (node:internal/process/task_queues:96:5)
‘’’

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.