python-jsonschema / check-jsonschema

A CLI and set of pre-commit hooks for jsonschema validation with built-in support for GitHub Workflows, Renovate, Azure Pipelines, and more!
https://check-jsonschema.readthedocs.io/en/stable
Other
192 stars 38 forks source link

Validation fails when expression is used in `matrix.include` #272

Closed erdemedeiros closed 10 months ago

erdemedeiros commented 1 year ago

The rule check-github-workflows fails to validate a valid workflow when an expression is used to define the content of the attribute matrix.include. Example:

    strategy:
      matrix:
        include: ${{ fromJSON(needs.step-producing-json-without-include.outputs.result) }}

Workaround:

Move the attribute include as part of the generated json and and use the expression to define the content of the root matrix:

    strategy:
      matrix: ${{ fromJSON(needs.step-producing-json-with-include.outputs.result) }}
sirosen commented 1 year ago

check-jsonschema gets the schema for GitHub Workflows from Schemastore. Anyone (including me) looking to fix this will need to do a PR there to expand what's allowed by that schema.

I'd love to promise that I'll give it a shot, but my personal backlog has been growing so it may take me a while.

erdemedeiros commented 1 year ago

Sure, no problem. Thank you for the update and for taking the time of having a first look at this.

sirosen commented 10 months ago

I just got a chance to circle back around on this. I got a fix into schemastore, and just pushed a version of check-jsonschema (v0.26.1) to ship that here.

Let me know if it doesn't work for you, but you should now be able to use expressions in matrix.include!

erdemedeiros commented 10 months ago

Thank you! I confirm the validation passes now!