Sites where you can find me or my work | |
---|---|
Web and social media | |
Software development | |
Publications |
If you want to generate the equivalent to the above for your own GitHub profile, check out the cicirello/user-statistician GitHub Action.
Coverage badges, and pull request coverage checks, from JaCoCo reports in GitHub Actions
Home Page: https://actions.cicirello.org/jacoco-badge-generator/
License: MIT License
Sites where you can find me or my work | |
---|---|
Web and social media | |
Software development | |
Publications |
If you want to generate the equivalent to the above for your own GitHub profile, check out the cicirello/user-statistician GitHub Action.
I want to implement the code coverage check as a required verification step for the PR's to the master branch.
I think that it is possible to implement it as an additional feature for the jacoco-badge-generator.
example:
- name: Generate JaCoCo Badge
id: jacoco
uses: cicirello/[email protected]
with:
fail-on-decrese: true
Also, it will be great to have such option as:
fail-when-coverage-lessThan: 60
Which will fail the pipeline when coverage is less than provided argument.
Is your feature request related to a problem? Please describe.
The Pester PowerShell testing framework allows users to output code coverage reports as JaCoCo xml files. However, this action requires input in the form of csv files.
Describe the solution you'd like
A new input option jacoco-xml-file
that works for JaCoCo xml files.
Describe alternatives you've considered
I could not find any simple way to convert from csv to xml. I could also request that the Pester framework add an option to output as csv, but I think it makes more sense to start here.
Additional context
N/A
Thank you for your consideration!
Describe the bug
After upgrading to Jdk17 from 11 the jacoco badge github action failing with the below error.
generate-branches-badge: true
generate-summary: true
jacoco-csv-file: target/site/jacoco/jacoco.csv
coverage-badge-filename: jacoco.svg
branches-badge-filename: branches.svg
generate-coverage-badge: true
coverage-label: coverage
branches-label: branches
on-missing-report: fail
fail-if-coverage-less-than: 0
fail-if-branches-less-than: 0
fail-on-coverage-decrease: false
fail-on-branches-decrease: false
intervals: 100 90 80 70 60 0
colors: #4c1 #97ca00 #a4a61d #dfb317 #fe7d37 #e05d44
generate-coverage-endpoint: false
generate-branches-endpoint: false
coverage-endpoint-filename: jacoco.json
branches-endpoint-filename: branches.json
summary-filename: coverage-summary.json
env:
DOCKER_REGISTRY: https://packages.aa.com
DOCKER_REPOSITORY_DEV: packages.aa.com/docker-dev/dotcwebappimage
REPO_NAME: pcs-dotcras-webapp
JAVA_HOME: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.7-7/x64
JAVA_HOME_17_X64: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.7-7/x64
/usr/bin/docker run --name c9a4a5cf7c06edd4384493bf0d4f88f418a56b_6564cb --label c9a4a5 --workdir /github/workspace --rm -e "DOCKER_REGISTRY" -e "DOCKER_REPOSITORY_DEV" -e "REPO_NAME" -e "JAVA_HOME" -e "JAVA_HOME_17_X64" -e "INPUT_BADGES-DIRECTORY" -e "INPUT_GENERATE-BRANCHES-BADGE" -e "INPUT_GENERATE-SUMMARY" -e "INPUT_JACOCO-CSV-FILE" -e "INPUT_COVERAGE-BADGE-FILENAME" -e "INPUT_BRANCHES-BADGE-FILENAME" -e "INPUT_GENERATE-COVERAGE-BADGE" -e "INPUT_COVERAGE-LABEL" -e "INPUT_BRANCHES-LABEL" -e "INPUT_ON-MISSING-REPORT" -e "INPUT_FAIL-IF-COVERAGE-LESS-THAN" -e "INPUT_FAIL-IF-BRANCHES-LESS-THAN" -e "INPUT_FAIL-ON-COVERAGE-DECREASE" -e "INPUT_FAIL-ON-BRANCHES-DECREASE" -e "INPUT_INTERVALS" -e "INPUT_COLORS" -e "INPUT_GENERATE-COVERAGE-ENDPOINT" -e "INPUT_GENERATE-BRANCHES-ENDPOINT" -e "INPUT_COVERAGE-ENDPOINT-FILENAME" -e "INPUT_BRANCHES-ENDPOINT-FILENAME" -e "INPUT_SUMMARY-FILENAME" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/pcs-dotcras-webapp/pcs-dotcras-webapp":"/github/workspace" c9a4a5:cf7c06edd4384493bf0d4f88f418a56b "target/site/jacoco/jacoco.csv" "badges" "jacoco.svg" "branches.svg" "true" "true" "fail" "0" "0" "false" "false" "100 90 80 70 60 0" "#4c1 #97ca00 #a4a61d #dfb317 #fe7d37 #e05d44" "false" "false" "jacoco.json" "branches.json" "true" "coverage-summary.json" "coverage" "branches"
WARNING: Report file target/site/jacoco/jacoco.csv does not exist or glob target/site/jacoco/jacoco.csv is empty.
WARNING: No JaCoCo csv reports found.
Add entry point for running as command-line utility outside of GitHub Actions. This is a pre-requisite to #40.
Is not an issue. Is just the requirement to generate the badge images without github actions
Describe the solution you'd like
Just a couple of lines showing how to run the python code to generate the images
Describe alternatives you've considered
I reviewed the tests and with some intuition I created this sentence:
python JacocoBadgeGenerator.py jacoco.csv /home coverage.png branch.png true true fail 50 50 true true '100, 90, 80, 70, 60, 0' "#ffffff" true true 50 50 true summary.txt
Also it would be appreciated a markdown table in the readme explaining the parameters.
Can I make you a PR to your readme?
Describe the bug / To Reproduce
specifiying an absolute path for jacoco-csv-file
results in:
WARNING: Report file /home/runner/work/soot-reloaded/soot-reloaded/report/target/jacoco-aggregate/jacoco.csv does not exist.
WARNING: No JaCoCo csv reports found.
The file exists (checked with stat).
Expected behavior
As with a relative path - which i am using now and it works.
Describe the bug
GitHub Actions has deprecated the set-output workflow command, which we are currently using for workflow outputs of the action. See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/. That same link indicates the replacement.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
No deprecation warning.
Describe the bug
I manage a multi-module maven project and when it comes to run cicirello/[email protected], I got the following error:
FileNotFoundError: [Errno 2] No such file or directory: 'target/site/jacoco/jacoco.csv'
Indeed, the parent artefact has no target/site/jacoco
directory whereas modules have.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I suppose the default behavior should scan for all target directories, from parent to children to look for all CSV files.
Relevant System Info (please complete the following information):
Best regards,
CP
Revise GitHub Actions workflow for matrix testing of Python versions supported by the CLI mode (for the unit tests and for the CLI mode of the tool itself). Note: this is not necessary for the GitHub Actions mode since as an Action it runs within a Docker container with the current version of Python.
I have a two-module project and I use TestNG as testing framework, which allows (like JUnit I believe) to declare groups.
I declared 8 groups, (a) some are tagged in both modules, (b) some in only one of them.
I configured this GitHub action in order to list jacoco-csv files but in (b) case only one exists.
When I run the action, it throws FileNotFoundError: [Errno 2] No such file or directory: 'solver/target/site/jacoco/jacoco.csv'
which is expected. But I wonder whether it is possible to add something like:
if os.path. exists(filename):
just before JacocoBadgeGenerator.py#L90.
Is your feature request related to a problem? Please describe.
Not really a problem.
Describe the solution you'd like
Output the computed coverage percentages as a workflow "job summary" (see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary).
Hi @cicirello,
thanks for this great action, I think it is very useful.
I have one question/suggestion related to maven multi module projects.
Is your feature request related to a problem? Please describe.
In your example, all modules are listed. This works for a small number of modules, but introduces the risk that when a new module is added to the project, it is not added here.
Describe the solution you'd like
I think it would be nice if a glob pattern could be provided here instead of the full list like **/jacoco.csv
.
Describe alternatives you've considered
It is possible to use this workaround, which is a bit verbose:
- name: Find JaCoCo reports of modules
run: |
find . -name jacoco.csv
echo "jacoco_csv_files=`find . -name jacoco.csv | tr '\n' ' '`" >> "$GITHUB_OUTPUT"
id: find_jacoco
- name: Generate JaCoCo Badge
id: jacoco
uses: cicirello/jacoco-badge-generator@v2
with:
generate-branches-badge: true
jacoco-csv-file: >
${{ steps.find_jacoco.outputs.jacoco_csv_files }}
Additional context
Just an additional thought:
Maybe it would even be nice to have a glob pattern as the default as opposed to 'target/site/jacoco/jacoco.csv'
, which should work for single and multi module projects. I don't see much downsides, except maybe that searching using the glob pattern will be a little slower as the hard coded default path.
Best,
Florian
Describe the bug
Maybe it's a beginner question and I'm doing something wrong, but I have a workflow running your action and I can't see the badge in the read.me
file.
To Reproduce
Steps to reproduce the behavior:
![Coverage](https://github.com/pablobaldez/test-coverage-sample/actions/workflows/pr-build.yml/jacoco.svg)
Expected behavior
I was expecting to see the badge such as the build badge
Screenshots
here is how my read me is
Additional context
here is my GitHub repository if you want to check more details https://github.com/pablobaldez/test-coverage-sample
Hey, first of all thank you for this helpful plugin.
When I'm running the plugin "cicirello/[email protected]" in my workflow I'm getting this error:
Traceback (most recent call last):
File "/JacocoBadgeGenerator.py", line 189, in
cov, branches = computeCoverage(jacocoCsvFile)
File "/JacocoBadgeGenerator.py", line 96, in computeCoverage
return covered / (covered + missed), coveredBranches / (coveredBranches + missedBranches)
ZeroDivisionError: division by zero
I opened my csv file and yes I can see zeros in the data, specifically I see BRANCH_MISSED and BRANCH_COVERED in some tests are both 0. So is it the problem from jacoc for not filling those columns with data or the script can omit these tests cases if both covered and missed are 0?
It will be great to have any link to the working example
Add a workflow that runs on release events as well as workflow_dispatch events that publishes the package on PyPI. This way whenever a GitHub release is created to release the Action to the GitHub Marketplace, the command-line utility is simultaneously released to PyPI.
We have multiple workfows in a single repository creating different coverages. We'd like to set the label text on the badge to show which coverage was calculated. E.g. instead of
coverage: 70,4%
we'd like to change the text to
coverage (product.core): 70,4%
I found no possible solutions to this problem in your documentation, maybe there is none yet!
Unfortunately, this is going to break usage for self-hosted GHES enterprise organizations that are not on the bleeding edge. I am still on GHES 3.5, which uses runner version 2.294.0
while this requires at least 2.297.0
. I am going to have to pin to 2.7.0
if reverting is not possible.
Originally posted by @erodewald in #84 (comment)
Use set-output
if GITHUB_OUTPUT
env variable doesn't exist.
Currently, the entrypoint of the action is an if __name__ == "__main__"
block. This works fine. However, one user requested the ability to use outside of GitHub Actions as a command line utility (see #40). In order to enable such functionality, parameters will need to be processed differently than they are as a GitHub Action.
if __name__ == "__main__"
block to a main function, except for the parameter processing.This issue does not actually fully address the command line utility use-case. However, the proposed new main function will greatly simplify future support. This issue is a pre-requisite to #40.
Is your feature request related to a problem? Please describe.
Is not related to a problem. Is just the request of a piece of documentation in which you show us how to use it directly without github actions
Describe the solution you'd like
Maybe on a direct usage section in readme, you could add something like this:
python3 JacocoBadgeGenerator.py \
/foo/project/target/site/jacoco/jacoco.csv \
badges \
coverage.svg \
branches.svg \
true \
true \
fail \
0.1 \
0.1 \
false \
false \
"10,30,50,70,90,100" \
'#4c1 #97ca00 #a4a61d #dfb317 #fe7d37 #e05d44' \
true \
true \
coverage.json \
branches.json \
true \
summary.json
There were many attempts to figure out the relationship between 12 and 13 args (colors and intervals). Maybe this comments could be
improved to highlight that relationship
Describe alternatives you've considered
Maybe an extra test on https://github.com/cicirello/jacoco-badge-generator/blob/main/tests/tests.py with this direct usage.
Thanks!
Is your feature request related to a problem? Please describe.
Not related to a problem, more of an improvement to the summary that is generated after a workflow run.
Describe the solution you'd like
I've would like to be able to change the values of the workflow summary. See attached screenshot.
We are generating multiple badges in one workflow, by using cicirello/jacoco-badge-generator@v2
multiple times on one workflow. And when the workflow is complete it posts a workflow summary with default values, but they all look the same since there is currently no way of customize the summary.
Describe alternatives you've considered
Have considered just using separate workflows for generating each badge, but we would still like to customize the values. And we can only find the option to completely turn it off.
In a huuge projects, 0.1% might include a couple of factories implementations plus minor bugfixes. Therefore, one decimal place precision is counterproductive - someone might spend significant effort, adding coverage by 0.04%, and someone else might just add some non-covered reducing overall coverage by 0.05%. After rounding to the first decimal place, the initial value, the value after the first contributor, and reduced value after the second one are undistinguishable. That discourages the first contributor from writing any more tests.
Please, add the input parameter "rounding" to the plugin.
Enable user to specify the colors to use for the badges.
Summary
The badges currently generated are styled in a way that is based on Shields's "flat" style, although no actual dependency on Shields (generated entirely within the action). Some users of this GitHub action may use other shields badges in their repos using one of their other styles, and may prefer all of their repo badges to have a common style. Although one potential solution would be to replicate all of the shields styles within the action. that would seem overly redundant.
Proposed Solution
Keep the default behavior as the default (generate badges directly within the action including the way they are currently styled). Add an option via action inputs to generate JSON endpoints with the fields expected by shields, either instead of or in addition to generating the badges directly.
Users who like the default style can continue to use as is, keeping the performance benefit of serving the badge directly from the repo (e.g., already generated, and one http request directly to the badge). Users who want to match other shields styles can opt-in to generating a JSON endpoint instead, using shields to generate the badge (e.g., use shields's endpoint badge, passing url to JSON to Shields to generate the badge). That would also enable those users to pass Shields's query parameters to change style, etc.
GitHub Actions docs recommend using a major release tag, which users can use to always have latest release, including patches with bug fixes without having to update workflow with specific release tag.
The sample badges in the README are visible when viewing the repository, but not when viewing the action in the GitHub Marketplace. They previously appeared there. It is likely a bug in the GitHub Marketplace for links to images relative within the repository.
In the section of documentation with example workflows, add an example showing all possible action inputs.
Currently, the coverage intervals for each badge color is fixed: e.g., 100 is bright green, 90 or better green, etc. Add an input to enable customizing the cutoffs.
Add option to suppress logging output to workflow job summary.
When using custom multi-project github actions using the .py script, summary becomes very long:
Originally posted by @eransamo in #126 (comment)
Describe the bug
A clear and concise description of what the bug is.
The newest version 2.6 will generate a __pycache__
folder which has a root permission and this will break the next step to remove it without sudo permission.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Relevant System Info (please complete the following information):
Additional context
Add any other context about the problem here.
I have a multi-module Maven project with 4 sub modules. Each of them have its own tests and produce a separate Jacoco report.
I would like to present in my README,md a badge with %coverage of all the Jacoco results together.
Instead of passing a single 'jacoco-csv-file' argument, it would be great to pass a list of files so the badge will present an average coverage weighted by the lines number of each sub module.
Since Jacoco 0.7.7, a goal of 'jacoco:report-aggregate' is supported, which create a single Jacoco report from multiple sub modules.
My problem with this alternative is that it requires an addition dummy sub module which depends on all the other sub modules, and the aggregated Jacoco report is actually the dummy sub module report.
This solution seems a bit messy to me and I want to avoid creating an additional sub module and keep my library cleaner.
Also I do want the reports themselves to be separate, as I prefer each sub module to test itself properly.
Thanks a lot of the tool, love it!
The actions/setup-java action recently introduced a new major version with new inputs. The example workflows in the documentation of the jacoco-badge-generator
currently assume the old version of setup-java. Update these.
Update Python to 3.12 in CI/CD workflows when running unit tests.
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.