forked from tortoise/tortoise-orm
-
Notifications
You must be signed in to change notification settings - Fork 0
271 lines (265 loc) · 8.65 KB
/
ci.yml
File metadata and controls
271 lines (265 loc) · 8.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
name: ci
on:
push:
branches:
- develop
- main
pull_request:
jobs:
check:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.10", "3.14"]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v7
- uses: actions/cache@v5
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/uv.lock') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: make deps
- name: Run checks
run: make check
test-sqlite:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v7
- uses: actions/cache@v5
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/uv.lock') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: make deps
- name: Test SQLite
run: make test_sqlite
env:
PYTHONDEVMODE: 1
- name: Test SQLite with regexp functions
run: make test_sqlite_regexp
env:
PYTHONDEVMODE: 1
- name: Test FastAPI/Blacksheep/Sanic Examples
run: |
PYTHONPATH=$DEST_FASTAPI uv run --frozen pytest $PYTEST_ARGS $DEST_FASTAPI/_tests.py
PYTHONPATH=$DEST_BLACKSHEEP uv run --frozen pytest $PYTEST_ARGS $DEST_BLACKSHEEP/_tests.py
PYTHONPATH=$DEST_SANIC uv run --frozen pytest $PYTEST_ARGS $DEST_SANIC/_tests.py
env:
DEST_FASTAPI: examples/fastapi
DEST_BLACKSHEEP: examples/blacksheep
DEST_SANIC: examples/sanic
PYTHONDEVMODE: 1
PYTEST_ARGS: "-n auto --cov=tortoise --cov-append --cov-branch --tb=native -q"
- name: Test Comprehensive Migrations Example
run: |
cd examples/comprehensive_migrations_project
# Apply all migrations forward
uv run --frozen tortoise -c config.TORTOISE_ORM migrate
# Verify migration history
uv run --frozen tortoise -c config.TORTOISE_ORM history
# Rollback all migrations to zero (defaults to __first__)
uv run --frozen tortoise -c config.TORTOISE_ORM downgrade erp
# Verify we're back to zero
uv run --frozen tortoise -c config.TORTOISE_ORM history
- name: Test poetry add
if: matrix.python-version == '3.10'
run: |
uv run --no-sync pytest $PYTEST_ARGS tests/test_version.py::test_added_by_poetry_v2
env:
TORTOISE_TEST_POETRY_ADD: 1
PYTHONDEVMODE: 1
PYTEST_ARGS: "-n auto --cov=tortoise --cov-append --cov-branch --tb=native -q"
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-sqlite-${{ matrix.python-version }}
path: .coverage
if-no-files-found: error
include-hidden-files: true
test-postgres:
runs-on: ubuntu-22.04
services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: 123456
POSTGRES_USER: postgres
options: --health-cmd=pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
env:
TORTOISE_TEST_MODULES: tests.testmodels
TORTOISE_POSTGRES_PASS: 123456
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v7
- uses: actions/cache@v5
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/uv.lock') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: make deps
- name: Test PostgreSQL asyncpg
run: make test_postgres_asyncpg
env:
PYTHONDEVMODE: 1
- name: Test PostgreSQL psycopg
run: make test_postgres_psycopg
env:
PYTHONDEVMODE: 1
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-postgres-${{ matrix.python-version }}
path: .coverage
if-no-files-found: error
include-hidden-files: true
test-mysql:
runs-on: ubuntu-22.04
services:
mysql:
image: mysql:8
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: 123456
options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5
env:
TORTOISE_TEST_MODULES: tests.testmodels
TORTOISE_MYSQL_PASS: 123456
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v7
- uses: actions/cache@v5
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/uv.lock') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: make deps
- name: Test MySQL MyISAM
run: make test_mysql_myisam
env:
PYTHONDEVMODE: 1
- name: Test MySQL InnoDB
run: make test_mysql
env:
PYTHONDEVMODE: 1
- name: Test MySQL asyncmy
run: make test_mysql_asyncmy
env:
PYTHONDEVMODE: 1
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-mysql-${{ matrix.python-version }}
path: .coverage
if-no-files-found: error
include-hidden-files: true
test-mssql:
runs-on: ubuntu-22.04
services:
mssql:
image: mcr.microsoft.com/mssql/server:2022-CU15-ubuntu-22.04
ports:
- 1433:1433
env:
ACCEPT_EULA: Y
SA_PASSWORD: Abcd12345678
options: >-
--health-cmd "/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P Abcd12345678 -Q 'SELECT 1' -b -o /dev/null"
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
TORTOISE_TEST_MODULES: tests.testmodels
TORTOISE_MSSQL_PASS: Abcd12345678
TORTOISE_MSSQL_DRIVER: ODBC Driver 18 for SQL Server
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- name: Install ODBC driver
run: |
curl -sSL -O https://packages.microsoft.com/config/ubuntu/$(grep VERSION_ID /etc/os-release | cut -d '"' -f 2)/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@v7
- uses: actions/cache@v5
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/uv.lock') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: make deps
- name: Test MSSQL
run: make test_mssql
env:
PYTHONDEVMODE: 1
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: coverage-mssql-${{ matrix.python-version }}
path: .coverage
if-no-files-found: error
include-hidden-files: true
coverage:
needs: [test-sqlite, test-postgres, test-mysql, test-mssql]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.14"
- uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: make deps
- name: Download all coverage artifacts
uses: actions/download-artifact@v4
with:
pattern: coverage-*
- name: Combine coverage
run: |
uv run --frozen coverage combine coverage-*/.coverage
- name: Coverage report
run: uv run --frozen coverage report
- name: Upload to Coveralls
run: uvx coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}