Coder Social home page Coder Social logo

cobertura-action's People

Contributors

alexjephsonsw avatar antonagestam avatar bijujoseph avatar dependabot[bot] avatar eljohnson92 avatar flaeppe avatar hannseman avatar kjagiello avatar michaelsp avatar shaguptashaikh avatar siemian avatar swistakm avatar tspascoal avatar xsc27 avatar zymotik 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cobertura-action's Issues

No commit found for SHA: 302de2cbaebb96948ff6419dcaxxxxxx

Run 5monkeys/cobertura-action@master
with:
path: /home/runner/work/myrepo/myrepo/**/coverage.xml
minimum_coverage: 75
repo_token: ***
skip_covered: true
fail_below_threshold: false
show_line: false
show_branch: false
show_class_names: false
show_missing: false
link_missing_lines: false
only_changed_files: false
env:
PIP_CACHE_DIR: /home/runner/work/myrepo/myrepo/.pip
DEPLOY: false
pythonLocation: /opt/hostedtoolcache/Python/3.8.18/x64
Error: No commit found for SHA: 302de2cbaebb96948ff6419dca4e5610b68b3484

while using action file on the event on:
push:
tags:
- '*' and when we trigger the pipline by running the ./release.sh we are gettingh the above issue

RFC: Threshold for a single file to fail the build

Hi all, I was certain there was a bug in the action, but then realized my issue...the failing threshold is for the total report, not each individual file.

I'd like a propose a new option that defines a threshold that EVERY file needs to be above. Thoughts? Concerns?

I'm already relatively deep in the codebase and know how I would implement it, so I'm more wondering if you think this would be a good addition or not.

Coverage report is different in percentage than cobertura.xml report

Hello.

I'm working on Open Source project in Crystal which generates coverage report using kcov. The report is in cobertura.xml and while looking and content of file, I notice the Cobertura-Action writes different percentage than in cobertura.xml file.
Also, some filenames are stripped, I don't know why.

This is Cobertura-Action comment:

image

And here is the report that kcov generates(in there, you can also open index.html for visual coverage or find cobertura.xml in coverage/specs/ directory):

coverage.zip

Node.js 12 actions are deprecated

I'm now seeing 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: 5monkeys/cobertura-action

link missing files fails for windows action

We integrated cobertura-action into a github action for .net on windows with the following config:

    - uses: 5monkeys/cobertura-action@master
      with:
        path: ./coverage/**/coverage.cobertura.xml
        skip_covered: false
        show_missing: true
        link_missing_lines: true
        link_missing_lines_source_dir: WinFormsThemes/WinFormsThemes
        minimum_coverage: 80

This works, but the links created by link_missing_lines are broken:

The file seems to be reported as Themes\FileTheme.cs and is used directly in the created url instead of being translated into /.

An example can be found here

Is this a bug or do I need to configure something else?

Coverage always show 100%

Hi

I'm trying to use thin action to help me generate coverage report. But when I see the bot comment on my Pull Request I always see it 100%

CoverageTestReport

Here is my coverage.xml

https://raw.githubusercontent.com/Laki7877/grails/main/coverage.xml

and here is my action yaml examle

- name: Add coverage to PR
        id: cobertura
        uses: 5monkeys/cobertura-action@v9
        with:
          path: ${{ github.workspace }}/target/test-reports/cobertura/*.xml
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          minimum_coverage: 40
          skip_covered: false
          show_line: false
          show_branch: false
          show_class_names: true
          show_missing: true
          only_changed_files: false

Permission issue on PRs raised from repository forks

Pull request workflows (event pull_request) raised from repository forks get read-only token. This causes the workflows involving cobertura-action to fail, due to lack of permission.

`Error: Resource not accessible by integration

Actions team recently introduced pull_request_target, but that poses additional security risks. To mitigate that, they recommend to split these workflows, a well-written recipe can be found in 2

Certainly, cobertura-action accepts pull_request_number parameter, but that will put the onus on the workflow author. So, in order to keep things simple, it is better to encapsulate the PR identification logic within this action for workflow_run events. Soon I will be rasing a PR to address this.

References:

[Feature Request] Limit report to files which are in the diff

Thanks for your very helpful action. This is a feature request to limit the reporting comment to only files which were changed in the given PR. I think this should be doable if you check that the file path in the cobertura report is a substring of the file path of a file in the diff.

This would make the report much more useful, especially for larger projects, as it will help reviewers narrow down which coverage report lines are important.

Validation failed - Body is too long (maximum is 65536 characters)

Hi,

When using this action, I get a validation failed error message:

Run 5monkeys/cobertura-action@master
  with:
    path: **/Cobertura.xml
    repo_token: ***
    pull_request_number: 145
    minimum_coverage: 0
    skip_covered: true
    show_line: false
    show_branch: false
    show_class_names: false
    show_missing: false
    only_changed_files: false
