Skip to content
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

Ignored/excluded warnings/errors should be re-evaluated to the current options when reusing cache #277

Open
lieryan opened this issue Jan 11, 2024 · 0 comments

Comments

@lieryan
Copy link
Contributor

lieryan commented Jan 11, 2024

Suppose that I have an app with one erroneous file:

$ ./manage.py lintmigrations --git-commit-id mycommit --no-cache --include-apps myapp  ; echo $?
*** Summary ***
Valid migrations: 0/15
Erroneous migrations: 1/15
Migrations with warnings: 0/15
Ignored migrations: 14/15
1

I can disable that warning with --exclude-migration-test:

$ ./manage.py lintmigrations --git-commit-id mycommit --no-cache --include-apps myapp --exclude-migration-test DROP_COLUMN DROP_TABLE  ; echo $?
*** Summary ***
Valid migrations: 1/15
Erroneous migrations: 0/15
Migrations with warnings: 0/15
Ignored migrations: 14/15
0

This is working well when passing --no-cache.

However, when caching is enabled:

$ ./manage.py lintmigrations --git-commit-id mycommit --cache-path dml-cache --include-apps myapp  ; echo $?
*** Summary ***
Valid migrations: 0/15
Erroneous migrations: 1/15
Migrations with warnings: 0/15
Ignored migrations: 14/15
1

When I re-run the command again with --exclude-migration-test, the result seems to have become fixated to the previous option due to the cache:

$ ./manage.py lintmigrations --git-commit-id mycommit --cache-path dml-cache --include-apps myapp --exclude-migration-test DROP_COLUMN DROP_TABLE  ; echo $?
*** Summary ***
Valid migrations: 0/15
Erroneous migrations: 1/15
Migrations with warnings: 0/15
Ignored migrations: 14/15
1

Same issue with --warnings-as-errors as well.

What I expect is that I should be able to re-run lintmigrations with different options and get the latest result based on the current set of options. django-migration-linter should either not cache anything that is based on the current options or it should bust the cache whenever the options changed.

This is particularly problematic because caching is always enabled by default when you don't pass in --cache-path or --no-cache. It leads to extremely confusing behavior that the options from previous runs affects the result of current run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant