Skip to content

Commit

Permalink
Log lines now don't affect annotations (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacLambat authored Apr 14, 2022
1 parent e41d575 commit cdc8ef7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
13 changes: 9 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const lineReader = __webpack_require__(631);
const fs = __webpack_require__(747);

try {
const regex = /(\s*[\w\d]+_test.go:\d+:)(.*?)(Test:\s+Test[\w\d]*?%0A)/gu; // Extracts only the failure from the logs (including whitespace)

const testResultsPath = core.getInput('test-results');
const customPackageName = core.getInput('package-name');

Expand Down Expand Up @@ -56,10 +58,13 @@ try {
lr.on('end', function() {
for (const [key, value] of Object.entries(obj)) {
if (value.includes("FAIL") && value.includes("_test.go")) {
const parts = value.split("%0A")[1].trim().split(":");
const file = key.split("/").slice(0, -1).join("/") + "/" + parts[0];
const lineNumber = parts[1];
core.info(`::error file=${file},line=${lineNumber}::${value}`)
var result;
while ((result = regex.exec(value)) !== null) {
const parts = result[0].split(":");
const file = key.split("/").slice(0, -1).join("/") + "/" + parts[0].trimStart();
const lineNumber = parts[1];
core.info(`::error file=${file},line=${lineNumber}::${result[0]}`);
}
}
}
});
Expand Down
13 changes: 9 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const lineReader = require('line-by-line');
const fs = require('fs');

try {
const regex = /(\s*[\w\d]+_test.go:\d+:)(.*?)(Test:\s+Test[\w\d]*?%0A)/gu; // Extracts only the failure from the logs (including whitespace)

const testResultsPath = core.getInput('test-results');
const customPackageName = core.getInput('package-name');

Expand Down Expand Up @@ -49,10 +51,13 @@ try {
lr.on('end', function() {
for (const [key, value] of Object.entries(obj)) {
if (value.includes("FAIL") && value.includes("_test.go")) {
const parts = value.split("%0A")[1].trim().split(":");
const file = key.split("/").slice(0, -1).join("/") + "/" + parts[0];
const lineNumber = parts[1];
core.info(`::error file=${file},line=${lineNumber}::${value}`)
var result;
while ((result = regex.exec(value)) !== null) {
const parts = result[0].split(":");
const file = key.split("/").slice(0, -1).join("/") + "/" + parts[0].trimStart();
const lineNumber = parts[1];
core.info(`::error file=${file},line=${lineNumber}::${result[0]}`);
}
}
}
});
Expand Down

0 comments on commit cdc8ef7

Please sign in to comment.