Skip to content

Commit

Permalink
Add Django 4.2 compat' and update test dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Wobrock committed Jul 2, 2023
1 parent f511d51 commit 366d16b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 31 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

mysql:
image: mysql:5.7
image: mysql:8.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
ports:
Expand All @@ -42,7 +42,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python -m pip install tox==3.28.0 tox-gh-actions
run: python -m pip install tox==4.6.3 tox-gh-actions
- name: Test with tox ${{ matrix.python-version }}
run: tox

Expand All @@ -52,12 +52,12 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- name: Install dependencies
run: python -m pip install tox==3.28.0
run: python -m pip install tox==4.6.3
- name: Lint with tox
run: tox
env:
Expand All @@ -76,7 +76,7 @@ jobs:
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

mysql:
image: mysql:5.7
image: mysql:8.0
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
ports:
Expand All @@ -89,18 +89,18 @@ jobs:
# Fetch all tags and branches because tests rely on it
with:
fetch-depth: 0
- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.11'
- name: Install dependencies and coverage
run: python -m pip install tox==3.28.0
run: python -m pip install tox==4.6.3
- name: Test with tox with coverage
run: tox
env:
TOXENV: coverage
- name: Upload coverage to Codecov
uses: codecov/[email protected].1
uses: codecov/[email protected].4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ def get_version():
],
extras_require={
"test": [
"tox>=3.15.2",
"mysqlclient>=1.4.6",
"psycopg2>=2.8.5",
"tox>=4.6.3",
"mysqlclient>=2.1.1",
"psycopg2>=2.9.6",
"django_add_default_value>=0.4.0",
"coverage>=5.5",
"coverage>=7.2.7",
],
},
keywords="django migration lint linter database backward compatibility",
Expand All @@ -56,6 +56,7 @@ def get_version():
"Framework :: Django :: 3.2",
"Framework :: Django :: 4.0",
"Framework :: Django :: 4.1",
"Framework :: Django :: 4.2",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
Expand Down
32 changes: 16 additions & 16 deletions tests/functional/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ def test_cache_normal(self, *args):
cache = linter.new_cache
cache.load()

self.assertEqual("OK", cache["ab2eef5ceb020d0e6eaa42dda2a754c5"]["result"])
self.assertEqual("ERR", cache["52000d9d2c43dfda982945000dc6ba54"]["result"])
self.assertEqual("OK", cache["eb6832d34f7ad40903a51a8b053ac13c"]["result"])
self.assertEqual("ERR", cache["31fa92230495861937bd6fd35b63c4e7"]["result"])
self.assertListEqual(
[
Issue(
code="NOT_NULL",
message="NOT NULL constraint on columns",
),
],
cache["52000d9d2c43dfda982945000dc6ba54"]["errors"],
cache["31fa92230495861937bd6fd35b63c4e7"]["errors"],
)

# Start the Linter again -> should use cache now.
Expand Down Expand Up @@ -96,16 +96,16 @@ def test_cache_different_databases(self, *args):
cache = linter.new_cache
cache.load()

self.assertEqual("OK", cache["ab2eef5ceb020d0e6eaa42dda2a754c5"]["result"])
self.assertEqual("ERR", cache["52000d9d2c43dfda982945000dc6ba54"]["result"])
self.assertEqual("OK", cache["eb6832d34f7ad40903a51a8b053ac13c"]["result"])
self.assertEqual("ERR", cache["31fa92230495861937bd6fd35b63c4e7"]["result"])
self.assertListEqual(
[
Issue(
code="NOT_NULL",
message="NOT NULL constraint on columns",
),
],
cache["52000d9d2c43dfda982945000dc6ba54"]["errors"],
cache["31fa92230495861937bd6fd35b63c4e7"]["errors"],
)

# Start the Linter again but with different database, should not be the same cache
Expand All @@ -121,16 +121,16 @@ def test_cache_different_databases(self, *args):
cache = linter.new_cache
cache.load()

