in eng/tools/lint-diff/src/lint-diff.ts [100:163]
async function runLintDiff(
beforePath: string,
afterPath: string,
changedFilesPath: string,
outFile: string,
baseBranch: string,
compareSha: string,
) {
const [beforeList, afterList, affectedSwaggers] = await getRunList(
beforePath,
afterPath,
changedFilesPath,
);
if (beforeList.size === 0 && afterList.size === 0) {
console.log("No changes found. Exiting.");
return;
}
// It may be possible to run these in parallel as they're running against
// different directories.
const beforeChecks = await runChecks(beforePath, beforeList);
const afterChecks = await runChecks(afterPath, afterList);
// If afterChecks has AutoRest errors, fail the run.
const autoRestErrors = afterChecks
.map((result) => {
return { result, errors: getAutorestErrors(result) };
})
.filter((result) => result.errors.length > 0);
if (autoRestErrors.length > 0) {
generateAutoRestErrorReport(autoRestErrors, outFile);
console.log("AutoRest errors found. See workflow summary for details.");
process.exitCode = 1;
console.error(`AutoRest errors found. See workflow summary report in ${outFile} for details.`);
return;
}
const runCorrelations = await correlateRuns(beforePath, beforeChecks, afterChecks);
const pass = await generateLintDiffReport(
runCorrelations,
affectedSwaggers,
outFile,
baseBranch,
compareSha,
);
if (!pass) {
process.exitCode = 1;
console.error(`Lint-diff failed. See workflow summary report in ${outFile} for details.`);
}
if (
process.env.GITHUB_SERVER_URL &&
process.env.GITHUB_REPOSITORY &&
process.env.GITHUB_RUN_ID
) {
console.log(
`See workflow summary at: ${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
);
}
}