Skip to content

WIP: Extend GHA with a YAML/JSON linter #490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: ubi9
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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@v4
- 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
4 changes: 4 additions & 0 deletions templates/image-streams.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
"labels": {
"xpaas": "1.4.17"
}


deliberately broken file

},
"spec": {
"tags": [
Expand Down
24 changes: 24 additions & 0 deletions tools/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ret=0

# XXX this will only work for one commit PRs. Need to diff against the
# merge base. Note also GHA checkout@v4 will only fetch the top-most
# commit by default!
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
5 changes: 5 additions & 0 deletions ubi9-openjdk-17.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ labels:
value: "openjdk-17-ubi9-container"
- name: "usage"
value: &docs "https://jboss-container-images.github.io/openjdk/"



deliberately broken yaml file

- name: "com.redhat.license_terms"
value: "https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI"
- name: "org.opencontainers.image.documentation"
Expand Down
Loading