Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign action working mode #8

Merged
merged 4 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 22 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
on: [push, pull_request]
name: test
name: Test

on:
septs marked this conversation as resolved.
Show resolved Hide resolved
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v1
with:
go-version: 1.15.x
- name: Checkout code
uses: actions/checkout@v1
- name: Integration test
run: |
# perform an integration test with original gcov2lcov integration
# test data, which is available in the testdata/ directory.
docker build -t gcov2lcov-action .
# create bare-bones go project to run the action on
mkdir -p gcov2lcov/.git
echo -e '[remote "origin"]\nurl = git@github.com:jandelgado/gcov2lcov\n' > gcov2lcov/.git/config
echo -e "package main\n" > gcov2lcov/main.go
echo -e "module github.com/jandelgado/gcov2lcov\ngo 1.15\n" > gcov2lcov/go.mod
cp testdata/coverage.out gcov2lcov/
docker run -e "GITHUB_WORKSPACE=/test" \
-e "INPUT_INFILE=coverage.out" \
-e "INPUT_OUTFILE=coverage.lcov" \
-i --rm -v "$PWD/gcov2lcov:/test" gcov2lcov-action
diff -y testdata/coverage_expected.lcov gcov2lcov/coverage.lcov
- name: Checkout code
uses: actions/checkout@v2
- name: Prepare
run: git init
working-directory: testdata
- name: Run gcov2lcov-action
uses: ./
with:
workspace: testdata
- name: Diff
run: diff -y coverage_expected.lcov coverage.lcov
working-directory: testdata
19 changes: 14 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# changelog for gcov2lcov-action
# Changelog for gcov2lcov-action

## 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
- 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)
- 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
- initial release
22 changes: 0 additions & 22 deletions Dockerfile

This file was deleted.

35 changes: 16 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## gcov2lcov-action
# gcov2lcov-action

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

Expand Down Expand Up @@ -32,39 +32,36 @@ with:
### Full example

```yaml
coverage:
runs-on: ubuntu-latest
steps:
coverage:
runs-on: ubuntu-latest
steps:
- name: Install Go
if: success()
uses: actions/setup-go@v1
with:
go-version: 1.15.x
uses: actions/setup-go@v2-beta
- name: Checkout code
uses: actions/checkout@v1
- name: Calc coverage
uses: actions/checkout@v2
- name: Calc coverage
run: |
export PATH=$PATH:$(go env GOPATH)/bin
export PATH=$PATH:$(go env GOPATH)/bin
go test -v -covermode=count -coverprofile=coverage.out
- name: Convert coverage to lcov
uses: jandelgado/gcov2lcov-action@v1.0.4
uses: jandelgado/gcov2lcov-action@v1.0.5
with:
infile: coverage.out
outfile: coverage.lcov
infile: coverage.out
outfile: coverage.lcov
- name: Coveralls
uses: coverallsapp/github-action@v1.0.4
with:
github-token: ${{ secrets.github_token }}
path-to-lcov: coverage.lcov
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 (C) 2019-2020 Jan Delgado

## License
Copyright &copy; 2019 - 2020 Jan Delgado

MIT
## License

[MIT](LICENSE)
34 changes: 26 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
name: 'gcov2lcov-action'
description: 'convert golang coverage to lcov format'
name: gcov2lcov-action

description: "convert golang coverage to lcov format"

inputs:
infile:
description: 'go coverage input file'
description: "go coverage input file"
required: true
default: 'coverage.out'
default: coverage.out
outfile:
description: 'lcov output file'
description: "lcov output file"
required: true
default: 'coverage.lcov'
default: coverage.lcov
version:
description: "gcov2lcov version"
required: true
default: v1.0.4
workspace:
description: "working directory"
required: false

runs:
using: 'docker'
image: 'Dockerfile'
using: composite
steps:
- name: Run gcov2lcov
run: ${{ github.action_path }}/entrypoint.sh
shell: bash
env:
INFILE: ${{ inputs.infile }}
OUTFILE: ${{ inputs.outfile }}
VERSION: ${{ inputs.version }}
WORKSPACE: ${{ inputs.workspace }}
15 changes: 8 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/sh
set -eu
#!/bin/bash
set -xeuo pipefail

unset GOPATH
export GOROOT=/usr/local/go

cd $GITHUB_WORKSPACE
exec /app/gcov2lcov-linux-amd64 -infile "$INPUT_INFILE" -outfile "$INPUT_OUTFILE"
TMP_BIN=$(mktemp -d -t ci-XXXXXXXXXX)
NAME="gcov2lcov-linux-amd64"
wget "https://github.com/jandelgado/gcov2lcov/releases/download/${VERSION}/${NAME}.tar.gz" -q -O - | tar zxf - --strip 1 --directory "$TMP_BIN"
chmod +x "$TMP_BIN/$NAME"
cd "$GITHUB_WORKSPACE/$WORKSPACE" || exit 1
exec "$TMP_BIN/gcov2lcov-linux-amd64" -infile "${INFILE}" -outfile "${OUTFILE}"
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