-
Notifications
You must be signed in to change notification settings - Fork 377
398 lines (383 loc) · 13 KB
/
main.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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
name: CI
on:
push:
branches:
- "**" # we just don't want this to run redundantly on tags
pull_request:
env:
PUB_ENVIRONMENT: bot.github
jobs:
setup:
uses: ./.github/workflows/setup.yml
docs:
name: "Documentation"
needs: [setup]
runs-on: ubuntu-latest
defaults:
run:
working-directory: docs
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
with:
dart_version: ${{ needs.setup.outputs.dart_version }}
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 3.24
cache: true
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:"
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:"
- name: Bootstrap Dart packages
run: melos bootstrap --scope drift_docs,drift,app
working-directory: .
- name: Run build
env:
IS_RELEASE: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/latest-release' }}
run: |
chmod +x ./docs.sh
./docs.sh build
- name: Analyze Dart and Drift sources
run: |
dart format -o none --set-exit-if-changed .
dart analyze --fatal-infos --fatal-warnings
dart run drift_dev analyze
- name: Test Dart and Drift sources
run: dart test
- name: Deploy to netlify (Branch)
if: ${{ github.event_name == 'push' }}
uses: nwtgck/actions-netlify@v3
with:
production-branch: latest-release
publish-dir: docs/deploy
enable-pull-request-comment: true
enable-commit-comment: false
netlify-config-path: "./netlify.toml"
github-token: ${{ secrets.GITHUB_TOKEN }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
- name: Deploy to netlify (Pull Request)
if: ${{ github.event_name == 'pull_request' }}
uses: nwtgck/actions-netlify@v3
with:
production-branch: latest-release
publish-dir: docs/deploy
enable-pull-request-comment: true
enable-commit-comment: false
netlify-config-path: "./netlify.toml"
github-token: ${{ secrets.GITHUB_TOKEN }}
alias: deploy-preview-${{ github.event.number }}
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
drift:
name: "drift package"
needs: [setup]
runs-on: ubuntu-latest
defaults:
run:
working-directory: drift
steps:
# setup
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
with:
dart_version: ${{ needs.setup.outputs.dart_version }}
- run: melos bootstrap --scope drift
working-directory: .
# analysis
- run: dart format -o none --set-exit-if-changed .
name: dartfmt
- run: dart analyze --fatal-infos --fatal-warnings
# build, test and upload coverage
- run: dart run build_runner build --delete-conflicting-outputs
- run: dart run build_runner doctor
- run: dart test --preset ci_unit_tests #-x background_isolate --coverage=coverage
env:
DID_RUN_BUILD_RUNNER: "1"
# - uses: actions/upload-artifact@v2
# with:
# name: moor-coverage-data
# path: |
# moor/coverage/
# moor/.dart_tool/package_config.json
# retention-days: 1
drift_web_ddc:
needs: [drift]
runs-on: ubuntu-latest
defaults:
run:
working-directory: drift
steps:
# setup
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
with:
dart_version: ${{ needs.setup.outputs.dart_version }}
- run: melos bootstrap --scope drift
working-directory: .
# Using build_runner test allows compiling the tests with ddc, which is much faster than
# dart2js since we have a lot of entrypoints.
- run: dart run tool/test_with_ddc.dart
# todo: Even with shards, dart2js take too long. We run unit tests with ddc and dart2wasm and
# also run web integration tests (compiled with dart2js), so maybe we don't need those?
# drift_web_dart2js:
# needs: [drift]
# runs-on: ubuntu-latest
# defaults:
# run:
# working-directory: drift
# strategy:
# matrix:
# browser: [chrome, firefox]
# shard: [0, 1, 2, 3]
# name: "Drift web unit tests, dart2js, ${{ matrix.browser }}, shard ${{ matrix.shard }}"
# steps:
# # setup
# - uses: actions/checkout@v4
# - uses: ./.github/actions/prepare
# with:
# dart_version: ${{ needs.setup.outputs.dart_version }}
# - run: melos bootstrap --scope drift
# working-directory: .
# - run: dart test -p ${{ matrix.browser }} --compiler dart2js --total-shards 4 --shard-index ${{ matrix.shard }}
drift_web_dart2wasm:
needs: [drift]
runs-on: ubuntu-latest
defaults:
run:
working-directory: drift
strategy:
matrix:
browser: [chrome, firefox]
name: "Drift web unit tests, dart2wasm, ${{ matrix.browser }}"
steps:
# setup
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
with:
dart_version: ${{ needs.setup.outputs.dart_version }}
- run: melos bootstrap --scope drift
working-directory: .
- run: dart test -p ${{ matrix.browser }} --compiler dart2wasm
drift_dev:
runs-on: ubuntu-latest
needs: [setup]
timeout-minutes: 15
defaults:
run:
working-directory: drift_dev
steps:
# setup
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
with:
dart_version: ${{ needs.setup.outputs.dart_version }}
- run: melos bootstrap --scope drift_dev --scope drift
working-directory: .
# analysis
- run: dart format -o none --set-exit-if-changed .
name: dartfmt
- run: dart analyze --fatal-infos --fatal-warnings
- run: dart test
name: test
sqlparser:
runs-on: ubuntu-latest
needs: [setup]
defaults:
run:
working-directory: sqlparser
steps:
# setup
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
with:
dart_version: ${{ needs.setup.outputs.dart_version }}
- run: dart pub upgrade
# analysis
- run: dart format -o none --set-exit-if-changed .
name: dartfmt
- run: dart analyze --fatal-infos --fatal-warnings
# tests and coverage
- run: dart test #--coverage=coverage
# - uses: actions/upload-artifact@v2
# with:
# name: sqlparser-coverage-data
# path: |
# sqlparser/coverage/
# sqlparser/.dart_tool/package_config.json
# retention-days: 1
misc_integration_tests:
name: "Integration tests"
needs: [setup]
runs-on: ubuntu-latest
timeout-minutes: 10
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
mariadb:
image: mariadb
env:
MARIADB_ROOT_PASSWORD: password
MARIADB_DATABASE: database
ports:
- 3306:3306
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
with:
dart_version: ${{ needs.setup.outputs.dart_version }}
- run: melos bootstrap --no-flutter
working-directory: .
- name: Postgres integration tests
working-directory: extras/drift_postgres
run: |
dart pub upgrade
dart test -j 1
- name: MariaDB integration tests
working-directory: extras/drift_mariadb
continue-on-error: true
run: |
dart pub upgrade
dart test
- name: Integration test with built_value
working-directory: examples/with_built_value
run: |
dart pub upgrade
dart run build_runner build --delete-conflicting-outputs
- name: Integration test with modular generation
working-directory: examples/modular
run: |
dart pub upgrade
dart run build_runner build --delete-conflicting-outputs
dart run bin/example.dart
- name: Integration test for migrations example
working-directory: examples/migrations_example
run: |
dart pub upgrade
dart test
test_flutter:
runs-on: ubuntu-latest
needs: [setup]
strategy:
matrix:
# We want to support the two latest stable Flutter versions
# Unfortunately, we currently can't support Flutter 3.22 because it's
# incompatible with `dart_style: ^2.3.7` that `drift_dev` has to use:
# https://github.com/simolus3/drift/issues/3302
flutter: ["3.24"]
steps:
- uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ matrix.flutter }}
cache: true
cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:"
cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:"
- name: Setup melos
run: dart pub global activate melos && dart pub get
shell: bash
- name: Install dependencies in drift/example/app
run: melos bootstrap --scope app
- name: Download sqlite3
uses: actions/download-artifact@v4
with:
name: sqlite3
path: drift/.dart_tool/sqlite3/
- name: Use downloaded sqlite3
shell: bash
run: |
chmod a+x drift/.dart_tool/sqlite3/latest/sqlite3
echo $(realpath drift/.dart_tool/sqlite3/latest) >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=$(realpath drift/.dart_tool/sqlite3/latest)" >> $GITHUB_ENV
- name: Check sqlite3 version
run: sqlite3 --version
shell: bash
- name: Generate code
run: dart run build_runner build --delete-conflicting-outputs
working-directory: examples/app
- name: Test CLI
run: |
dart run drift_dev schema dump lib/database/database.dart drift_schemas/
dart run drift_dev schema generate drift_schemas/ test/generated_migrations/
dart run drift_dev schema steps drift_schemas/ lib/database/schema_versions.dart
working-directory: examples/app
- run: flutter analyze
working-directory: examples/app
- run: flutter test
working-directory: examples/app
migration_integration_tests:
name: "Integration tests for migration tooling"
needs: [setup]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
with:
dart_version: ${{ needs.setup.outputs.dart_version }}
- run: melos bootstrap --scope migrations_example
working-directory: .
- name: Run build
working-directory: examples/migrations_example
run: |
dart run build_runner build --delete-conflicting-outputs
dart run drift_dev schema generate drift_schemas/default test/generated/ --data-classes --companions
dart run drift_dev schema generate drift_schemas/ lib
- name: Test
working-directory: examples/migrations_example
run: dart test
- name: Test with older sqlite3
working-directory: examples/migrations_example
run: |
LD_LIBRARY_PATH=$(realpath ../../drift/.dart_tool/sqlite3/minimum) dart test
- name: Check that extracting schema still works
working-directory: examples/migrations_example
run: dart run drift_dev schema dump lib/database.dart drift_migrations/
web_integration_tests:
name: "Web integration tests"
needs: [drift]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare
with:
dart_version: ${{ needs.setup.outputs.dart_version }}
- uses: nanasess/setup-chromedriver@v2
- run: melos bootstrap --scope web_wasm
working-directory: .
- name: Test
working-directory: extras/integration_tests/web_wasm
run: dart test
# upload_coverage:
# runs-on: ubuntu-20.04
# needs: [moor, sqlparser]
# steps:
# - uses: actions/checkout@v2
# - uses: dart-lang/setup-dart@v1
# - run: dart pub upgrade
# name: "Setup coverage processor"
# working-directory: extras/tooling
# - uses: actions/download-artifact@v2
# with:
# name: moor-coverage-data
# path: moor/
# - uses: actions/download-artifact@v2
# with:
# name: sqlparser-coverage-data
# path: sqlparser/
# - run: dart run extras/tooling/bin/coverage.dart
# name: "Format coverage from raw data"
# - uses: codecov/codecov-action@v1
# with:
# file: lcov.info