-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update README.md and CHANGELOG.md to point to v1 * Rename $COVERAGE_REPORT_TRIM to $TRIM_PACKAGE * Rename "-root-pkg" flag to "-root" * Fail "Download go-coverage-report" job on non-zero status codes * Move downloading of binary into its own script * Use v0.4.0 version in GitHub CI workflow until v1.0.0 is actually released * Move Go code into "cmd" directory * Tell goreleaser where to find the main package * Support install go-coverage-report from local and remote source * Some more tweaking of input and variable naming
- Loading branch information
Showing
18 changed files
with
164 additions
and
80 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ builds: | |
- linux | ||
- windows | ||
- darwin | ||
main: ./cmd/go-coverage-report | ||
|
||
archives: | ||
- format: tar.gz | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
// Package coverage contains code to parse and format code coverage profiles. | ||
package main | ||
|
||
import ( | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e -o pipefail | ||
|
||
type curl > /dev/null 2>&1 || { echo >&2 'ERROR: Script requires "curl"'; exit 1; } | ||
type sha256sum > /dev/null 2>&1 || { echo >&2 'ERROR: Script requires "sha256sum"'; exit 1; } | ||
type tar > /dev/null 2>&1 || { echo >&2 'ERROR: Script requires "tar"'; exit 1; } | ||
|
||
USAGE="$0: Download the go-coverage-report binary from GitHub. | ||
This script is meant to be used as part of a GitHub action and makes use of Workflow commands as | ||
described in https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions | ||
Usage: | ||
$0 version [sha256sum] | ||
Example: | ||
$0 Linux X64 | ||
You can use the following environment variables to configure the script: | ||
- RUNNER_OS: The operating system of the runner (default: Linux) | ||
- RUNNER_ARCH: The architecture of the runner (default: X64) | ||
- DRY_RUN: Do not actually move the binary to /usr/bin (default: false) | ||
" | ||
|
||
if [[ $# == 0 ]]; then | ||
echo -e "Error: script requires at least one argument\n" | ||
echo "$USAGE" | ||
exit 1 | ||
fi | ||
|
||
VERSION=$1 | ||
RUNNER_OS=${RUNNER_OS:-Linux} | ||
RUNNER_ARCH=${RUNNER_ARCH:-X64} | ||
|
||
if [[ -z ${VERSION+x} ]]; then | ||
echo "Missing version argument" | ||
exit 1 | ||
fi | ||
|
||
if [[ $# == 2 ]]; then | ||
SHA256SUM=$2 | ||
fi | ||
|
||
sudo_or_dry_run="sudo" | ||
if [[ "$DRY_RUN" == "true" ]]; then | ||
sudo_or_dry_run='echo [DRY-RUN]: sudo' | ||
fi | ||
|
||
start_group(){ | ||
echo "::group::$*" | ||
{ set -x; return; } 2>/dev/null | ||
} | ||
|
||
end_group(){ | ||
{ set +x; return; } 2>/dev/null | ||
echo "::endgroup::" | ||
} | ||
|
||
if [[ $VERSION == "local" ]]; then | ||
start_group "Installing go-coverage-report from local source" | ||
go install -v ./cmd/go-coverage-report | ||
end_group | ||
exit 0 | ||
fi | ||
|
||
if [[ ${#VERSION} == 40 ]]; then | ||
start_group "Installing go-coverage-report from remote source" | ||
go install -v "github.com/fgrosse/go-coverage-report@$VERSION" | ||
end_group | ||
exit 0 | ||
fi | ||
|
||
start_group "Determining runner architecture" | ||
if [ "$RUNNER_ARCH" = "ARM64" ]; then | ||
ARCH="arm64" | ||
elif [ "$RUNNER_ARCH" = "ARM" ]; then | ||
ARCH="arm" | ||
elif [ "$RUNNER_ARCH" = "X86" ]; then | ||
ARCH="386" | ||
elif [ "$RUNNER_ARCH" = "X64" ]; then | ||
ARCH="amd64" | ||
else | ||
ARCH="amd64" | ||
fi | ||
end_group | ||
|
||
start_group "Downloading tar archive from GitHub" | ||
mkdir -p .github/outputs | ||
OS=$(echo "$RUNNER_OS" | tr '[:upper:]' '[:lower:]') | ||
FILENAME="go-coverage-report-${VERSION}-${OS}-${ARCH}.tar.gz" | ||
URL="https://github.com/fgrosse/go-coverage-report/releases/download/${VERSION}/${FILENAME}" | ||
curl --fail --location "$URL" --output ".github/outputs/$FILENAME" | ||
end_group | ||
|
||
if ! [[ "$SHA256SUM" ]] ; then | ||
start_group "Checking checksum using checksums.txt file from GitHub release" | ||
URL="https://github.com/fgrosse/go-coverage-report/releases/download/${VERSION}/checksums.txt" | ||
cd .github/outputs | ||
curl -fsSL "$URL" | sha256sum --check --ignore-missing | ||
cd - | ||
end_group | ||
else | ||
start_group "Checking checksum using provided SHA256 hash" | ||
echo "Actual sha256:" | ||
sha256sum ".github/outputs/$FILENAME" | ||
echo "Checking checksum" | ||
echo "$SHA256SUM .github/outputs/$FILENAME" | sha256sum -c | ||
end_group | ||
fi | ||
|
||
start_group "Decompressing tar archive" | ||
tar -xzf ".github/outputs/$FILENAME" -C .github/outputs/ go-coverage-report | ||
rm ".github/outputs/$FILENAME" | ||
end_group | ||
|
||
start_group "Move binary to /usr/bin" | ||
$sudo_or_dry_run mv .github/outputs/go-coverage-report /usr/bin | ||
end_group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters