Have a catch all coded error for lint failures

This commit is contained in:
Simon Engledew 2020-12-01 15:41:04 +00:00
parent 145a3c1ed9
commit f99af1c014
No known key found for this signature in database
GPG key ID: 84302E7B02FE8BCE
3 changed files with 21 additions and 10 deletions

View file

@ -232,6 +232,7 @@ export const WorkflowErrors = toCodedErrors({
PathsSpecified: `Using on.push.paths can prevent Code Scanning annotating new alerts in your pull requests.`,
PathsIgnoreSpecified: `Using on.push.paths-ignore can prevent Code Scanning annotating new alerts in your pull requests.`,
CheckoutWrongHead: `git checkout HEAD^2 is no longer necessary. Please remove this step as Code Scanning recommends analyzing the merge commit for best results.`,
LintFailed: `Unable to lint workflow for CodeQL.`,
});
export function validateWorkflow(doc: Workflow): CodedError[] {
@ -332,13 +333,17 @@ export function validateWorkflow(doc: Workflow): CodedError[] {
}
export async function getWorkflowErrors(): Promise<CodedError[]> {
const workflow = await getWorkflow();
try {
const workflow = await getWorkflow();
if (workflow === undefined) {
return [];
if (workflow === undefined) {
return [];
}
return validateWorkflow(workflow);
} catch (e) {
return [WorkflowErrors.LintFailed];
}
return validateWorkflow(workflow);
}
export function formatWorkflowErrors(errors: CodedError[]): string {