-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
All files are included when a non-DBT yaml file is edited #163
Comments
I think I just ran into this issue myself, ironically while adding dbt-checkpoint to the project. This required adding or editing these files to the root of the project:
Which then triggered dbt-checkpoint to run for the entire project on commit, finding a large number of non-compliant files and in theory preventing me from commiting changes to implement dbt-checkpoint in the first place until all the issues are resolved. Not sure if this is intentional or not? |
It depends on how you are running it. We only check files changed in a given PR, not the whole project On Nov 16, 2023, at 7:47 PM, Nathan Griffiths ***@***.***> wrote:
I think I just ran into this issue myself, ironically while adding dbt-checkpoint to the project. This required adding or editing these files to the root of the project:
.dbt-checkpoint.yaml
.pre-commit-config.yaml
Which then triggered dbt-checkpoint to run for the entire project on commit, finding a large number of non-compliant files and preventing me from commiting changes to implement dbt-checkpoint in the first place until all the issues are resolved. Not sure if this is intentional or not but it makes it pretty hard to justify implementing if it requires the entire project to be issue free just to install it.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Environment: Git repo structure: dbt_project_folder contains an existing dbt project with a large number of non-compliant files. Steps .dbt-checkpoint.yaml
.pre-commit-config.yaml
Now commit the changes: Output:
I may be doing something wrong here but I can't see what it might be. It definitely looks like these hooks are running for all models in the dbt project, not just the two files I am actually committing. |
The workaround for this e.g. when adding dbt-checkpoint to a new repo is:
After this it appears dbt-checkpoint will only include staged files in checks as intended. |
Describe the bug
I believe pre-commit should only check files staged to be committed. However, if one of the files edited is in the root directory and is a
yml
orsql
file , all files are checked.This is due to the
get_missing_file_paths
adding the paths for everything.check-model-has-tests
and other hooks are effected.To Reproduce
Steps to reproduce the behavior:
check-model-has-tests
.pre-commit-config.yaml
Expected behavior
Only files staged for the commit (and those directly related, such as properties files) should be checked
Version:
v0.1.1
Additional context
I think the problem is that root files break the logic in
_add_related_sqls
. To prevent this adding an additional condition here:elif (suffix == ".yml" or suffix == ".yaml") and ".sql" in extensions and Path(path).parent != Path('.'):
fixes it.
Happy to raise a PR if useful.
The text was updated successfully, but these errors were encountered: