aboutsummaryrefslogtreecommitdiff
path: root/public/templates
diff options
context:
space:
mode:
authorKevin J Hoerr <kjhoerr@protonmail.com>2019-12-29 01:00:49 -0500
committerKevin J Hoerr <kjhoerr@protonmail.com>2019-12-29 01:00:49 -0500
commit309e12033b76c2221b6b5c761c620816dc0d945d (patch)
tree27ee2355f29958084402d43b03f1d96bcd991c8f /public/templates
parent5f99b8e36d22a54a6a5ef17b43c1b3c33e560cef (diff)
downloadao-coverage-309e12033b76c2221b6b5c761c620816dc0d945d.tar.gz
ao-coverage-309e12033b76c2221b6b5c761c620816dc0d945d.tar.bz2
ao-coverage-309e12033b76c2221b6b5c761c620816dc0d945d.zip
Move template files to subfolder
More static files will likely be used that do not require using a template (e.g. favicon.ico), so storing them in the public folder will keep them with other served files without getting them confused with the templates.
Diffstat (limited to 'public/templates')
-rw-r--r--public/templates/bash.template72
-rw-r--r--public/templates/index.html.template17
2 files changed, 89 insertions, 0 deletions
diff --git a/public/templates/bash.template b/public/templates/bash.template
new file mode 100644
index 0000000..08a5913
--- /dev/null
+++ b/public/templates/bash.template
@@ -0,0 +1,72 @@
+#!/usr/bin/env bash
+
+# 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="tarpaulin"
+report=""
+token="$COV_TOKEN"
+
+function verbose_say() {
+ if [ -z "$QUIET" ] || [ "$VERBOSE" == "true" ]; then
+ echo "$1"
+ fi
+}
+
+verbose_say "==========================="
+verbose_say " ao-coverage "
+verbose_say "==========================="
+verbose_say
+
+verbose_say "Gathering report information . . ."
+
+if [ "$CI" == "drone" ]; 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}"
+fi
+
+if [[ ! -f "$report" ]]; then
+ echo "Report file could not be found."
+ exit 1
+fi
+
+verbose_say "Uploading $report . . ."
+
+response=$(curl -X POST --data-binary "@$report" \
+ -H 'Content-Type: text/html' \
+ "$url/v1/$repo/$branch/$commit.html?token=$token&format=$format")
+
+if [ ! -z "$response" ]; then
+ echo "Error uploading report: $response"
+ exit 1
+else
+ echo "Successfully uploaded report!"
+ verbose_say
+ verbose_say "View uploaded report at: $url/v1/$repo/$branch/$commit.html"
+ verbose_say "View coverage badge at: $url/v1/$repo/$branch/$commit.svg"
+ verbose_say
+ verbose_say "Shorthand links are also available, as the latest commit of this branch."
+ verbose_say "View latest report for branch $branch: $url/v1/$repo/$branch.html"
+ verbose_say "View latest badge for branch $branch: $url/v1/$repo/$branch.svg"
+fi \ No newline at end of file
diff --git a/public/templates/index.html.template b/public/templates/index.html.template
new file mode 100644
index 0000000..0dfbee7
--- /dev/null
+++ b/public/templates/index.html.template
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="en-US">
+
+<head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <meta http-equiv="x-ua-compatible" content="ie=edge" />
+ <title>AO Coverage: Simple code coverage tracking</title>
+</head>
+
+<body>
+ <div id="content">
+ <span class="code">bash &lt;(curl -s {{TARGET_URL}}/bash)</span>
+ </div>
+</body>
+
+</html> \ No newline at end of file