5monkeys / cobertura-action Goto Github PK
View Code? Open in Web Editor NEWGitHub Action to report cobertura coverage
License: MIT License
GitHub Action to report cobertura coverage
License: MIT License
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:
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!
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
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.
I'd love the option to show class names instead of file names because Java files can contain multiple internal classes. Cobertura has this field available as "name" instead of "filename"
For whatever reason, one of the elements (not sure what) is missing the line rate.
Looks like these lines of code should check that the element has that key before accessing it: https://github.com/5monkeys/cobertura-action/blob/master/src/cobertura.js#L53-L54
##[error]Cannot read property 'line-rate' of undefined
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?
Coverage report works for single environment. For my case, i have to use coverage on various sub directory, the report comment overwrites to the last one.
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
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
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:
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):
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.
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.
It will just throw an exception complaining your massage is too large for a comment
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
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
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.
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%
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
#78 was merged, but there hasn't been a new release yet, but all GitHub actions will start running on Node 16 on May 18, which is just a few days aways: https://github.blog/changelog/2023-05-04-github-actions-all-actions-will-run-on-node16-instead-of-node12/
could you introduce a new flag like show_uncovered_lines
, and show the uncovered_lines as a new column?
thanks
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)
The following warning is displayed in the run panel:
Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: 5monkeys/cobertura-action@v13. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/.
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?
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
__init__.py
files are displayed as init.py because of GitHub's markdown. It needs to either escape them or display filenames within code blocks (`__file_name__.py`)
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?
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
Hey,
cool action - still amazed by how complex it is to get coverage reporting into PRs withour external services...
Since a few days my pipelines fail with
Error: Resource not accessible by integratio
see example: https://github.com/Boehringer-Ingelheim/oncomsm/actions/runs/4151027484/jobs/7201882375
Any ideas?
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?
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:
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?
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:
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!
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.
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
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
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 )
I am using glob pattern to supply 2 xml files but same files from one report is also being included in another report
Source could be that files[]
is not been cleared between reports for
loop
cobertura-action/src/action.js
Lines 167 to 169 in 717143c
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
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
i.e. when manually triggering a workflow. See workflow_dispatch.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.