diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1c80bea..b2bfb43 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,29 +1,26 @@ -on: [push, pull_request] -name: test +name: Test + +on: + 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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 68cf8ba..6900aaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 + () ## 1.0.0 [2019-10-07] -* initial release +- initial release diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index a7a6b3e..0000000 --- a/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -# note: gcov2lcov also needs a running go executable in the container, so we -# keep this as the base -FROM golang:1.15-alpine - -ARG VERSION=v1.0.4 - -LABEL MAINTAINER="Jan Delgado " -LABEL "com.github.actions.description"="convert golang coverager to lcov format" -LABEL "com.github.actions.name"="gcov2lcov-action" -LABEL "com.github.actions.color"="blue" - -WORKDIR /app -ADD . /app - -ENV GOROOT=/usr/local/go -RUN wget https://github.com/jandelgado/gcov2lcov/releases/download/${VERSION}/gcov2lcov-linux-amd64.tar.gz -q -O - |\ - tar xvzf - --strip 1\ - && chmod 755 gcov2lcov-linux-amd64 - -COPY entrypoint.sh / - -ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index 7d2b2a4..ad8c2ae 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 © 2019 - 2020 Jan Delgado -MIT +## License +[MIT](LICENSE) diff --git a/action.yml b/action.yml index b79af27..6ee4608 100644 --- a/action.yml +++ b/action.yml @@ -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 }} diff --git a/entrypoint.sh b/entrypoint.sh index 153b821..5baddbf 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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}" diff --git a/testdata/go.mod b/testdata/go.mod new file mode 100644 index 0000000..61209db --- /dev/null +++ b/testdata/go.mod @@ -0,0 +1,3 @@ +module github.com/jandelgado/gcov2lcov + +go 1.15 diff --git a/testdata/main.go b/testdata/main.go new file mode 100644 index 0000000..06ab7d0 --- /dev/null +++ b/testdata/main.go @@ -0,0 +1 @@ +package main