Error: Validation Failed: {"resource":"IssueComment","code":"unprocessable","field":"data","message":"Body is too long (maximum is 65536 characters)"}

https://github.com/nHapiNET/nHapi/actions/runs/566542886

What am I doing wrong? or is there a way around this?

Applying for GitHub publisher verification for "cobertura-action" Action.

Iโ€™m writing regarding the GH Action cobertura-report

Our project is starting to migrate the CI/CD to GH Actions and we are interested to use your Actions.
Providing some context, our Security team requires the "Creator Verified by GitHub" badge to start the internal GHA verification process, due to this we are blocked to use unverified Actions.

We would be grateful if you could start the GH Action verification process, as it would help us greatly.

I believe it must improve your impact in the whole GitHub community as a partner organization and also, you are letting us use your actions.

You can find more helpful information in the following articles from GitHub Docs as a good starting point on the process.

Applying for publisher verification for your organization
About marketplace badges

##[error]Found no pull request.

    runs-on: ubuntu-latest
    needs: compile
    steps:
      - uses: actions/checkout@v2
      - name: Restore target dir
        uses: actions/download-artifact@v1
        with:
          name: target
      - name: Coverage
        uses: jetbridge/[email protected]
        with:
          commands: coverage coverageReport
      - uses: 5monkeys/cobertura-action@master
        with:
          path: target/scala-2.12/coverage-report/cobertura.xml
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          minimum_coverage: 90

Gives me the error:

Run 5monkeys/cobertura-action@master
  with:
    path: target/scala-2.12/coverage-report/cobertura.xml
    repo_token: ***
    minimum_coverage: 90
    skip_covered: true
    show_line: false
    show_branch: false
    show_class_names: false
    only_changed_files: false
[@octokit/rest] `const Octokit = require("@octokit/rest")` is deprecated. Use `const { Octokit } = require("@octokit/rest")` instead
[@octokit/rest] `const Octokit = require("@octokit/rest")` is deprecated. Use `const { Octokit } = require("@octokit/rest")` instead
##[error]Found no pull request.

