Skip to content

Commit

Permalink
WIP: Extend GHA with a YAML/JSON linter
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Dowland <[email protected]>
  • Loading branch information
jmtd committed Apr 29, 2024
1 parent b2201a5 commit a605be9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/image-workflow-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ on:
env:
LANG: en_US.UTF-8
jobs:
validateYAML:
name: Validate YAML and JSON files touched by commit
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: Find YAML and JSON files and verify their syntax
run: ./tools/lint.sh
openjdkci:
name: OpenJDK S2I Build and Test
timeout-minutes: 60
Expand Down
23 changes: 23 additions & 0 deletions tools/lint.sh
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

0 comments on commit a605be9

Please sign in to comment.