Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
andyli86 committed Jul 11, 2022
0 parents commit c2839da
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 0 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Changelog for gcov2lcov-action

## 1.0.9 [2022-05-23]

- fix: always set `GOROOT` before invoking `gcov2lcov` (#13)

## 1.0.8 [2020-11-05]

- fix: use correct download link when specific version of gcov2lcov is set (#11)

## 1.0.5 [2020-10-15]

- without docker runtime

## 1.0.4 [2020-10-13]

- bump to gcov2lcov 1.0.4
- use precompiled binary

## 1.0.3 [2020-09-11]

- bump to gcov2lcov 1.0.3

## 1.0.2 [2020-04-25]

- bump to gcov2lcov 1.0.2 to address coverage calculation problem
(<https://github.com/jandelgado/gcov2lcov-action/issues/2>)

## 1.0.0 [2019-10-07]

- initial release
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Jan Delgado

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
74 changes: 74 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# gcov2lcov-action

[![Build Status](https://github.com/jandelgado/gcov2lcov-action/workflows/test/badge.svg)](https://github.com/jandelgado/gcov2lcov-action/actions?workflow=test)

Convert golang coverage files to lcov format. Works nicely with the [coveralls
github action](https://github.com/marketplace/actions/coveralls-github-action) and
uses [gcov2lcov](https://github.com/jandelgado/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

```yaml
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
```yaml
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](https://github.com/jandelgado/golang-ci-template-github-actions).
## Author
Copyright &copy; 2019 - 2022 Jan Delgado
## License
[MIT](LICENSE)
34 changes: 34 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: gcov2lcov-action

description: "convert golang coverage to lcov format"

inputs:
infile:
description: "go coverage input file"
required: false
default: coverage.out
outfile:
description: "lcov output file"
required: false
default: coverage.lcov
version:
description: "gcov2lcov version"
required: false
default: latest
working-directory:
description: "change working directory"
required: false

runs:
using: composite
steps:
- shell: bash
run: 'set -x && curl -sLf "$([ ${{inputs.version}} == latest ] && echo $LATEST_RELEASE || echo $RELEASE)/${NAME}.tar.gz" | tar zxf - --strip 1'
working-directory: /tmp
env:
NAME: "gcov2lcov-linux-amd64"
RELEASE: "https://github.com/jandelgado/gcov2lcov/releases/download/${{inputs.version}}"
LATEST_RELEASE: "https://github.com/jandelgado/gcov2lcov/releases/latest/download"
- shell: bash
run: 'set -x && GOROOT=$(go env GOROOT) /tmp/gcov2lcov-linux-amd64 -infile "${{ inputs.infile }}" -outfile "${{ inputs.outfile }}"'
working-directory: ${{ inputs.working-directory }}
4 changes: 4 additions & 0 deletions testdata/coverage.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mode: set
github.com/jandelgado/gcov2lcov/main.go:45.44,49.38 4 1
github.com/jandelgado/gcov2lcov/main.go:46.44,50.38 4 0
github.com/jandelgado/gcov2lcov/main.go:58.2,58.32 1 1
12 changes: 12 additions & 0 deletions testdata/coverage_expected.lcov
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
TN:
SF:main.go
DA:45,1
DA:46,1
DA:47,1
DA:48,1
DA:49,1
DA:50,0
DA:58,1
LF:7
LH:6
end_of_record
3 changes: 3 additions & 0 deletions testdata/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/jandelgado/gcov2lcov

go 1.15
1 change: 1 addition & 0 deletions testdata/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package main

0 comments on commit c2839da

Please sign in to comment.