Skip to content

Commit d914c70

Browse files
authored
Merge pull request #2088 from tortoise/develop
Update main branch
2 parents d300754 + 1f70faa commit d914c70

File tree

396 files changed

+49132
-21704
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

396 files changed

+49132
-21704
lines changed

.github/FUNDING.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/ci.yml

Lines changed: 218 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,100 @@
11
name: ci
22
on:
33
push:
4-
branches-ignore:
4+
branches:
5+
- develop
56
- main
67
pull_request:
7-
branches-ignore:
8-
- main
8+
99
jobs:
10-
test:
10+
check:
11+
runs-on: ubuntu-22.04
12+
strategy:
13+
matrix:
14+
python-version: ["3.10", "3.14"]
15+
steps:
16+
- uses: actions/checkout@v6
17+
- uses: actions/setup-python@v6
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
- uses: astral-sh/setup-uv@v7
21+
- uses: actions/cache@v5
22+
with:
23+
path: ~/.cache/pip
24+
key: ${{ runner.os }}-pip-${{ hashFiles('**/uv.lock') }}
25+
restore-keys: |
26+
${{ runner.os }}-pip-
27+
- name: Install dependencies
28+
run: make deps
29+
- name: Run checks
30+
run: make check
31+
32+
test-sqlite:
33+
runs-on: ubuntu-22.04
34+
strategy:
35+
matrix:
36+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
37+
steps:
38+
- uses: actions/checkout@v6
39+
- uses: actions/setup-python@v6
40+
with:
41+
python-version: ${{ matrix.python-version }}
42+
- uses: astral-sh/setup-uv@v7
43+
- uses: actions/cache@v5
44+
with:
45+
path: ~/.cache/pip
46+
key: ${{ runner.os }}-pip-${{ hashFiles('**/uv.lock') }}
47+
restore-keys: |
48+
${{ runner.os }}-pip-
49+
- name: Install dependencies
50+
run: make deps
51+
- name: Test SQLite
52+
run: make test_sqlite
53+
env:
54+
PYTHONDEVMODE: 1
55+
- name: Test SQLite with regexp functions
56+
run: make test_sqlite_regexp
57+
env:
58+
PYTHONDEVMODE: 1
59+
- name: Test FastAPI/Blacksheep/Sanic Examples
60+
run: |
61+
PYTHONPATH=$DEST_FASTAPI uv run --frozen pytest $PYTEST_ARGS $DEST_FASTAPI/_tests.py
62+
PYTHONPATH=$DEST_BLACKSHEEP uv run --frozen pytest $PYTEST_ARGS $DEST_BLACKSHEEP/_tests.py
63+
PYTHONPATH=$DEST_SANIC uv run --frozen pytest $PYTEST_ARGS $DEST_SANIC/_tests.py
64+
env:
65+
DEST_FASTAPI: examples/fastapi
66+
DEST_BLACKSHEEP: examples/blacksheep
67+
DEST_SANIC: examples/sanic
68+
PYTHONDEVMODE: 1
69+
PYTEST_ARGS: "-n auto --cov=tortoise --cov-append --cov-branch --tb=native -q"
70+
- name: Test Comprehensive Migrations Example
71+
run: |
72+
cd examples/comprehensive_migrations_project
73+
# Apply all migrations forward
74+
uv run --frozen tortoise -c config.TORTOISE_ORM migrate
75+
# Verify migration history
76+
uv run --frozen tortoise -c config.TORTOISE_ORM history
77+
# Rollback all migrations to zero (defaults to __first__)
78+
uv run --frozen tortoise -c config.TORTOISE_ORM downgrade erp
79+
# Verify we're back to zero
80+
uv run --frozen tortoise -c config.TORTOISE_ORM history
81+
- name: Test poetry add
82+
if: matrix.python-version == '3.10'
83+
run: |
84+
uv run --no-sync pytest $PYTEST_ARGS tests/test_version.py::test_added_by_poetry_v2
85+
env:
86+
TORTOISE_TEST_POETRY_ADD: 1
87+
PYTHONDEVMODE: 1
88+
PYTEST_ARGS: "-n auto --cov=tortoise --cov-append --cov-branch --tb=native -q"
89+
- name: Upload coverage artifact
90+
uses: actions/upload-artifact@v4
91+
with:
92+
name: coverage-sqlite-${{ matrix.python-version }}
93+
path: .coverage
94+
if-no-files-found: error
95+
include-hidden-files: true
96+
97+
test-postgres:
1198
runs-on: ubuntu-22.04
1299
services:
13100
postgres:
@@ -18,13 +105,95 @@ jobs:
18105
POSTGRES_PASSWORD: 123456
19106
POSTGRES_USER: postgres
20107
options: --health-cmd=pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
108+
env:
109+
TORTOISE_TEST_MODULES: tests.testmodels
110+
TORTOISE_POSTGRES_PASS: 123456
111+
strategy:
112+
matrix:
113+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
114+
steps:
115+
- uses: actions/checkout@v6
116+
- uses: actions/setup-python@v6
117+
with:
118+
python-version: ${{ matrix.python-version }}
119+
- uses: astral-sh/setup-uv@v7
120+
- uses: actions/cache@v5
121+
with:
122+
path: ~/.cache/pip
123+
key: ${{ runner.os }}-pip-${{ hashFiles('**/uv.lock') }}
124+
restore-keys: |
125+
${{ runner.os }}-pip-
126+
- name: Install dependencies
127+
run: make deps
128+
- name: Test PostgreSQL asyncpg
129+
run: make test_postgres_asyncpg
130+
env:
131+
PYTHONDEVMODE: 1
132+
- name: Test PostgreSQL psycopg
133+
run: make test_postgres_psycopg
134+
env:
135+
PYTHONDEVMODE: 1
136+
- name: Upload coverage artifact
137+
uses: actions/upload-artifact@v4
138+
with:
139+
name: coverage-postgres-${{ matrix.python-version }}
140+
path: .coverage
141+
if-no-files-found: error
142+
include-hidden-files: true
143+
144+
test-mysql:
145+
runs-on: ubuntu-22.04
146+
services:
21147
mysql:
22-
image: mysql
148+
image: mysql:8
23149
ports:
24150
- 3306:3306
25151
env:
26152
MYSQL_ROOT_PASSWORD: 123456
27153
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5
154+
env:
155+
TORTOISE_TEST_MODULES: tests.testmodels
156+
TORTOISE_MYSQL_PASS: 123456
157+
strategy:
158+
matrix:
159+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
160+
steps:
161+
- uses: actions/checkout@v6
162+
- uses: actions/setup-python@v6
163+
with:
164+
python-version: ${{ matrix.python-version }}
165+
- uses: astral-sh/setup-uv@v7
166+
- uses: actions/cache@v5
167+
with:
168+
path: ~/.cache/pip
169+
key: ${{ runner.os }}-pip-${{ hashFiles('**/uv.lock') }}
170+
restore-keys: |
171+
${{ runner.os }}-pip-
172+
- name: Install dependencies
173+
run: make deps
174+
- name: Test MySQL MyISAM
175+
run: make test_mysql_myisam
176+
env:
177+
PYTHONDEVMODE: 1
178+
- name: Test MySQL InnoDB
179+
run: make test_mysql
180+
env:
181+
PYTHONDEVMODE: 1
182+
- name: Test MySQL asyncmy
183+
run: make test_mysql_asyncmy
184+
env:
185+
PYTHONDEVMODE: 1
186+
- name: Upload coverage artifact
187+
uses: actions/upload-artifact@v4
188+
with:
189+
name: coverage-mysql-${{ matrix.python-version }}
190+
path: .coverage
191+
if-no-files-found: error
192+
include-hidden-files: true
193+
194+
test-mssql:
195+
runs-on: ubuntu-22.04
196+
services:
28197
mssql:
29198
image: mcr.microsoft.com/mssql/server:2022-CU15-ubuntu-22.04
30199
ports:
@@ -39,60 +208,64 @@ jobs:
39208
--health-retries 5
40209
env:
41210
TORTOISE_TEST_MODULES: tests.testmodels
42-
TORTOISE_MYSQL_PASS: 123456
43-
TORTOISE_POSTGRES_PASS: 123456
44211
TORTOISE_MSSQL_PASS: Abcd12345678
45212
TORTOISE_MSSQL_DRIVER: ODBC Driver 18 for SQL Server
46213
strategy:
47214
matrix:
48-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
215+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
49216
steps:
50-
- uses: actions/cache@v4
217+
- name: Install ODBC driver
218+
run: |
219+
curl -sSL -O https://packages.microsoft.com/config/ubuntu/$(grep VERSION_ID /etc/os-release | cut -d '"' -f 2)/packages-microsoft-prod.deb
220+
sudo dpkg -i packages-microsoft-prod.deb
221+
sudo apt-get update
222+
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18
223+
- uses: actions/checkout@v6
224+
- uses: actions/setup-python@v6
225+
with:
226+
python-version: ${{ matrix.python-version }}
227+
- uses: astral-sh/setup-uv@v7
228+
- uses: actions/cache@v5
51229
with:
52230
path: ~/.cache/pip
53-
key: ${{ runner.os }}-pip-${{ hashFiles('**/poetry.lock') }}
231+
key: ${{ runner.os }}-pip-${{ hashFiles('**/uv.lock') }}
54232
restore-keys: |
55233
${{ runner.os }}-pip-
56-
- uses: actions/checkout@v4
57-
- uses: actions/setup-python@v5
58-
with:
59-
python-version: ${{ matrix.python-version }}
60-
- name: Install and configure Poetry
61-
run: |
62-
pip install -U pip poetry
63-
poetry config virtualenvs.create false
64-
- name: Install ODBC driver
65-
run: |
66-
sudo curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
67-
sudo curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list -o /etc/apt/sources.list.d/mssql-release.list
68-
sudo apt-get update
69-
ACCEPT_EULA=Y sudo apt-get install -y msodbcsql18
70-
- name: Run ci
71-
run: make ci
72-
- name: Test Examples
73-
run: |
74-
export DEST=examples/blacksheep && PYTHONPATH=$DEST pytest $PYTEST_ARGS $DEST/_tests.py
75-
export DEST=examples/fastapi && PYTHONPATH=$DEST pytest $PYTEST_ARGS $DEST/_tests.py
234+
- name: Install dependencies
235+
run: make deps
236+
- name: Test MSSQL
237+
run: make test_mssql
76238
env:
77239
PYTHONDEVMODE: 1
78-
PYTEST_ARGS: "-n auto --cov=tortoise --cov-append --tb=native -q"
79-
- name: Upload Coverage
80-
run: |
81-
pip3 install --upgrade coveralls
82-
coveralls --service=github
83-
env:
84-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85-
COVERALLS_FLAG_NAME: ${{ matrix.python-version }}
86-
COVERALLS_PARALLEL: true
240+
- name: Upload coverage artifact
241+
uses: actions/upload-artifact@v4
242+
with:
243+
name: coverage-mssql-${{ matrix.python-version }}
244+
path: .coverage
245+
if-no-files-found: error
246+
include-hidden-files: true
87247

