dbt-labs / dbt-jsonschema

Apache License 2.0
109 stars 40 forks source link

Fix model validation, add CI #16

Closed kochalex closed 1 year ago

kochalex commented 1 year ago

When trying to use these schemas in a CI workflow with our DBT project, I ran into a few errors with the JSON schema documents with both Ajv and jsonschema.

This has a couple of fixes that allowed the schemas themselves to be validated as draft 7. (I used draft 7 since it's the most common from my experience, but it might also be good to add a $schema entry to the files). There's also a sample GitHub Actions CI workflow that tests using ajv-cli:

  1. If the schema files pass draft7
  2. Testing simple dbt_project.yml and model.yml files generated with dbt init.

Here's a run on my fork: https://github.com/kochalex/dbt-jsonschema/actions/runs/3048375813

Screen Shot 2022-09-13 at 4 22 48 PM

Separately, are there any plans for DBT to publish these schemas in a registry like https://schemas.getdbt.com/ or have them officially part of DBT?

I've pointed my VS Code at these updated files and our project's YAML files validate ok, but it should be noted that the existing files also seemed to work ok with the VS Code YAML extension, it was just the CI cases that failed (with two separate validators). I know CI is not the intended use case here. 😸

joellabes commented 1 year ago

Separately, are there any plans for DBT to publish these schemas in a registry like https://schemas.getdbt.com/ or have them officially part of DBT?

Not yet, but over time as they get more robust it's not out of the question! We're also thinking about listing on schemastore, but that has some tradeoffs (see #3)

kochalex commented 1 year ago

Ok, I've made the changes (caps and adding in $schema), would you like me to cleanup & squash the history on this?

joellabes commented 1 year ago

@kochalex we squash and merge so it's all good! Thank you for doing this 🌟