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
3 changed files with 21 additions and 10 deletions
+10 -4
View File
@@ -178,6 +178,7 @@ exports.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.`,
});
function validateWorkflow(doc) {
var _a, _b, _c, _d, _e, _f, _g;
@@ -273,11 +274,16 @@ function validateWorkflow(doc) {
}
exports.validateWorkflow = validateWorkflow;
async function getWorkflowErrors() {
const workflow = await getWorkflow();
if (workflow === undefined) {
return [];
try {
const workflow = await getWorkflow();
if (workflow === undefined) {
return [];
}
return validateWorkflow(workflow);
}
catch (e) {
return [exports.WorkflowErrors.LintFailed];
}
return validateWorkflow(workflow);
}
exports.getWorkflowErrors = getWorkflowErrors;
function formatWorkflowErrors(errors) {
File diff suppressed because one or more lines are too long
+10 -5
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 {