diff --git a/src/rules/spec/githubActions/component.ts b/src/rules/spec/githubActions/component.ts index a28bffc2..32beca4b 100644 --- a/src/rules/spec/githubActions/component.ts +++ b/src/rules/spec/githubActions/component.ts @@ -50,9 +50,15 @@ export const detectGithubActionsComponent: ComponentMatcher = async ( continue; } - const parsed: GitHubActionsFile = parse(content, {}); - if (!parsed?.jobs) { - l.warn('Failed to parse GitHub Actions file', file.fp); + let parsed: GitHubActionsFile; + try { + parsed = parse(content, {}); + if (!parsed?.jobs) { + l.warn('No jobs in GitHub Actions', file.fp); + return false; + } + } catch (err) { + l.warn('Failed to parse', file.fp, err); return false; } diff --git a/tests/__fixtures__/.github/workflows/invalid.yml b/tests/__fixtures__/.github/workflows/invalid.yml new file mode 100644 index 00000000..948d8363 --- /dev/null +++ b/tests/__fixtures__/.github/workflows/invalid.yml @@ -0,0 +1,3 @@ +{{{{raw}}}} +name: Audit +{{{{/raw}}}}