forked from diesel-rs/diesel
-
Notifications
You must be signed in to change notification settings - Fork 2
357 lines (320 loc) · 13.5 KB
/
ci.yml
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- master
- '0.[0-9]+.x'
- '1.[0-9]+.x'
name: CI Tests
jobs:
check_and_test:
name: Check
strategy:
fail-fast: false
matrix:
rust: ["stable", "beta", "nightly"]
backend: ["postgres", "sqlite", "mysql"]
os: [ubuntu-18.04, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Cache cargo registry
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-${{ matrix.backend }}-cargo-${{ hashFiles('**/Cargo.toml') }}
- name: Set environment variables
shell: bash
if: matrix.backend == 'mysql'
run: |
echo 'RUST_TEST_THREADS=1' >> $GITHUB_ENV
- name: Set environment variables
shell: bash
run: |
echo 'RUSTFLAGS=--cap-lints=warn' >> $GITHUB_ENV
- name: Install postgres (Linux)
if: runner.os == 'Linux' && matrix.backend == 'postgres'
run: |
sudo apt-get update
sudo apt-get install -y libpq-dev postgresql
echo "host all all 127.0.0.1/32 md5" > sudo tee -a /etc/postgresql/10/main/pg_hba.conf
sudo service postgresql restart && sleep 3
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
sudo service postgresql restart && sleep 3
echo 'PG_DATABASE_URL=postgres://postgres:postgres@localhost/' >> $GITHUB_ENV
echo 'PG_EXAMPLE_DATABASE_URL=postgres://postgres:postgres@localhost/diesel_example' >> $GITHUB_ENV
- name: Install sqlite (Linux)
if: runner.os == 'Linux' && matrix.backend == 'sqlite'
run: |
sudo apt-get update
sudo apt-get -y install libsqlite3-dev
echo 'SQLITE_DATABASE_URL=/tmp/test.db' >> $GITHUB_ENV
- name: Install mysql (Linux)
if: runner.os == 'Linux' && matrix.backend == 'mysql'
run: |
sudo apt-get update
sudo apt-get -y install mysql-server libmysqlclient-dev
sudo /etc/init.d/mysql start
mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'root'@'localhost';" -uroot -proot
echo 'MYSQL_DATABASE_URL=mysql://root:root@localhost/diesel_test' >> $GITHUB_ENV
echo 'MYSQL_EXAMPLE_DATABASE_URL=mysql://root:root@localhost/diesel_example' >> $GITHUB_ENV
echo 'MYSQL_UNIT_TEST_DATABASE_URL=mysql://root:root@localhost/diesel_unit_test' >> $GITHUB_ENV
- name: Install postgres (MacOS)
if: runner.os == 'macOS' && matrix.backend == 'postgres'
run: |
/usr/local/opt/postgres/bin/pg_ctl -D /usr/local/var/postgres start
sleep 3
/usr/local/opt/postgres/bin/createuser -s postgres
echo 'PG_DATABASE_URL=postgres://postgres@localhost/' >> $GITHUB_ENV
echo 'PG_EXAMPLE_DATABASE_URL=postgres://postgres@localhost/diesel_example' >> $GITHUB_ENV
- name: Install sqlite (MacOS)
if: runner.os == 'macOS' && matrix.backend == 'sqlite'
run: |
brew update
brew install sqlite
echo 'SQLITE_DATABASE_URL=/tmp/test.db' >> $GITHUB_ENV
- name: Install mysql (MacOS)
if: runner.os == 'macOS' && matrix.backend == 'mysql'
run: |
brew update &&
brew install mysql@5.7 &&
brew services start mysql@5.7 &&
brew services stop mysql@5.7;sleep 3;brew services start mysql@5.7 &&
sleep 2 &&
/usr/local/Cellar/mysql@5.7/5.7.35/bin/mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'root'@'localhost';" -uroot
echo 'MYSQL_DATABASE_URL=mysql://root@localhost/diesel_test' >> $GITHUB_ENV
echo 'MYSQL_EXAMPLE_DATABASE_URL=mysql://root@localhost/diesel_example' >> $GITHUB_ENV
echo 'MYSQL_UNIT_TEST_DATABASE_URL=mysql://root@localhost/diesel_unit_test' >> $GITHUB_ENV
echo 'MYSQLCLIENT_LIB_DIR=/usr/local/opt/mysql@5.7/lib' >> $GITHUB_ENV
echo 'PKG_CONFIG_PATH="/usr/local/opt/mysql@5.7/lib/pkgconfig"' >> $GITHUB_ENV
- name: Install sqlite (Windows)
if: runner.os == 'Windows' && matrix.backend == 'sqlite'
shell: cmd
run: |
choco install sqlite
cd /D C:\ProgramData\chocolatey\lib\SQLite\tools
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
lib /machine:x64 /def:sqlite3.def /out:sqlite3.lib
- name: Set variables for sqlite (Windows)
if: runner.os == 'Windows' && matrix.backend == 'sqlite'
shell: bash
run: |
echo "C:\ProgramData\chocolatey\lib\SQLite\tools" >> $GITHUB_PATH
echo "SQLITE3_LIB_DIR=C:\ProgramData\chocolatey\lib\SQLite\tools" >> $GITHUB_ENV
echo "SQLITE_DATABASE_URL=C:\test.db" >> $GITHUB_ENV
- name: Install postgres (Windows)
if: runner.os == 'Windows' && matrix.backend == 'postgres'
shell: bash
run: |
choco install postgresql12 --force --params '/Password:postgres'
echo 'C:\Program Files\PostgreSQL\12\bin' >> $GITHUB_PATH
echo 'C:\Program Files\PostgreSQL\12\lib' >> $GITHUB_PATH
echo 'PQ_LIB_DIR=C:\Program Files\PostgreSQL\12\lib' >> $GITHUB_ENV
echo 'PG_DATABASE_URL=postgres://postgres:postgres@localhost/' >> $GITHUB_ENV
echo 'PG_EXAMPLE_DATABASE_URL=postgres://postgres:postgres@localhost/diesel_example' >> $GITHUB_ENV
- name: Install mysql (Windows)
if: runner.os == 'Windows' && matrix.backend == 'mysql'
shell: cmd
run: |
choco install mysql
"C:\tools\mysql\current\bin\mysql" -e "create database diesel_test; create database diesel_unit_test; grant all on `diesel_%`.* to 'root'@'localhost';" -uroot
- name: Set variables for mysql (Windows)
if: runner.os == 'Windows' && matrix.backend == 'mysql'
shell: bash
run: |
echo "MYSQL_DATABASE_URL=mysql://root@localhost/diesel_test" >> $GITHUB_ENV
echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://root@localhost/diesel_example" >> $GITHUB_ENV
echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://root@localhost/diesel_unit_test" >> $GITHUB_ENV
echo "MYSQLCLIENT_LIB_DIR=C:\tools\mysql\current\lib" >> $GITHUB_ENV
- name: Update Rustup (temporary workaround)
run: rustup self update
shell: bash
if: startsWith(matrix.os, 'windows')
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Rust version check
uses: actions-rs/cargo@v1
with:
command: version
- name: Test diesel (nightly)
if: matrix.rust == 'nightly'
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path diesel/Cargo.toml --no-default-features --features "${{ matrix.backend }} unstable extras"
- name: Test diesel
if: matrix.rust != 'nightly'
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path diesel/Cargo.toml --no-default-features --features "${{ matrix.backend }} extras"
- name: Test diesel (with-deprecated)
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path diesel/Cargo.toml --no-default-features --features "${{ matrix.backend }} extras with-deprecated"
- name: Test diesel-derives (nightly)
if: matrix.rust == 'nightly'
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path diesel_derives/Cargo.toml --no-default-features --features "diesel/${{ matrix.backend }} diesel/unstable"
- name: Test diesel-derives
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path diesel_derives/Cargo.toml --no-default-features --features "diesel/${{ matrix.backend }}"
- name: Test diesel-cli
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path diesel_cli/Cargo.toml --no-default-features --features "${{ matrix.backend }}"
- name: Test diesel examples
shell: bash
run: |
(cd examples/${{ matrix.backend }} && BACKEND=${{ matrix.backend }} ./test_all)
- name: Test migrations-internals
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path diesel_migrations/migrations_internals/Cargo.toml
- name: Test migrations-macros
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path diesel_migrations/migrations_macros/Cargo.toml
- name: Test diesel_migrations
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path diesel_migrations/Cargo.toml --features "${{ matrix.backend }} diesel/${{ matrix.backend }}"
- name: Run diesel_tests (nightly)
if: matrix.run == 'nightly'
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path diesel_tests/Cargo.toml --no-default-features --features "${{ matrix.backend }} unstable"
- name: Run diesel_tests
if: matrix.run != 'nightly'
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path diesel_tests/Cargo.toml --no-default-features --features "${{ matrix.backend }}"
- name: Run rustdoc (nightly)
if: matrix.run == 'nightly'
uses: actions-rs/cargo@v1
with:
command: doc
args: --manifest-path diesel/Cargo.toml --no-deps --no-default-features --features "${{ matrix.backend }} unstable"
- name: Run rustdoc
if: matrix.run != 'nightly'
uses: actions-rs/cargo@v1
with:
command: doc
args: --manifest-path diesel/Cargo.toml --no-deps --no-default-features --features "${{ matrix.backend }}"
compile_tests:
name: Compiletests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2018-11-27
profile: minimal
override: true
- name: Cache cargo registry
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: compile_test-cargo-${{ hashFiles('**/Cargo.toml') }}
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install libsqlite3-dev libpq-dev libmysqlclient-dev
- name: Run compile tests
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path diesel_compile_tests/Cargo.toml
sqlite_bundled:
name: Check sqlite bundled
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Cache cargo registry
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: sqlite_bundled-cargo-${{ hashFiles('**/Cargo.toml') }}
- name: Setup environment
run: |
echo 'SQLITE_DATABASE_URL=/tmp/test.db' >> $GITHUB_ENV
echo 'RUSTFLAGS=--cap-lints=warn' >> $GITHUB_ENV
- name: Test diesel-cli
uses: actions-rs/cargo@v1
with:
command: test
args: --manifest-path diesel_cli/Cargo.toml --no-default-features --features "sqlite-bundled"
minimal_rust_version:
name: Check Minimal supported rust version (1.31.0)
runs-on: ubuntu-16.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.31.0
profile: minimal
override: true
components: clippy, rustfmt
- name: Cache cargo registry
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: minimal_rust_version-cargo-${{ hashFiles('**/Cargo.toml') }}
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install libsqlite3-dev libpq-dev libmysqlclient-dev libclang-dev
- name: Fix minimal dependencies
run: |
RUSTC_BOOTSTRAP=1 cargo update -Z minimal-versions
cargo update -p diesel:1.4.0
cargo update -p diesel_derives:1.4.0
cargo update -p rustc-serialize --precise=0.3.20
cargo update -p regex:0.1.0 --precise=0.1.31
cargo update -p cexpr --precise=0.2.2
cargo update -p num-bigint:0.1.36 --precise=0.1.41
cargo update -p num-bigint:0.2.0 --precise=0.1.41
cargo update -p num-integer --precise=0.1.33
cargo update -p syn:0.12.0 --precise=0.12.3
cargo update -p libloading --precise=0.3.1
cargo update -p pq-sys --precise=0.3.1
cargo update -p mysqlclient-sys --precise=0.2.0
- name: Check building with rust 1.31.0
uses: actions-rs/cargo@v1
with:
command: check
args: --manifest-path=diesel/Cargo.toml
- name: Check formating
uses: actions-rs/cargo@v1
with:
command: fmt