88-
coveralls:
89-
name: Finish Coveralls
90-
needs: test
248+
coverage:
249+
needs: [test-sqlite, test-postgres, test-mysql, test-mssql]
91250
runs-on: ubuntu-22.04
92251
steps:
93-
- name: Finished
252+
- uses: actions/checkout@v6
253+
- uses: actions/setup-python@v6
254+
with:
255+
python-version: "3.14"
256+
- uses: astral-sh/setup-uv@v7
257+
- name: Install dependencies
258+
run: make deps
259+
- name: Download all coverage artifacts
260+
uses: actions/download-artifact@v4
261+
with:
262+
pattern: coverage-*
263+
- name: Combine coverage
94264
run: |
95-
pip3 install --upgrade coveralls
96-
coveralls --finish
265+
uv run --frozen coverage combine coverage-*/.coverage
266+
- name: Coverage report
267+
run: uv run --frozen coverage report
268+
- name: Upload to Coveralls
269+
run: uvx coveralls --service=github
97270
env:
98271
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/codspeed.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CodSpeed
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
pull_request:
8+
# `workflow_dispatch` allows CodSpeed to trigger backtest
9+
# performance analysis in order to generate initial data.
10+
workflow_dispatch:
11+
12+
jobs:
13+
benchmarks:
14+
name: Run benchmarks
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
- uses: actions/setup-python@v6
19+
with:
20+
# 3.12 is the minimum required version for profiling enabled
21+
python-version: "3.12"
22+
23+
- uses: astral-sh/setup-uv@v7
24+
25+
- name: Build dists
26+
run: make build
27+
28+
- name: Run benchmarks
29+
uses: CodSpeedHQ/action@v3
30+
with:
31+
token: ${{ secrets.CODSPEED_TOKEN }}
32+
run: uv run --frozen pytest tests/benchmarks --codspeed

.github/workflows/gh-pages-release.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@ jobs:
77
publish:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v3
11-
- uses: actions/setup-python@v4
10+
- uses: actions/checkout@v6
11+
- uses: actions/setup-python@v6
1212
with:
13-
python-version: "3.9"
14-
- name: Install and configure Poetry
15-
run: |
16-
pip install -U pip poetry
17-
poetry config virtualenvs.create false
13+
python-version: "3.10"
14+
- uses: astral-sh/setup-uv@v7
1815
- name: Build docs
1916
run: make docs
2017
- name: Deploy release docs

.github/workflows/gh-pages.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ jobs:
88
publish:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v3
12-
- uses: actions/setup-python@v4
11+
- uses: actions/checkout@v6
12+
- uses: actions/setup-python@v6
1313
with:
14-
python-version: "3.9"
15-
- name: Install and configure Poetry
16-
run: |
17-
pip install -U pip poetry
18-
poetry config virtualenvs.create false
14+
python-version: "3.10"
15+
- uses: astral-sh/setup-uv@v7
1916
- name: Build docs
2017
run: make docs
2118
- name: Deploy latest docs

0 commit comments

Comments
 (0)