Skip to content

Commit cdc8ef7

Browse files
authored
Log lines now don't affect annotations (#19)
1 parent e41d575 commit cdc8ef7

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

dist/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const lineReader = __webpack_require__(631);
1010
const fs = __webpack_require__(747);
1111

1212
try {
13+
const regex = /(\s*[\w\d]+_test.go:\d+:)(.*?)(Test:\s+Test[\w\d]*?%0A)/gu; // Extracts only the failure from the logs (including whitespace)
14+
1315
const testResultsPath = core.getInput('test-results');
1416
const customPackageName = core.getInput('package-name');
1517

@@ -56,10 +58,13 @@ try {
5658
lr.on('end', function() {
5759
for (const [key, value] of Object.entries(obj)) {
5860
if (value.includes("FAIL") && value.includes("_test.go")) {
59-
const parts = value.split("%0A")[1].trim().split(":");
60-
const file = key.split("/").slice(0, -1).join("/") + "/" + parts[0];
61-
const lineNumber = parts[1];
62-
core.info(`::error file=${file},line=${lineNumber}::${value}`)
61+
var result;
62+
while ((result = regex.exec(value)) !== null) {
63+
const parts = result[0].split(":");
64+
const file = key.split("/").slice(0, -1).join("/") + "/" + parts[0].trimStart();
65+
const lineNumber = parts[1];
66+
core.info(`::error file=${file},line=${lineNumber}::${result[0]}`);
67+
}
6368
}
6469
}
6570
});

index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const lineReader = require('line-by-line');
33
const fs = require('fs');
44

55
try {
6+
const regex = /(\s*[\w\d]+_test.go:\d+:)(.*?)(Test:\s+Test[\w\d]*?%0A)/gu; // Extracts only the failure from the logs (including whitespace)
7+
68
const testResultsPath = core.getInput('test-results');
79
const customPackageName = core.getInput('package-name');
810

@@ -49,10 +51,13 @@ try {
4951
lr.on('end', function() {
5052
for (const [key, value] of Object.entries(obj)) {
5153
if (value.includes("FAIL") && value.includes("_test.go")) {
52-
const parts = value.split("%0A")[1].trim().split(":");
53-
const file = key.split("/").slice(0, -1).join("/") + "/" + parts[0];
54-
const lineNumber = parts[1];
55-
core.info(`::error file=${file},line=${lineNumber}::${value}`)
54+
var result;
55+
while ((result = regex.exec(value)) !== null) {
56+
const parts = result[0].split(":");
57+
const file = key.split("/").slice(0, -1).join("/") + "/" + parts[0].trimStart();
58+
const lineNumber = parts[1];
59+
core.info(`::error file=${file},line=${lineNumber}::${result[0]}`);
60+
}
5661
}
5762
}
5863
});

0 commit comments

Comments
 (0)