Does anyone out there have a favourite Github Action(s) for validating JSON and YAML files? There’re a few out there and I’m curious whether anyone has had good/bad experiences with any of them.
Hey @dougiesquire !
So it’s funny you say that…I’ve created a workflow that does just that as part of
build-ci (at least, for the JSON side of things…) found here: https://github.com/ACCESS-NRI/build-ci/blob/main/.github/workflows/validate-json.yml
You can invoke it in your own workflows with:
- uses: access-nri/build-ci/.github/workflows/validate-json.yml@main with: src: "some/directory"
Note that the
*.schema.json files need to be in the same
src directory for now, but if there’s appetite this can be changed It essentially checks if
name.json conforms to the
Under the hood it’s simply a call to
jsonschema package, of which many implementations exist - if you wanted to customize it a bit more!
Let me know if you need a hand with it!
In terms of actions that can do both, your best bet might be GrantBirki/json-yaml-validate
The config validation branch I am about to merge validates yaml against a schema. It should be straightforward to load the methods out of benchcab and use in an action.