From e31779e27da0ed6eef90f4cf32c6dfc2f297ae1b Mon Sep 17 00:00:00 2001 From: Septs Date: Sun, 18 Oct 2020 03:06:19 +0800 Subject: [PATCH] simplify code and update docs (#9) * rename workspace to working-directory * update readme * cache binary in temporary directory * remove entrypoint.sh * add cache test * remove cache --- .github/workflows/test.yml | 2 +- README.md | 20 +++++++++++++++----- action.yml | 21 +++++++++++---------- entrypoint.sh | 9 --------- 4 files changed, 27 insertions(+), 25 deletions(-) delete mode 100755 entrypoint.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b2bfb43..dc8768f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: - name: Run gcov2lcov-action uses: ./ with: - workspace: testdata + working-directory: testdata - name: Diff run: diff -y coverage_expected.lcov coverage.lcov working-directory: testdata diff --git a/README.md b/README.md index ad8c2ae..09af85b 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,19 @@ uses [gcov2lcov](https://github.com/jandelgado/gcov2lcov) under the hood. ### `infile` -**Required** Name of the go coverage file. Default `coverage.out`. +**Optional** Name of the go coverage file. Default `coverage.out`. ### `outfile` -**Required** Name of the lcov file to write. Default `coverage.lcov`. +**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 the change to specific working-directory. ## Outputs @@ -23,10 +31,12 @@ No outputs. ## Example usage ```yaml -uses: jandelgado/gcov2lcov-action@v1.0.4 +uses: jandelgado/gcov2lcov-action@v1.0.5 with: - infile: coverage.out - outfile: coverage.lcov + 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 diff --git a/action.yml b/action.yml index 6ee4608..bdacab4 100644 --- a/action.yml +++ b/action.yml @@ -14,19 +14,20 @@ inputs: version: description: "gcov2lcov version" required: true - default: v1.0.4 - workspace: - description: "working directory" + default: latest + working-directory: + description: "change working directory" required: false runs: using: composite steps: - - name: Run gcov2lcov - run: ${{ github.action_path }}/entrypoint.sh - shell: bash + - shell: bash + run: 'set -x && curl -sLf "${RELEASE}/${NAME}.tar.gz" | tar zxf - --strip 1' + working-directory: /tmp env: - INFILE: ${{ inputs.infile }} - OUTFILE: ${{ inputs.outfile }} - VERSION: ${{ inputs.version }} - WORKSPACE: ${{ inputs.workspace }} + NAME: "gcov2lcov-linux-amd64" + RELEASE: "https://github.com/jandelgado/gcov2lcov/releases/${{inputs.version}}/download" + - shell: bash + run: set -x && /tmp/gcov2lcov-linux-amd64 -infile "${{ inputs.infile }}" -outfile "${{ inputs.outfile }}" + working-directory: ${{ inputs.working-directory }} diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100755 index 5baddbf..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -set -xeuo pipefail - -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}"