Skip to content

Commit

Permalink
ci: add TiDB v7.1 & Django v4.2 (#42)
Browse files Browse the repository at this point in the history
* refactor CI workflow with matrix

* skip tidb v4.0.15 & v5.4.3 in Django v4.2.4

* skip python 3.11 & django 3.2.20
  • Loading branch information
wd0517 authored Aug 8, 2023
1 parent 8ead1b9 commit eabcac1
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 111 deletions.
149 changes: 38 additions & 111 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
on: [push, pull_request]
on:
pull_request:
push:
branches:
- main

jobs:
lint:
Expand All @@ -17,120 +21,42 @@ jobs:
run: |
tox -e lint
django3_tidb4:
name: Python ${{ matrix.python-version }} | Django 3 | TiDB 4
runs-on: ubuntu-latest

tests:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']

services:
tidb4:
image: hawkingrei/tind:v4.0.15-standalone
ports:
- 4000:4000

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
sudo apt-get update
sudo apt-get install -y libmemcached-dev zlib1g-dev
- name: Run tests
run: tox
env:
DJANGO_VERSION: 3.2.18

django4_tidb4:
name: Python ${{ matrix.python-version }} | Django 4 | TiDB 4
python-version:
- '3.9'
- '3.10'
- '3.11'
django-version:
- '3.2.20'
- '4.1.10'
- '4.2.4'
tidb-version:
- 'v7.1.1'
- 'v6.5.3'
- 'v5.4.3'
- 'v4.0.15'
exclude:
# Django introduced the `debug_transaction` feature in version 4.2.x,
# but it does not consider databases that do not support savepoints(TiDB < 6.2.0),
# as a result, all `assertNumQueries` in test cases failed.
# https://github.com/django/django/commit/798e38c2b9c46ab72e2ee8c33dc822f01b194b1e
- django-version: '4.2.4'
tidb-version: 'v4.0.15'
- django-version: '4.2.4'
tidb-version: 'v5.4.3'
# Django 3.2 is under extended support, some functions are not compatible with Python 3.11
- python-version: '3.11'
django-version: '3.2.20'

name: py${{ matrix.python-version }}_tidb${{ matrix.tidb-version }}_django${{ matrix.django-version }}
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']

services:
tidb4:
image: hawkingrei/tind:v4.0.15-standalone
ports:
- 4000:4000

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
sudo apt-get install -y libmemcached-dev zlib1g-dev
- name: Run tests
run: tox
env:
DJANGO_VERSION: 4.1.7

django3_tidb5:
name: Python ${{ matrix.python-version }} | Django 3 | TiDB 5
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']

services:
tidb5:
image: hawkingrei/tind:v5.2.2-standalone
ports:
- 4000:4000

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
sudo apt-get install -y libmemcached-dev zlib1g-dev
- name: Run tests
run: tox
env:
DJANGO_VERSION: 3.2.18

django4_tidb5:
name: Python ${{ matrix.python-version }} | Django 4 | TiDB 5
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']

services:
tidb5:
image: hawkingrei/tind:v5.2.2-standalone
tidb:
image: wangdi4zm/tind:${{ matrix.tidb-version }}-standalone
ports:
- 4000:4000

Expand All @@ -147,9 +73,10 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
sudo apt-get update
sudo apt-get install -y libmemcached-dev zlib1g-dev
- name: Run tests
run: tox
env:
DJANGO_VERSION: 4.1.7
DJANGO_VERSION: ${{ matrix.django-version }}
53 changes: 53 additions & 0 deletions django_tidb/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,50 @@ def can_release_savepoints(self):
return True
return False

@cached_property
def django_test_expected_failures(self):
expected_failures = set()
# https://github.com/pingcap/django-tidb/issues/38
# These expected failures will be removed once this issue is resolved
if self.supports_json_field:
expected_failures.update(
{
"model_fields.test_jsonfield.TestQuerying.test_key_quoted_string",
"model_fields.test_jsonfield.TestQuerying.test_deep_lookup_mixed",
"model_fields.test_jsonfield.TestQuerying.test_deep_lookup_objs",
"model_fields.test_jsonfield.TestQuerying.test_key_icontains",
"model_fields.test_jsonfield.TestQuerying.test_key_iendswith",
"model_fields.test_jsonfield.TestQuerying.test_key_iexact",
"model_fields.test_jsonfield.TestQuerying.test_key_in",
"model_fields.test_jsonfield.TestQuerying.test_key_iregex",
"model_fields.test_jsonfield.TestQuerying.test_key_istartswith",
"model_fields.test_jsonfield.TestQuerying.test_lookup_exclude",
"model_fields.test_jsonfield.TestQuerying.test_lookup_exclude_nonexistent_key",
"model_fields.test_jsonfield.TestQuerying.test_nested_key_transform_on_subquery",
"model_fields.test_jsonfield.TestQuerying.test_none_key_and_exact_lookup",
"model_fields.test_jsonfield.TestQuerying.test_obj_subquery_lookup",
"model_fields.test_jsonfield.TestQuerying.test_shallow_obj_lookup",
}
)
if django.VERSION >= (4, 1):
expected_failures.update(
{
"model_fields.test_jsonfield.TestQuerying.test_icontains",
}
)
if django.VERSION >= (4, 2):
expected_failures.update(
{
"model_fields.test_jsonfield.TestQuerying.test_key_endswith",
"model_fields.test_jsonfield.TestQuerying.test_key_regex",
"model_fields.test_jsonfield.TestQuerying.test_key_text_transform_char_lookup",
"model_fields.test_jsonfield.TestQuerying.test_key_startswith",
"model_fields.test_jsonfield.TestQuerying.test_ordering_grouping_by_key_transform",
"model_fields.test_jsonfield.TestQuerying.test_ordering_grouping_by_key_transform",
}
)
return expected_failures

@cached_property
def django_test_skips(self):
skips = {
Expand Down Expand Up @@ -410,6 +454,15 @@ def django_test_skips(self):
},
}
)
if not self.supports_foreign_keys:
skips.update(
{
# Django does not check if the database supports foreign keys.
"django42_db_unsupport_foreign_keys": {
"inspectdb.tests.InspectDBTestCase.test_same_relations",
},
}
)
return skips

@cached_property
Expand Down

0 comments on commit eabcac1

Please sign in to comment.