-
Notifications
You must be signed in to change notification settings - Fork 2
263 lines (205 loc) · 7.84 KB
/
Copy pathci.yml
File metadata and controls
263 lines (205 loc) · 7.84 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
name: CI
on:
push:
branches:
- master
pull_request:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all --check
clippy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Run clippy
run: cargo clippy --workspace --all-targets -- -D warnings
# `rust-version = "1.88"` in both manifests is a promise to downstream
# resolvers, and every other job installs `stable`, so nothing else here would
# notice a post-1.88 API landing. This job is the only thing that checks it.
#
# Deliberately `cargo check` and not `--all-targets`: the MSRV covers the
# published library and proc-macro crate, not the dev-dependencies
# (criterion, trybuild, tokio) that only contributors build. The module
# features are on because they gate real code that the default feature set
# never compiles.
#
# When this job fails, the fix is to raise `rust-version` in `Cargo.toml` and
# `tideorm-macros/Cargo.toml` together, not to relax the job.
msrv:
runs-on: ubuntu-latest
env:
MODULE_FEATURES: "attachments,translations,fulltext,entity-manager,dirty-tracking,encrypted-fields"
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust
# Keep this literal in sync with `rust-version` in both manifests.
uses: dtolnay/rust-toolchain@1.88.0
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Check against the declared MSRV
run: cargo check --workspace --features "$MODULE_FEATURES"
# The six module feature flags gate real code but are off by default, so the
# `clippy` and `test` jobs above never compile them. Lint and unit-test them
# here, together with the non-default async-std runtime.
features:
runs-on: ubuntu-latest
env:
MODULE_FEATURES: "attachments,translations,fulltext,entity-manager,dirty-tracking,encrypted-fields"
POSTGRESQL_DATABASE_URL: postgres://postgres:postgres@localhost:5432/test_tide_orm
# `cargo test --lib` is otherwise database-free, but the entity-manager
# relation tests under `tests/unit/` are `#[path]`-included into it and speak
# real PostgreSQL (`BIGSERIAL`, `... CASCADE`). Without a server they do not
# skip — they wait out the pool acquisition timeout and fail, 30s apiece.
# They only compile under `entity-manager`, which is why this is the one job
# that needs a database.
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test_tide_orm
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Run clippy with module features
run: cargo clippy --workspace --all-targets --features "$MODULE_FEATURES" -- -D warnings
- name: Test with module features
run: cargo test --lib --features "$MODULE_FEATURES"
- name: Check async-std runtime
run: cargo check --no-default-features --features sqlite,runtime-async-std
macros:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Test tideorm-macros
run: cargo test -p tideorm-macros --lib
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
feature-set:
- "--no-default-features --features postgres,runtime-tokio"
- "--no-default-features --features mysql,runtime-tokio"
- "--no-default-features --features sqlite,runtime-tokio"
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Check
run: cargo check ${{ matrix.feature-set }}
- name: Test
run: cargo test --lib ${{ matrix.feature-set }}
integration-sqlite:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Run SQLite integration test
run: cargo test --package tideorm --test sqlite_ci_smoke_test --no-default-features --features sqlite,runtime-tokio
# Integration targets that never touch a database. Targets are named
# explicitly rather than using `--tests`, because postgres_integration_tests,
# postgres_advanced_tests and mysql_integration_tests all need a live server.
tests-no-db:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Run database-free integration tests
run: |
cargo test --package tideorm \
--test public_api_tests \
--test edge_case_tests \
--test query_builder_tests \
--test seaorm2_features_tests \
--test tokenization_tests \
--test tokenization_missing_key_test \
--test relation_serde_tests
# or_clause_tests pulls in a Postgres-backed module behind
# `feature = "postgres"`, so run it with the sqlite feature set instead.
- name: Run OR clause tests
run: cargo test --package tideorm --test or_clause_tests --no-default-features --features sqlite,runtime-tokio
# trybuild suites: the only real check on the tideorm/tideorm-macros ABI.
- name: Run compile-fail tests
run: cargo test --package tideorm --test relation_compile_fail --test encrypted_fields_feature_compile_fail
# These targets need a live database to run, but compile rot is still worth
# catching, so build them without executing.
integration-compile:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Compile SQLite integration tests
run: cargo test --package tideorm --test sqlite_integration_tests --no-default-features --features sqlite,runtime-tokio --no-run
- name: Compile MySQL integration tests
run: cargo test --package tideorm --test mysql_integration_tests --no-default-features --features mysql,runtime-tokio --no-run
docs:
runs-on: ubuntu-latest
env:
# Keep in sync with .github/workflows/mdbook.yml, otherwise a book can
# pass this gate and then fail the post-merge Pages deploy.
MDBOOK_VERSION: 0.4.36
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install mdBook
uses: taiki-e/install-action@v2
with:
tool: mdbook@${{ env.MDBOOK_VERSION }}
- name: Build book
run: mdbook build