Favourite Github Action for validating JSON/YAML

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.

1 Like

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…) :smiley: 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
    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 :slight_smile: It essentially checks if name.json conforms to the name.schema.json.
Under the hood it’s simply a call to pips 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 :slight_smile:

1 Like

@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.