From e3f21afa451f8c8cb5743cd08fe3c3450ff5a75b Mon Sep 17 00:00:00 2001 From: Kevin J Hoerr Date: Thu, 7 Oct 2021 16:47:35 +0000 Subject: Use *.tmpl file extension over *.template --- public/templates/sh.tmpl | 90 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 public/templates/sh.tmpl (limited to 'public/templates/sh.tmpl') diff --git a/public/templates/sh.tmpl b/public/templates/sh.tmpl new file mode 100644 index 0000000..049b0b2 --- /dev/null +++ b/public/templates/sh.tmpl @@ -0,0 +1,90 @@ +#!/usr/bin/env sh + +# Licensed under Parity Public License 7.0.0 +# The full version of this license can be found here: +# https://git.submelon.dev/kjhoerr/ao-coverage/raw/branch/trunk/LICENSE.md + +url="{{TARGET_URL}}" +commit="" +branch="" +repo="" +format="${FORMAT:-tarpaulin}" +report="" +token="$COV_TOKEN" +curl_verbosity="" +content_type="text/html" +extension="html" + +verbose_say() { + if [ -z "$SILENT" ] && [ "$VERBOSE" = "true" ]; then + echo "$1" + fi +} + +say() { + if [ -z "$SILENT" ]; then + echo "$1" + fi +} + +say "===========================" +say " ao-coverage " +say "===========================" +say + +verbose_say "Gathering report information . . ." + +if [ "$CI" = "true" ] && [ "$DRONE" = "true" ] ; then + verbose_say "Drone CI discovered - using Drone report info" + commit="$DRONE_COMMIT" + branch="$DRONE_BRANCH" + repo="$DRONE_REPO" +else + verbose_say "Using environment variables for report info" + commit="$VCS_COMMIT" + branch="$VCS_BRANCH" + repo="$VCS_REPO" +fi + +verbose_say "Using commit #: $commit" +verbose_say "Using branch: $branch" +verbose_say "Using repo: $repo" +verbose_say + +if [ "$format" = "tarpaulin" ]; then + report="${REPORT_FILE:-tarpaulin-report.html}" +elif [ "$format" = "cobertura" ]; then + report="${REPORT_FILE:-cobertura.xml}" + content_type="application/xml" + extension="xml" +fi + +if [ ! -f "$report" ]; then + say "Report file could not be found." + exit 1 +fi + +if [ "$VERBOSE" != "true" ]; then + curl_verbosity="-s" +fi + +say "Uploading $report . . ." + +response=$(curl -X POST --data-binary "@$report" \ + -H "Content-Type: $content_type" \ + $curl_verbosity \ + "$url/v1/$repo/$branch/$commit.$extension?token=$token&format=$format") + +if [ -n "$response" ]; then + say "Error uploading report: $response" + exit 1 +else + say "Successfully uploaded report!" + say + say "View uploaded report at: $url/v1/$repo/$branch/$commit.$extension" + say "View coverage badge at: $url/v1/$repo/$branch/$commit.svg" + say + say "Shorthand links are also available, as the latest commit of this branch." + say "View latest report for branch $branch: $url/v1/$repo/$branch.$extension" + say "View latest badge for branch $branch: $url/v1/$repo/$branch.svg" +fi -- cgit