From a605be9d98ad7c0213b0943f4f4e8921bbbb4a80 Mon Sep 17 00:00:00 2001 From: Jonathan Dowland Date: Mon, 29 Apr 2024 14:07:21 +0100 Subject: [PATCH 1/4] WIP: Extend GHA with a YAML/JSON linter Signed-off-by: Jonathan Dowland --- .github/workflows/image-workflow-template.yml | 10 ++++++++ tools/lint.sh | 23 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100755 tools/lint.sh diff --git a/.github/workflows/image-workflow-template.yml b/.github/workflows/image-workflow-template.yml index 0a23e8ac..753b05b7 100644 --- a/.github/workflows/image-workflow-template.yml +++ b/.github/workflows/image-workflow-template.yml @@ -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 diff --git a/tools/lint.sh b/tools/lint.sh new file mode 100755 index 00000000..ca0b85de --- /dev/null +++ b/tools/lint.sh @@ -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 From c54c9480d8970fa83e6b7b4916012eabe65b5e9b Mon Sep 17 00:00:00 2001 From: Jonathan Dowland Date: Mon, 29 Apr 2024 14:10:22 +0100 Subject: [PATCH 2/4] temporary test commits, break syntax --- templates/image-streams.json | 4 ++++ ubi9-openjdk-17.yaml | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/templates/image-streams.json b/templates/image-streams.json index 840f11e0..83b3cd27 100644 --- a/templates/image-streams.json +++ b/templates/image-streams.json @@ -22,6 +22,10 @@ "labels": { "xpaas": "1.4.17" } + + + deliberately broken file + }, "spec": { "tags": [ diff --git a/ubi9-openjdk-17.yaml b/ubi9-openjdk-17.yaml index f75306af..f1f66249 100644 --- a/ubi9-openjdk-17.yaml +++ b/ubi9-openjdk-17.yaml @@ -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" From 853cb049cbd7e830bf01e734d084540ef36b67a7 Mon Sep 17 00:00:00 2001 From: Jonathan Dowland Date: Mon, 29 Apr 2024 14:13:20 +0100 Subject: [PATCH 3/4] fixup! WIP: Extend GHA with a YAML/JSON linter --- .github/workflows/image-workflow-template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/image-workflow-template.yml b/.github/workflows/image-workflow-template.yml index 753b05b7..1a307700 100644 --- a/.github/workflows/image-workflow-template.yml +++ b/.github/workflows/image-workflow-template.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Find YAML and JSON files and verify their syntax run: ./tools/lint.sh openjdkci: From 445cff5f56c3486f45e725ed164dbc58d55285b1 Mon Sep 17 00:00:00 2001 From: Jonathan Dowland Date: Mon, 29 Apr 2024 14:15:03 +0100 Subject: [PATCH 4/4] fixup! WIP: Extend GHA with a YAML/JSON linter --- tools/lint.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/lint.sh b/tools/lint.sh index ca0b85de..6e5bb7a8 100755 --- a/tools/lint.sh +++ b/tools/lint.sh @@ -1,7 +1,8 @@ ret=0 # XXX this will only work for one commit PRs. Need to diff against the -# merge base +# 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