Skip to content

Commit

Permalink
Merge pull request #3 from Krizzu/v1.0.1-testing
Browse files Browse the repository at this point in the history
fix: handle annotation amount larger than 50
  • Loading branch information
Krzysztof authored Mar 4, 2020
2 parents 3f7443d + 21fbf06 commit c5c2340
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion src/eslintRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,50 @@ class EslintRunner {
this.checkRunID = await this.startGitHubCheck();
const report = this.runEslintCheck()!;
const { success, annotations, counts } = this.prepareAnnotation(report);
this.finishGitHubCheck(success, annotations, counts);

// if annotations are too large, split them into check-updates
let restOfAnnotation = await this.handleAnnotations(annotations, counts);

this.finishGitHubCheck(success, restOfAnnotation, counts);
};

private handleAnnotations = async (
annotations: Array<GitHubAnnotation>,
counts: ReportCounts
) => {
let leftAnnotations = [...annotations];
if (leftAnnotations.length > 50) {
while (leftAnnotations.length > 50) {
let toProcess = leftAnnotations.splice(0, 50);
try {
await this.updateAnnotation(toProcess, counts);
} catch (e) {
exitWithError(`Fail processing annotations: ${e.message}`);
}
}
}
return leftAnnotations;
};

private updateAnnotation = async (
annotations: Array<GitHubAnnotation>,
counts: ReportCounts
) => {
try {
await this.kit.checks.update({
owner: this.opts.repoOwner,
repo: this.opts.repoName,
check_run_id: this.checkRunID,
status: 'in_progress',
output: {
title: this.name,
summary: `Found ${counts.error} error(s), ${counts.warning} warning(s).`,
annotations,
},
});
} catch (e) {
exitWithError(e.message);
}
};

private startGitHubCheck = async () => {
Expand Down

0 comments on commit c5c2340

Please sign in to comment.