self.assertEqual("OK", cache["ab2eef5ceb020d0e6eaa42dda2a754c5"]["result"])
self.assertEqual("ERR", cache["52000d9d2c43dfda982945000dc6ba54"]["result"])
self.assertEqual("OK", cache["eb6832d34f7ad40903a51a8b053ac13c"]["result"])
self.assertEqual("ERR", cache["31fa92230495861937bd6fd35b63c4e7"]["result"])
self.assertListEqual(
[
Issue(
code="NOT_NULL",
message="NOT NULL constraint on columns",
),
],
cache["52000d9d2c43dfda982945000dc6ba54"]["errors"],
cache["31fa92230495861937bd6fd35b63c4e7"]["errors"],
)

self.assertTrue(linter.has_errors)
Expand Down Expand Up @@ -180,7 +180,7 @@ def test_cache_modified(self, *args):
cache = linter.new_cache
cache.load()

self.assertEqual("ERR", cache["52000d9d2c43dfda982945000dc6ba54"]["result"])
self.assertEqual("ERR", cache["31fa92230495861937bd6fd35b63c4e7"]["result"])

# Get the content of the migration file and mock the open call to append
# some content to change the hash
Expand All @@ -206,9 +206,9 @@ def test_cache_modified(self, *args):
cache = linter.new_cache
cache.load()

self.assertNotIn("52000d9d2c43dfda982945000dc6ba54", cache)
self.assertNotIn("31fa92230495861937bd6fd35b63c4e7", cache)
self.assertEqual(1, len(cache))
self.assertEqual("ERR", cache["edeb40ecc1f5550ebef876c8e8ca093d"]["result"])
self.assertEqual("ERR", cache["864f9dc59e9dccd57ef6fa45143f1ef0"]["result"])

@mock.patch(
"django_migration_linter.MigrationLinter._gather_all_migrations",
Expand All @@ -232,16 +232,16 @@ def test_ignore_cached_migration(self, *args):
cache = linter.new_cache
cache.load()

self.assertEqual("OK", cache["ab2eef5ceb020d0e6eaa42dda2a754c5"]["result"])
self.assertEqual("ERR", cache["52000d9d2c43dfda982945000dc6ba54"]["result"])
self.assertEqual("OK", cache["eb6832d34f7ad40903a51a8b053ac13c"]["result"])
self.assertEqual("ERR", cache["31fa92230495861937bd6fd35b63c4e7"]["result"])
self.assertListEqual(
[
Issue(
code="NOT_NULL",
message="NOT NULL constraint on columns",
),
],
cache["52000d9d2c43dfda982945000dc6ba54"]["errors"],
cache["31fa92230495861937bd6fd35b63c4e7"]["errors"],
)

# Start the Linter again -> should use cache now but ignore the erroneous
Expand All @@ -263,4 +263,4 @@ def test_ignore_cached_migration(self, *args):
cache = linter.new_cache
cache.load()
self.assertEqual(1, len(cache))
self.assertEqual("OK", cache["ab2eef5ceb020d0e6eaa42dda2a754c5"]["result"])
self.assertEqual("OK", cache["eb6832d34f7ad40903a51a8b053ac13c"]["result"])
5 changes: 4 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ envlist =
py{37,38,39,310}-django32
py{38,39,310}-django40
py{38,39,310,311}-django41
py{38,39,310,311}-django42
lint
coverage

Expand All @@ -15,6 +16,7 @@ python =
3.11: py311

[testenv]
allowlist_externals = ./manage.py
commands = ./manage.py test --no-input {posargs}
extras = test
pip_pre = true
Expand All @@ -23,9 +25,10 @@ deps =
django32: django>=3.2,<3.3
django40: django>=4.0,<4.1
django41: django>=4.1,<4.2
django42: django>=4.2,<4.3

[testenv:lint]
basepython = python3.10
basepython = python3.11
deps = pre-commit
commands = pre-commit run --all-files --show-diff-on-failure

Expand Down

0 comments on commit 366d16b

Please sign in to comment.