ci: add JSON syntax validation for release-notes files#3009
Conversation
|
|
|
Welcome @rduffyuk! |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rduffyuk The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
Adds a new GitHub Actions workflow to validate JSON syntax for release-notes artifacts in PRs, aiming to prevent malformed release-notes JSON from being merged and breaking downstream rendering (relnotes.k8s.io).
Changes:
- Introduces
.github/workflows/validate-release-notes-json.yamlto runjq emptyon changedreleases/release-*/release-notes/**/*.jsonfiles in pull requests. - Detects added/modified JSON files via
git diffand surfaces failures as GitHub Actions annotations.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 |
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: read |
|
/kind feature |
rduffyuk
left a comment
There was a problem hiding this comment.
comments replied to see inline thxs
|
Quick housekeeping note on the Copilot review — when I was replying inline some of my replies landed on the wrong threads (the SHA-pin reply ended up on the deleted-file thread), and the SHA-pin and For the avoidance of doubt, all 5 fixes from Copilot's review are in
Local testing details are in the PR description's Testing section. Happy to walk through any part in further review. |
Summary
Adds a GitHub Actions workflow that runs
jq emptyagainst changedreleases/release-*/release-notes/**/*.jsonfiles on PRs, failing thecheck with inline annotations if any file has invalid JSON syntax.
Closes #2985.
Why
Release notes JSON gets manually edited during alpha → beta → RC. A trailing
comma or an unmatched brace in a manual edit silently breaks downstream
rendering on https://relnotes.k8s.io/ after the release ships. Catching it at
PR time is cheaper than catching it post-release.
There are 17
release-notes-draft.jsonfiles in the tree today (release-1.21through
release-1.36) — any of them being touched mid-cycle should pay this~5-second validation cost.
This is complementary to the existing
krel-release-notes-validate.yamlworkflow, which validates YAML release-notes files via
krel. JSON syntaxvalidation isn't covered there because the path filter is YAML-only.
What it does
releases/release-*/release-notes/**/*.jsongit diff --diff-filter=AMagainst the PR basejq empty <file>against each (preinstalled onubuntu-latest, no setup needed)::error file=...annotations so failures appear inline in the PR's "Files changed" tab; messages are URL-encoded per GitHub's workflow command specWhat it doesn't do (intentional scope)
master— runs only on PRs.--diff-filter=AMexcludes deletions, so the workflow simply doesn't trigger when only deletions occur.Testing — local validation against real data
Verified the core behaviour locally against the actual
release-1.36release-notes JSON in this repo:
Valid JSON → silent success, exit 0:
Deliberately corrupted JSON → parse error with file:line, exit 5:
This proves both halves: the workflow correctly accepts well-formed
release-notes JSON, and correctly rejects malformed JSON with a parse error
that identifies the offending line. The
::error file=...::annotation inthe workflow surfaces the same
line:columninformation inline on the PR's"Files changed" tab so reviewers can click straight to the broken file.
No-op behaviour: the path filter on
pull_requestensures the workflowdoes not run at all on PRs that don't touch matching JSON files, so there is
no false-positive risk on unrelated PRs.
Disclosure
AI-assisted: workflow YAML drafted with Claude, reviewed and adapted by me
against the actual
release-notes-draft.jsonschema and file layout in thisrepo. I addressed the initial Copilot review feedback (license header, action
SHA pinning, removal of dead deleted-file branch, GitHub Actions message
escaping, dropping unused
pull-requests: readpermission) in the sameamend. I understand every line of the workflow, ran the local validation
above myself, and own the implementation. Happy to walk through any part in
review.