zgosalvez / github-actions-report-lcov Goto Github PK
View Code? Open in Web Editor NEWA Github Action to report the code coverage from LCOV files
Home Page: https://github.com/marketplace/actions/report-lcov
License: MIT License
A Github Action to report the code coverage from LCOV files
Home Page: https://github.com/marketplace/actions/report-lcov
License: MIT License
Great action! Thanks for sharing it!!
It would be nice if the comment has a link to the artifact uploaded to Github.
In addition, we might return artifact-id that we receive from uploading an artifact. So that we can programmatically decide where to show/serve it.
Using this sample workflow step:
- name: Report LCOV report
uses: zgosalvez/[email protected]
with:
coverage-files: coverage/*.info
artifact-name: code-coverage-report
I get the following error:
/usr/bin/genhtml --rc lcov_branch_coverage=1 --output-directory /tmp/__zgosalvez_github-actions-report-lcov/html
genhtml: No filename specified
Running this Action fails with Error: Resource not accessible by integration
on the Report code coverage
step.
Run zgosalvez/github-actions-report-lcov@v3
/usr/bin/genhtml /home/runner/work/IFJ23/IFJ23/build/tests/cov.info --rc lcov_branch_coverage=1 --output-directory /tmp/__zgosalvez_github-actions-report-lcov/html
Reading data file /home/runner/work/IFJ23/IFJ23/build/tests/cov.info
Found 1 entries.
Found common filename prefix "/home/runner/work/IFJ23/IFJ23"
Writing .css and .png files.
Generating output.
Processing file src/main.c
Writing directory view page.
Overall coverage rate:
lines......: 100.0% (7 of 7 lines)
functions..: 100.0% (1 of 1 function)
branches...: no data found
Uploading artifacts.
Starting artifact upload
For more detailed logs during the artifact upload process, enable step-debugging: https://docs.github.com/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging#enabling-step-debug-logging
Artifact name is valid!
Container for artifact "code-coverage-report" successfully created. Starting upload of file(s)
Total size of all the files uploaded is 13694 bytes
File upload process has finished. Finalizing the artifact upload
Artifact has been finalized. All files have been successfully uploaded!
The raw size of all the files that were specified for upload is 58875 bytes
The size of all the files that were uploaded is 13694 bytes. This takes into account any gzip compression used to reduce the upload size, time and storage
Note: The size of downloaded zips can differ significantly from the reported size. For more information see: https://github.com/actions/upload-artifact#zipped-artifact-downloads
/usr/bin/lcov --add-tracefile /home/runner/work/IFJ23/IFJ23/build/tests/cov.info --output-file /tmp/__zgosalvez_github-actions-report-lcov/lcov.info --rc lcov_branch_coverage=1
Combining tracefiles.
Reading tracefile /home/runner/work/IFJ23/IFJ23/build/tests/cov.info
Writing data to /tmp/__zgosalvez_github-actions-report-lcov/lcov.info
Summary coverage rate:
lines......: 100.0% (7 of 7 lines)
functions..: 100.0% (1 of 1 function)
branches...: no data found
/usr/bin/lcov --summary /tmp/__zgosalvez_github-actions-report-lcov/lcov.info --rc lcov_branch_coverage=1
Reading tracefile /tmp/__zgosalvez_github-actions-report-lcov/lcov.info
Summary coverage rate:
lines......: 100.0% (7 of 7 lines)
functions..: 100.0% (1 of 1 function)
branches...: no data found
/usr/bin/lcov --list /tmp/__zgosalvez_github-actions-report-lcov/lcov.info --list-full-path --rc lcov_branch_coverage=1
Reading tracefile /tmp/__zgosalvez_github-actions-report-lcov/lcov.info
|Lines |Functions |Branches
Filename |Rate Num|Rate Num|Rate Num
==============================================================================
/home/runner/work/IFJ23/IFJ23/src/main.c| 100% 7| 100% 1| - 0
==============================================================================
Total:| 100% 7| 100% 1| - 0
Error: Resource not accessible by integration
Unfortunately the files changed coverage rate is not shown in the posted comment, only "n/a" is printed instead.
I am using v1.5.0, but had this with previous versions as well. I thought this might be fixed with the branch coverage now being calculated but the issues still seems to exist.
When looking at the output, the coverage per file looks fine.
Looking at the source code, I think this might be related to filtering out the files which are untouched.
github-actions-report-lcov/src/main.js
Lines 176 to 190 in 8b72ce0
Any ideas or suggestions appreciated!
name: horeekaa
on:
push:
branches: [master]
paths:
- ".github/workflows/horeekaa.yaml"
- "apps/horeekaa/**"
pull_request:
branches: [master, epic-**]
paths:
- ".github/workflows/horeekaa.yaml"
- "apps/horeekaa/**"
jobs:
build:
defaults:
run:
working-directory: apps/horeekaa
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/[email protected]
- name: Install dependencies
run: flutter pub get
- name: Format
run: flutter format --set-exit-if-changed lib test
- name: Analyze project source
run: flutter analyze lib test
- name: Test
run: flutter test --coverage
- name: Report code coverage
uses: zgosalvez/[email protected]
with:
working-directory: apps/horeekaa
coverage-files: apps/horeekaa/coverage/lcov.info
minimum-coverage: 95
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
Current runner version: '2.276.1'
Operating System
Virtual Environment
Prepare workflow directory
Prepare all required actions
Getting action download info
Failed to resolve action download info. Error: Unable to resolve actionzgosalvez/[email protected]
, unable to find version1.3.0
Retrying in 14.083 seconds
Failed to resolve action download info. Error: Unable to resolve actionzgosalvez/[email protected]
, unable to find version1.3.0
Retrying in 10.631 seconds
Error: Unable to resolve actionzgosalvez/[email protected]
, unable to find version1.3.0
Hi, I can't seem able to run using the latest released version from the github action marketplace. Maybe there's something wrong with the release process or how long should it be usually before available?
Thanks.
I see that the generated HTML reports are using a 4 years old LCOV version (1.14).
Can you update to LCOV 2.0?
Hello,
I have problem adding your action to my CI workflows:
I have 2 workflows
First go CI, which builds app, run tests and upload test results and coverage as artifacts. This one is complete with success state and uploads artifacts:
After workflow [CI] is completed my second workflow is triggered, which should process tests and coverage reports:
name: 'Test Report and Code Coverage'
on:
workflow_run:
workflows: ["CI"]
types: [completed]
jobs:
report:
name: Workflow test
runs-on: ubuntu-latest
steps:
- name: .NET Tests Results
uses: dorny/test-reporter@v1
with:
artifact: test-results
name: .NET Tests results
path: '**/**/*.trx'
reporter: dotnet-trx
- name: Code Coverage
uses: zgosalvez/github-actions-report-lcov@v1
with:
artifact-name: code-coverage-report
name: Code Coverage
coverage-files: '**/TestResults/coverage.info'
minimum-coverage: 0
github-token: ${{ secrets.GITHUB_TOKEN }}
While tests reported is working as expected (so artifacts seems to be working), code coverage isn't.
It is failing with following error:
I was playing witch changing .info file retrieving patterns, but doesn't help.
What is interesting is that when I had code coverage inside the same workflow as running tests it was working.
Any idea what's the problem here?
Links:
When i run on macOS it tries to install with apt
instead of brew
.
Command:
brew install lcov
Github gives this message as of today:
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: zgosalvez/github-actions-report-lcov
I can find the correct way to set lcov output file to the this github action,
I have this configuration:
- name: Coverage
working-directory: ${{github.workspace}}/build
run: make coverage && ls -l && pwd
- name: Report code coverage
uses: zgosalvez/github-actions-report-lcov@v1
with:
coverage-files: lcov.coverage.info
minimum-coverage: 90
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
working-directory: ${{github.workspace}}/build
The Coverage stage generate the file lcov.coverage.info on the build directory which is the working directory on the github action, but It can't pick it up.
Could anybody point me to the right direction to fix this?
here is a screenshot of the error and a link to the failing runner
We run our tests on both Linux and Windows. However, the action seems to have trouble mapping the Windows file names in the Linux environment once the coverage upload starts. See https://github.com/tgstation/tgstation-server/actions/runs/3061728208/jobs/4943751420
Currently I can't generate branch coverage. There are some scenario, when coverage is 100%, but branch coverage is lower.
From lcov 1.10 this feature needs a new flag: --rc lcov_branch_coverage=1
Maybe we should extends the functionality of the action with this option.
Hi !
Thank you for this action which is very useful !
My problem : I do not need the html report, but there's no way to disable it. In my case it is a waste of resources and time.
I see 2 options :
Do you think you can provide this feature ? Thank you !
name: horeekaa
on:
push:
branches: [master]
paths:
- ".github/workflows/horeekaa.yaml"
- "apps/horeekaa/**"
pull_request:
branches: [master, epic-**]
paths:
- ".github/workflows/horeekaa.yaml"
- "apps/horeekaa/**"
jobs:
build:
defaults:
run:
working-directory: apps/horeekaa
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/[email protected]
- name: Install dependencies
run: flutter pub get
- name: Format
run: flutter format --set-exit-if-changed lib test
- name: Analyze project source
run: flutter analyze lib test
- name: Test
run: flutter test --coverage
- name: Report code coverage
uses: zgosalvez/github-actions-report-lcov@v1
with:
coverage-files: apps/horeekaa/coverage/lcov.info
minimum-coverage: 95
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
Run zgosalvez/github-actions-report-lcov@v1
/usr/bin/sudo apt-get install lcov
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
libgd-perl
The following NEW packages will be installed:
lcov libgd-perl
0 upgraded, 2 newly installed, 0 to remove and 12 not upgraded.
Need to get 255 kB of archives.
After this operation, 860 kB of additional disk space will be used.
Get:1 http://azure.archive.ubuntu.com/ubuntu bionic/universe amd64 lcov all 1.13-3 [93.1 kB]
Get:2 http://azure.archive.ubuntu.com/ubuntu bionic/main amd64 libgd-perl amd64 2.66-1build1 [162 kB]
Fetched 255 kB in 0s (14.7 MB/s)
Selecting previously unselected package lcov.
(Reading database ...
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 283623 files and directories currently installed.)
Preparing to unpack .../archives/lcov_1.13-3_all.deb ...
Unpacking lcov (1.13-3) ...
Selecting previously unselected package libgd-perl.
Preparing to unpack .../libgd-perl_2.66-1build1_amd64.deb ...
Unpacking libgd-perl (2.66-1build1) ...
Setting up libgd-perl (2.66-1build1) ...
Setting up lcov (1.13-3) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
/usr/bin/genhtml /home/runner/work/horeekaa-frontend/horeekaa-frontend/apps/horeekaa/coverage/lcov.info --output-directory /tmp/zgosalvezgithub-actions-report-lcov/html
Reading data file /home/runner/work/horeekaa-frontend/horeekaa-frontend/apps/horeekaa/coverage/lcov.info
Resolved relative source file path "lib/dummy_file.dart" with CWD to "/home/runner/work/horeekaa-frontend/horeekaa-frontend/lib/dummy_file.dart".
Found 1 entries.
Found common filename prefix "/home/runner/work/horeekaa-frontend/horeekaa-frontend"
Writing .css and .png files.
Generating output.
genhtml: ERROR: cannot read /home/runner/work/horeekaa-frontend/horeekaa-frontend/lib/dummy_file.dart
Processing file lib/dummy_file.dart
Error: The process '/usr/bin/genhtml' failed with exit code 2
Maybe adding an option to set project folder like:
project-dir: apps/horeekaa
or read the directory of workflows as specified in working-directory
.
Example warning here:
Warning: The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
Would appreciate if you could update the action accordingly.
Originally posted by mccrearyp April 13, 2024
The latest version doesn't post the complete artifact. It posts the top level directory with the stats, but is missing the files needed to drill down into sub directories or files. If I run my code coverage locally I still get the files. Possibly related to this change?
Tried to switch from @v1 to @V3 and got this:
Run zgosalvez/github-actions-report-lcov@v3
with:
coverage-files: coverage.lcov
artifact-name: code-coverage-report
github-token: ***
minimum-coverage: 0
env:
...
Error: Cannot find module 'lcov-total'
Require stack:
- /home/runner/work/_actions/zgosalvez/github-actions-report-lcov/v3/dist/main/index.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.2388 (/home/runner/work/_actions/zgosalvez/github-actions-report-lcov/v3/dist/webpack:/github-actions-report-lcov/node_modules/@vercel/ncc/dist/ncc/@@notfound.js:1:1)
at __nccwpck_require__ (/home/runner/work/_actions/zgosalvez/github-actions-report-lcov/v3/dist/webpack:/github-actions-report-lcov/webpack/bootstrap:21:1)
at /home/runner/work/_actions/zgosalvez/github-actions-report-lcov/v3/dist/webpack:/github-actions-report-lcov/src/main.js:6:1
at /home/runner/work/_actions/zgosalvez/github-actions-report-lcov/v3/dist/main/index.js:20541:3
at Object.<anonymous> (/home/runner/work/_actions/zgosalvez/github-actions-report-lcov/v3/dist/main/index.js:20544:12)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
the workflow file looks like this:
runs-on: ubuntu-latest
env:
...
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
...
- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@v1
- name: Run tests
run: go test -cover -coverprofile=gotest.coverage ./...
- name: Convert coverage to lcov
uses: jandelgado/gcov2lcov-action@v1
with:
infile: gotest.coverage
...
- name: Report code coverage
uses: zgosalvez/github-actions-report-lcov@v3
with:
coverage-files: coverage.lcov
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
A feature that I would find nice would be to remove some files from the coverage report.
It could simply use the lcov command like this:
lcov --remove coverage/lcov.info 'lib/**/*.g.dart' -o coverage/clean_lcov.info
Hey there!
Am I doing something wrong?
lcov.info file is located at /coverage directory.
- name: ๐ Code Coverage Report
uses: zgosalvez/[email protected]
with:
coverage-files: coverage/lcov.info
github-token: ${{ secrets.GITHUB_TOKEN }}
update-comment: true
Logs:
##[debug]Evaluating condition for step: '๐ Code Coverage Report'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: ๐ Code Coverage Report
##[debug]Register post job cleanup for action: zgosalvez/github-actions-report-lcov@v[3](https://github.com/spherebread/inriver-html-templates/actions/runs/4315315437/jobs/7529581314#step:9:3).1.1
##[debug]Loading inputs
##[debug]Evaluating: secrets.GITHUB_TOKEN
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'GITHUB_TOKEN'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Loading env
Run zgosalvez/[email protected]
with:
coverage-files: coverage/lcov.info
github-token: ***
update-comment: true
minimum-coverage: 0
##[debug]followSymbolicLinks 'true'
##[debug]implicitDescendants 'true'
##[debug]matchDirectories 'true'
##[debug]omitBrokenSymbolicLinks 'true'
##[debug]Search path '/home/runner/work/inriver-html-templates/inriver-html-templates/coverage/lcov.info'
Error: Unable to locate executable file: genhtml. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: ๐ Code Coverage Report
I am trying to generate a coverage report for a package but it fails saying
env:
PACKAGE_PATH: packages/bridge_common
defaults:
run:
shell: bash
working-directory: packages/bridge_common
coverage:
name: ๐น Generate coverage report
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: ๐ง Setup Dart SDK
uses: dart-lang/[email protected]
- name: ๐ Install dependencies
run: dart pub get
- name: ๐ Generate Coverage
working-directory: packages/
run: ./coverage.sh bridge_common
- name: ๐ Report Coverage
uses: zgosalvez/[email protected]
with:
coverage-files: coverage/lcov.info
minimum-coverage: 0 # todo: update minimum coverage
artifact-name: common-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
working-directory: ${{env.PACKAGE_PATH}}
Is there any way to use the percentage result to use in future steps? I would like to generate an svg badge after this step
https://github.com/nektos/act is a GitHub runner.
It doesn't have a package catalog already pre-fetched, so the step sudo apt-get install -y lcov
fails.
It would be great if sudo apt-get update
is run if the package catalog is missing, so that act
will work.
As far as I can see, we are not feeding a base lcov file in the inputs of this action. How does it determine what changed?
I am getting na
in PR message of the files changed section.
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.