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.
Ping @TommyGatti
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 *.json
and *.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 name.schema.json
.
Under the hood it’s simply a call to pip
s 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
@SeanBryan51 @ben Should we look into that for bench_example
? There aren’t many changes coming into that file so maybe not a priority.
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.