(It's a pull request and not a fork)

Display coverage results as job summary

Hello,

Today, GitHub have announced the possibility to display markdown in job summary.
I think it's truly awesome, and I would appreciate if this action could offer the mode "summary" to report the coverage results instead of decorating pull request. Or maybe in complement?
Anyways, I'd be glad to contribute if you agree with this suggestion.

[Feature request] Add new parameter "minimum_coverage_per_file"

Hi,
Thanks for this action, it is very helpful !

It would be nice to have two distinct a new parameter which would be : minimum_coverage_per_file

Example:

- name: cobertura-report
        uses: 5monkeys/cobertura-action@v13
        with:
          path: cobertura/coverage/cobertura.xml
          minimum_coverage: 75
          minimum_coverage_per_file: 70

And result would be

first example KO

File Coverage Lines Missing
All files 75% 75% โœ…
no-map/AccountTriggerHandler 100% 100% โœ…
no-map/AccountContactRelation 50% 50% โŒ

Minimum coverage requirement was not satisfied (75% global and 70% per file )

- name: cobertura-report
        uses: 5monkeys/cobertura-action@v13
        with:
          path: cobertura/coverage/cobertura.xml
          minimum_coverage: 85
          minimum_coverage_per_file: 75

second example OK

File Coverage Lines Missing
All files 87% 87% โœ…
no-map/AccountTriggerHandler 100% 100% โœ…
no-map/AccountContactRelation 75% 75% โœ…

Minimum coverage requirement satisfied (85% global and 75% per file )

Coverage Percentage as Output Variable

Hi, Thank you for awesome GH Action. Could i request you to consider providing Coverage Percentage as Output Variable so i can use in subsequent steps and jobs.

Not always posting comments

I've updated the trigger in hopes to get my workflow to run on main when PRs are merged (so using the push event) but the pull_request event for everything else:

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - '**/*'

You can see it's properly triggered on my pull request when I push new commits, with the pull_request event:
image

However it's not posting comments! The report says "updated 2 mins ago" so it seems like that's working properly but I'm not sure why it can't resolve the pull request number.

Is there some way to enable debug output or something like that?
Thanks!

Storing badge under the GitHub Action

Hi,

I would like to avoid storing badges in my repository code. Ideally I would like to store my badges un der the GitHub Action execution itself. This way I can reference it in the markdown.

<Path to my Repository>/actions/workflows/myGitHubActionFile.yml/jacoco.svg

Is there a workaround for this?

Signal "check" failure when code coverage falls below threshold

Thanks for the great action!

I have coverage running as a separate workflow and it appears in my PR's "checks" section. Is there a way to fail the check (red X) if code coverage doesn't meet its thresholds in addition to the comment the action already posts?

[Feature Request] Ability to turn off commenting on pull requests

It would be nice to have a flag such as post_on_pr: true/false, which would toggle this option on/off.
The report should be generated in either case and be accessible via the Actions tab, but not posted to the PR discussion thread if desired.

Reasons:

  • These comments draw unnecessary attention
  • In case of matrix strategies, multiple comments are posted

Fail when code coverage is below line threshold

When using fail_below_threshold: true action fails if (lineCoverage + branchCoverage) / 2 < minimum_coverage. I want to show line coverage badge in README file but that coverage is not the same as when using this action. Would it be possible to make this configurable and decide what minimum_coverage means - decide whether failure is for line, branch or combined coverage?

Or maybe something like minimum_coverage: X Y Z where X Y and Z represent coverage for combined, line and branch respectively?

Error: Not Found

The action fails when running after a PR is merged.

After a PR is merged to the main branch we trigger a workflow. I have unsuccessfully tried skipping the Cobertura action in that case because it fails with Error: Not Found

Screen Shot 2021-12-13 at 4 09 38 PM

I am not sure exactly what is missing, it does perfectly on PRs

Relevant parts of the workflow

on:
  push:
    branches:
      - test/*
      - latest

  pull_request:
    branches:
      - latest
jobs:
  jest:
    needs: download-env
    runs-on: [self-hosted, linux, x64]

    steps:
      ... 
      - name: run unit tests
        run: npm run test-ci // > jest --ci --maxWorkers=2 --coverage --coverageReporters="cobertura"
      - name: coverage report
        uses: 5monkeys/cobertura-action@v12
        if: github.event_name == 'pull_request' && ${{ github.actor != 'dependabot[bot]' }}
        with:
          path: coverage/**/cobertura-coverage.xml
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          only_changed_files: true
          minimum_coverage: 40
          skip_covered: false

Output from run unit tests

Test Suites: 1 skipped, 110 passed, 110 of 111 total
Tests:       3 skipped, 582 passed, 585 total
Snapshots:   74 passed, 74 total
Time:        44.857 s
Ran all test suites.
๐Ÿ“ฆ reporter is created on: /home/github/work/.../tmp/jest_html_reporters.html

Any ideas on how can I skip running this action after a merge? or what is it that the action is not finding?

Passing action during PR

Screen Shot 2021-12-13 at 4 23 48 PM

please make new release

thank you for very useful action. it helps us to report branch coverage on PRs.

currently we have to use commit sha 61b3b14 because #46 not part of the latest release of v9: https://github.com/5monkeys/cobertura-action/releases/tag/v9

    - name: cobertura-report
      uses: 5monkeys/cobertura-action@61b3b14d4da85a16843613a7de9c49aaeddd9d1b
      if: ${{ github.event_name == 'pull_request' }}
      with:
        path: html/cobertura.xml
        repo_token: ${{ github.token }}
        minimum_coverage: 100
        show_branch: true
        pull_request_number: ${{ github.pull_request.number }}
        fail_below_threshold: true

Allow failling the check without failling to step.

Currently if fail_below_threshold is true and the threshold, both the step and the coverage check would be marked as failed. Ideally only the check would be marked as failed since it allows to easily that the job was able to succeed, but the coverage was insufficient. To avoid changing the current behaviour, an input could be added to get the described behaviour.

A workaround is to set continue-on-error: true. However this solution will also mark the job as success even if we were unsuccessful at creating the coverage report.

Error: EACCES: permission denied, scandir '/lost+found'

Trying to generate a report for a dot net project, Action is failing with a permission error.

yml

jobs:
  build-and-test:
    runs-on: ubuntu-latest
    permissions: write-all
    defaults:
      run:
        working-directory: ./api
    steps:
    - uses: actions/checkout@v3
    - name: Setup .NET
      uses: actions/setup-dotnet@v3
      with:
        dotnet-version: 6.0.x
    - name: Restore dependencies
      run: dotnet restore
    - name: Build
      run: dotnet build --no-restore
    - name: Test
      run: dotnet test -p:CollectCoverage=true -p:CoverletOutput=TestResults/ -p:CoverletOutputFormat=\"cobertura,opencover\" -p:ExcludeByFile=\"**/*.cshtml\" --no-build --verbosity normal Tests/*.Tests/
    - name: Test Code Coverage Comment
      uses: 5monkeys/cobertura-action@v13
      with:
          repo_token: ${{ secrets.GITHUB_TOKEN }}
          path: /**/TestResults/coverage.cobertura.xml
          skip_covered: false
          minimum_coverage: 75
          show_line: true
          show_branch: true
          show_missing: true
          link_missing_lines: true
          link_missing_lines_source_dir: "api/"
          report_name: Api Test Coverage

Output
Screenshot 2023-10-20 at 21 56 50

`only_changed_files` option not working

I have a dotnet / C# project using 5monkeys/cobertura-action@v13, it works great with default values

Just tried to add the option only_changed_files: true as the project is getting bigger but it does not seem to have any effect.
More precisely, the report is still created but only shows the header line for All files
Screenshot 2023-09-04 at 13-36-14 epona_ github_workflows at main ยท ardextech_epona

Here is an extract of my GitHub workflow

  test:
    runs-on: ubuntu-latest
    permissions:
      statuses: write
      checks: write
      contents: write
      pull-requests: write
      actions: write
    steps:
    - uses: actions/checkout@v3
    - name: Setup .NET
      uses: actions/setup-dotnet@v3
      with:
        dotnet-version: 7.0.x
    - name: Test
      run: dotnet test --logger "trx;LogFileName=test-results.trx" --collect:"XPlat Code Coverage"
    - name: Coverage Report
      uses: 5monkeys/cobertura-action@v13
      with:
        path: backend-api/tests/TestResults/*/*.xml
        minimum_coverage: 70
        skip_covered: false
        show_line: true
        show_branch: true
        show_class_names: false
        only_changed_files: true

Action executes without any problem
Screenshot 2023-09-04 at 14-23-38 EPN-34 Generate and Send New User Invite Email ยท ardextech_epona@9a3c2ae

Support separate comments for separate reports

Would be neat to be able to publish separate comments for separate reports, I'm trying to use this for publishing the metrics for two different xml files generated by two different suites, but the same comment is updated for both of them. A new feature would be great where I can pass in a new input for say report_name which can be used in the initial comment body as say - title for the report and when you lookup comments for subsequent jobs in action.js->addComment(), use the report name to filter instead of the credits text? Thanks!

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.