Skip to content

Commit

Permalink
fix(githubActions): handle invalid yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
bodinsamuel committed Nov 6, 2023
1 parent 0649e49 commit 940924d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/rules/spec/githubActions/component.ts
Expand Up @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions tests/__fixtures__/.github/workflows/invalid.yml
@@ -0,0 +1,3 @@
{{{{raw}}}}
name: Audit
{{{{/raw}}}}

0 comments on commit 940924d

Please sign in to comment.