Skip to content

Commit

Permalink
Log lines now don't affect annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacLambat committed Apr 4, 2022
1 parent e41d575 commit b102aca
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 = /(\w+_test.go:\d+:)/g; // Extracts file name and line where test failures occurred

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}`)
const result = regex.exec(value);
if (result != null) {
const parts = result[0].split(":");
const file = parts[0]
const lineNumber = parts[1];
core.info(`::error file=${file},line=${lineNumber}::${value}`)
}
}
}
});
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 = /(\w+_test.go:\d+:)/g; // Extracts file name and line where test failures occurred

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}`)
const result = regex.exec(value);
if (result != null) {
const parts = result[0].split(":");
const file = parts[0]
const lineNumber = parts[1];
core.info(`::error file=${file},line=${lineNumber}::${value}`)
}
}
}
});
Expand Down

0 comments on commit b102aca

Please sign in to comment.