GithubHelp home page GithubHelp logo

jandelgado / gcov2lcov-action Goto Github PK

View Code? Open in Web Editor NEW
22.0 3.0 2.0 18 KB

Github action to convert go coverage files to lcov format

License: MIT License

golang lcov coverage gcov2lcov-action coverage-files testing gcov2lcov

gcov2lcov-action's Introduction

gcov2lcov-action

Build Status

Convert golang coverage files to lcov format. Works nicely with the coveralls github action and uses gcov2lcov under the hood.

Inputs

infile

Optional Name of the go coverage file. Default coverage.out.

outfile

Optional Name of the lcov file to write. Default coverage.lcov.

version

Optional Name of the specific gcov2lcov program version. Default latest.

working-directory

Optional Name of directory where gcov2lcov is run. Defaults to $GITHUB_WORKSPACE.

Outputs

No outputs.

Example usage

uses: jandelgado/gcov2lcov-action@v1
with:
  infile: coverage.out        # optional, default filename is `coverage.out`
  outfile: coverage.lcov      # optional, default filename is `coverage.lcov`
  version: v1.0.4             # optional, use specific `gcov2lcov` release version
  working-directory: testdata # optional, change working directory

Full example

coverage:
  runs-on: ubuntu-latest
  steps:
    - name: Install Go
      if: success()
      uses: actions/setup-go@v3
      with:
        go-version: 1.18
    - name: Checkout code
      uses: actions/checkout@v2
    - name: Calc coverage
      run: go test -v -covermode=count -coverprofile=coverage.out
    - name: Convert coverage to lcov
      uses: jandelgado/gcov2lcov-action@v1
    - name: Coveralls
      uses: coverallsapp/[email protected]
      with:
        github-token: ${{ secrets.github_token }}
        path-to-lcov: coverage.lcov

See also example repository.

Author

Copyright © 2019 - 2022 Jan Delgado

License

MIT

gcov2lcov-action's People

Contributors

jandelgado avatar septs avatar

Stargazers

 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

gcov2lcov-action's Issues

error: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

One of the latest runs of my workflow failed:

Run jandelgado/gcov2lcov-action@master
  with:
    infile: profile.cov
    outfile: coverage.lcov
    version: latest
Run set -x && curl -sLf "$([ latest == latest ] && echo $LATEST_RELEASE || echo $RELEASE)/${NAME}.tar.gz" | tar zxf - --strip 1
  set -x && curl -sLf "$([ latest == latest ] && echo $LATEST_RELEASE || echo $RELEASE)/${NAME}.tar.gz" | tar zxf - --strip 1
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    NAME: gcov2lcov-linux-amd64
    RELEASE: https://github.com/jandelgado/gcov2lcov/releases/download/latest
    LATEST_RELEASE: https://github.com/jandelgado/gcov2lcov/releases/latest/download
+ tar zxf - --strip 1
++ '[' latest == latest ']'
++ echo https://github.com/jandelgado/gcov2lcov/releases/latest/download
+ curl -sLf https://github.com/jandelgado/gcov2lcov/releases/latest/download/gcov2lcov-linux-amd64.tar.gz
Run set -x && /tmp/gcov2lcov-linux-amd64 -infile "profile.cov" -outfile "coverage.lcov"
  set -x && /tmp/gcov2lcov-linux-amd64 -infile "profile.cov" -outfile "coverage.lcov"
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
+ /tmp/gcov2lcov-linux-amd64 -infile profile.cov -outfile coverage.lcov
2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64

2022/05/18 14:07:34 warn: go/build: importGo github.com/pashagolub/pgxmock/: exit status 2
go: cannot find GOROOT directory: /opt/hostedtoolcache/go/1.13.15/x64
...

Is it because runner doesn't have Go v1.13 installed anymore?

I don't think -coverpkg=./... is handled well.

codecov: 82%
coveralls: 48%
https://github.com/arvenil/kata

go test -coverpkg=./... -coverprofile=coverage.txt -covermode=atomic ./...

Note -coverpkg=./....
This results in below file (I cut it only to show line 14 of templates.go file):

$ cat coverage.txt | grep templates.go:14
github.com/arvenil/kata/format/templates/templates.go:14.37,19.17 5 0
github.com/arvenil/kata/format/templates/templates.go:14.37,19.17 5 0
github.com/arvenil/kata/format/templates/templates.go:14.37,19.17 5 1
github.com/arvenil/kata/format/templates/templates.go:14.37,19.17 5 0
github.com/arvenil/kata/format/templates/templates.go:14.37,19.17 5 0
github.com/arvenil/kata/format/templates/templates.go:14.37,19.17 5 0

As you may see, for example, line 14 is visible there several times with different count.
This tool converts it to:

DA:14,0
DA:14,0
DA:14,1
DA:14,0
DA:14,0
DA:14,0

And then coveralls doesn't seem to handle it and shows ZERO coverage when there was exactly one pass. Maybe this tool should sum such entries, and as so coveralls would show correct value, or maybe it's a bug worth reporting to coveralls?

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.