ccao-data / data-architecture

Codebase for CCAO data infrastructure construction and management
https://ccao-data.github.io/data-architecture/
6 stars 4 forks source link

Move `check_sort_dbt_yaml_files` linter to pre-commit #644

Closed jeancochrane closed 1 week ago

jeancochrane commented 1 week ago

The dbt YAML sort order linter we introduced in https://github.com/ccao-data/data-architecture/pull/578 is awesome, but I find it annoying that I only get notified of failures after I've already pushed a commit. This PR updates our config to move the linter into pre-commit so that we can be notified of failures more proactively.

In order to speed up the pre-commit hook when installed locally, this PR also adjusts the interface for the check_sort_dbt_yaml_files.py script so that it can accept a list of filepaths from pre-commit to check for errors. When testing locally on one YAML file changed to have an incorrect sort order, the check fails nearly instantly.