in src/main.ts [102:133]
async function run() {
try {
const linterOutputPath = core.getInput('linter_output_path');
console.log(`Reading linter output from: ${GITHUB_WORKSPACE}/${linterOutputPath}`)
const output = await fs.promises.readFile(`${GITHUB_WORKSPACE}/${linterOutputPath}`);
const mode = core.getInput('mode');
let annotations: Annotation[];
if (mode === 'regex') {
const regex = core.getInput('regex');
annotations = parseOutputLines(output.toString(), RegExp(regex))
} else if (mode === 'json') {
annotations = parseOutputJSON(output.toString());
} else {
throw `Mode '${mode}' not recognized.`;
}
if (annotations.length > 0) {
console.log("===============================================================")
console.log("| FAILURES DETECTED |")
console.log("| You don't need to read this log output. |")
console.log("| Check the 'Files changed' tab for in-line annotations! |")
console.log("===============================================================")
console.log(annotations);
const checkName = core.getInput('check_name');
await createCheck(checkName, 'failures detected', annotations);
console.log(`${annotations.length} errors(s) found`);
}
}
catch (error) {
core.setFailed(error.message);
}
}