GithubHelp home page GithubHelp logo

zgosalvez / github-actions-report-lcov Goto Github PK

View Code? Open in Web Editor NEW
51.0 51.0 43.0 3.81 MB

A Github Action to report the code coverage from LCOV files

Home Page: https://github.com/marketplace/actions/report-lcov

License: MIT License

JavaScript 100.00%
actions github github-actions lcov

github-actions-report-lcov's Introduction

Hi there ๐Ÿ‘‹

  • ๐Ÿ”ญ Iโ€™m currently maintaining a handful of GitHub Actions
  • ๐Ÿ’ฌ Ask me anything or reach me by GitHub Discussions
  • ๐Ÿ˜„ Pronouns: he/him

github-actions-report-lcov's People

Contributors

alvra avatar balaji-nordic avatar bartosz347 avatar dependabot[bot] avatar jbrownsw avatar jhen0409 avatar mattangus avatar moseskarunia avatar poowaa avatar zgosalvez 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

github-actions-report-lcov's Issues

How does changed files 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.

Nodejs12 is deprecated

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

genhtml: No filename specified

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

Report lcov

Add Link to the uploaded artifact file

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.

The action uses the soon deprecated `set-output` command

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.

Add support for macOS

When i run on macOS it tries to install with apt instead of brew.

Command:

brew install lcov

Branch coverage

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.

Process /usr/bin/genhtml failed with exit code 255

I am trying to generate a coverage report for a package but it fails saying

image

ci-workflow.yaml
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}}

Files changed coverage rate not shown

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.

lines = lines.filter((line, index) => {
if (index <= 2) return true; // Include header
for (const changedFile of changedFiles) {
console.log(`${line} === ${changedFile}`);
if (line.startsWith(changedFile)) return true;
}
return false;
});
if (lines.length === 3) { // Only the header remains
return ' n/a';
}

Is it maybe that the line does not start with the filename because it has the full path to the repo prepended?

Any ideas or suggestions appreciated!

Unable to resolve action

Yaml

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 }}

Log

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 action zgosalvez/[email protected], unable to find version 1.3.0
Retrying in 14.083 seconds
Failed to resolve action download info. Error: Unable to resolve action zgosalvez/[email protected], unable to find version 1.3.0
Retrying in 10.631 seconds
Error: Unable to resolve action zgosalvez/[email protected], unable to find version 1.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.

Incompatible with act

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.

genhtml step fails

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

Failed to retrieve file names from artifact

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:
image

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:
image

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:

  1. Tests and coverage processing action log: https://github.com/Stanislaw000/ONIX-Data/runs/3244608588?check_suite_focus=true
  2. Build, test and artifacts upload action log: https://github.com/Stanislaw000/ONIX-Data/runs/3244213227?check_suite_focus=true
  3. Coverage processing workflow: https://github.com/Stanislaw000/ONIX-Data/blob/NetStandard/.github/workflows/test-report.yml (default branch version, because this one is always working as being triggered by workflow complete)
  4. CI workflow: https://github.com/Stanislaw000/ONIX-Data/blob/Test-Report-and-Code-Coverage-CI-improve/.github/workflows/ci.yml

Remove files from coverage

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

Error: Resource not accessible by integration

Running this Action fails with Error: Resource not accessible by integration on the Report code coverage step.

Logs
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

Error: Cannot find module 'lcov-total'

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 }}

@v1 and @v2 works fine with the same configuration.

Error when used with non-root project folder

Yaml

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 }}

Error Log

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

Proposed solution

Maybe adding an option to set project folder like:

project-dir: apps/horeekaa

or read the directory of workflows as specified in working-directory.

Folder Structure

Screen Shot 2021-02-04 at 14 37 10

genhtml: Unable to locate executable file: genhtml

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

Disable genhtml

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 :

  • Disable it if artifact-name is not set
  • Add an option to disable it

Do you think you can provide this feature ? Thank you !

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.