diff options
| author | Kevin J Hoerr <kjhoerr@protonmail.com> | 2021-09-17 12:25:32 -0400 |
|---|---|---|
| committer | Kevin J Hoerr <kjhoerr@protonmail.com> | 2021-09-17 12:25:32 -0400 |
| commit | cca92e4ba601b4a738807224b4abe53228bab1a0 (patch) | |
| tree | ad34fcdacbe981b6c7b35ba9fb1717242edfeef5 | |
| parent | e33d446ee8457f8ae114e33210382668efba92a9 (diff) | |
| download | ao-coverage-cca92e4ba601b4a738807224b4abe53228bab1a0.tar.gz ao-coverage-cca92e4ba601b4a738807224b4abe53228bab1a0.tar.bz2 ao-coverage-cca92e4ba601b4a738807224b4abe53228bab1a0.zip | |
#14 Changed /bash file to /sh
| -rw-r--r-- | CHANGELOG.md | 4 | ||||
| -rw-r--r-- | public/templates/index.html.template | 2 | ||||
| -rw-r--r-- | public/templates/sh.template (renamed from public/templates/bash.template) | 20 | ||||
| -rw-r--r-- | src/routes.test.ts | 14 | ||||
| -rw-r--r-- | src/routes.ts | 4 |
5 files changed, 25 insertions, 19 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cc01e3..dfefc27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Increased script file compatibility and moved to `/sh` + ## [0.5.0] ### Added diff --git a/public/templates/index.html.template b/public/templates/index.html.template index 4fb8930..2494e59 100644 --- a/public/templates/index.html.template +++ b/public/templates/index.html.template @@ -24,7 +24,7 @@ <p>If you have a coverage token, uploading a report is as easy as adding this line to your CI pipeline:</p> <div class="code-container-container"> <div class="code-container"> - <span class="shell code">bash <(curl -s {{TARGET_URL}}/bash)</span> + <span class="shell code">curl --proto '=https' --tlsv1.2 -sSf {{TARGET_URL}}/sh | sh</span> </div> </div> <p>Visit <a href="https://git.submelon.dev/kjhoerr/ao-coverage/wiki/Home" target="_blank">the AO Coverage diff --git a/public/templates/bash.template b/public/templates/sh.template index 375143e..0e8e34c 100644 --- a/public/templates/bash.template +++ b/public/templates/sh.template @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # Licensed under Parity Public License 7.0.0 # The full version of this license can be found here: @@ -15,13 +15,13 @@ curl_verbosity="" content_type="text/html" extension="html" -function verbose_say() { - if [ -z "$SILENT" ] && [ "$VERBOSE" == "true" ]; then +verbose_say() { + if [ -z "$SILENT" ] && [ "$VERBOSE" = "true" ]; then echo "$1" fi } -function say() { +say() { if [ -z "$SILENT" ]; then echo "$1" fi @@ -34,7 +34,7 @@ say verbose_say "Gathering report information . . ." -if [ "$CI" == "drone" ]; then +if [ "$CI" = "drone" ]; then verbose_say "Drone CI discovered - using Drone report info" commit="$DRONE_COMMIT" branch="$DRONE_BRANCH" @@ -51,15 +51,15 @@ verbose_say "Using branch: $branch" verbose_say "Using repo: $repo" verbose_say -if [ "$format" == "tarpaulin" ]; then +if [ "$format" = "tarpaulin" ]; then report="${REPORT_FILE:-tarpaulin-report.html}" -elif [ "$format" == "cobertura" ]; then +elif [ "$format" = "cobertura" ]; then report="${REPORT_FILE:-cobertura.xml}" content_type="application/xml" extension="xml" fi -if [[ ! -f "$report" ]]; then +if [ ! -f "$report" ]; then say "Report file could not be found." exit 1 fi @@ -75,7 +75,7 @@ response=$(curl -X POST --data-binary "@$report" \ $curl_verbosity \ "$url/v1/$repo/$branch/$commit.$extension?token=$token&format=$format") -if [ ! -z "$response" ]; then +if [ -n "$response" ]; then say "Error uploading report: $response" exit 1 else @@ -87,4 +87,4 @@ else 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
\ No newline at end of file +fi diff --git a/src/routes.test.ts b/src/routes.test.ts index 5ffd289..d761602 100644 --- a/src/routes.test.ts +++ b/src/routes.test.ts @@ -88,21 +88,21 @@ const HOST_DIR = configOrError("HOST_DIR"); const TARGET_URL = process.env.TARGET_URL ?? "http://localhost:3000"; describe("templates", () => { - describe("GET /bash", () => { - it("should return the bash file containing the curl command", async () => { + describe("GET /sh", () => { + it("should return the sh file containing the curl command", async () => { await persistTemplate({ inputFile: path.join( __dirname, "..", "public", "templates", - "bash.template" + "sh.template" ), - outputFile: path.join(HOST_DIR, "bash"), + outputFile: path.join(HOST_DIR, "sh"), context: { TARGET_URL } } as Template); - const res = await (await request()).get("/bash").expect(200); + const res = await (await request()).get("/sh").expect(200); expect(exit).not.toHaveBeenCalled(); expect(res.text).toMatch("curl -X POST"); expect(res.text).toMatch(`url="${TARGET_URL}"`); @@ -128,7 +128,9 @@ describe("templates", () => { .expect("Content-Type", /html/) .expect(200); expect(exit).not.toHaveBeenCalled(); - expect(res.text).toMatch(`bash <(curl -s ${TARGET_URL}/bash)`); + expect(res.text).toMatch( + `curl --proto '=https' --tlsv1.2 -sSf ${TARGET_URL}/sh | sh` + ); }); }); }); diff --git a/src/routes.ts b/src/routes.ts index d242902..3ab55ae 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -60,8 +60,8 @@ export default (metadata: Metadata): Router => { // serve script for posting coverage report router.use( - "/bash", - express.static(path.join(metadata.getHostDir(), "bash"), { + "/sh", + express.static(path.join(metadata.getHostDir(), "sh"), { setHeaders: res => res.contentType("text/plain") }) ); |
