-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Extend GHA with a YAML/JSON linter
Signed-off-by: Jonathan Dowland <[email protected]>
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
ret=0 | ||
|
||
# XXX this will only work for one commit PRs. Need to diff against the | ||
# merge base | ||
git diff-tree --no-commit-id --name-only HEAD -r |\ | ||
while read f; do | ||
case "${f##*.}" in | ||
yaml) | ||
# XXX we could use yamllint but it's too noisy for now | ||
yq < "$f" >/dev/null || { | ||
echo "$f is not valid YAML" | ||
ret=1 | ||
} | ||
;; | ||
json) | ||
jq < "$f" >/dev/null || { | ||
echo "$f is not valid JSON"; | ||
ret=1 | ||
} | ||
;; | ||
esac | ||
done | ||
exit $ret |