From 48645c385003e0c362bf954d4018895be76f1d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Strza=C5=82kowski?= Date: Mon, 8 Feb 2021 05:15:28 +0100 Subject: [PATCH] add configuration for custom pkg names (#5) --- README.md | 1 + index.js | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9a0b8e2..2bc2b6f 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ jobs: uses: guyarb/golang-test-annoations@v0.3.0 with: test-results: test.json + package-name: foobar # optional, if using custom package name, github.com/owner/repo stripped from the pathname by default ``` ## Development of this action diff --git a/index.js b/index.js index efad278..45ebbbd 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ const lineReader = require('line-by-line'); try { const testResultsPath = core.getInput('test-results'); + const customPackageName = core.getInput('package-name'); var obj = new Object(); var lr = new lineReader(testResultsPath); @@ -18,8 +19,12 @@ try { return; } output = output.replace("\n", "%0A").replace("\r", "%0D") - // Removing the github.com/owner/reponame + // Strip github.com/owner/repo package from the path by default var packageName = currentLine.Package.split("/").slice(3).join("/"); + // If custom package is provided, strip custom package name from the path + if (customPackageName != null) { + packageName = currentLine.Package.replace(customPackageName + "/", "") + } var newEntry = packageName + "/" + testName; if (!obj.hasOwnProperty(newEntry)) { obj[newEntry] = output;