forked from simolus3/sqlite3.dart
-
Notifications
You must be signed in to change notification settings - Fork 1
287 lines (255 loc) · 9.12 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
name: CI
on:
push:
branches: ['**']
pull_request:
branches: [ main ]
jobs:
compile_sqlite3:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
name: Compile sqlite3 for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
SQLITE_YEAR: "2023"
SQLITE_VERSION: "3420000"
steps:
- uses: actions/cache@v4
id: cache_sqlite_build
with:
path: sqlite/out
key: sqlite-v3-${{ runner.os }}-${{ env.SQLITE_VERSION }}
- name: Compile sqlite3 on Linux
if: steps.cache_sqlite_build.outputs.cache-hit != 'true' && runner.os == 'Linux'
run: |
mkdir sqlite
cd sqlite
curl https://sqlite.org/$SQLITE_YEAR/sqlite-autoconf-$SQLITE_VERSION.tar.gz --output sqlite.tar.gz
tar zxvf sqlite.tar.gz
cd sqlite-autoconf-$SQLITE_VERSION
./configure
make -j
mkdir ../out
cp sqlite3 ../out
cp .libs/libsqlite3.so ../out
cp *.h ../out
- name: Compile sqlite3 on macOS
if: steps.cache_sqlite_build.outputs.cache-hit != 'true' && runner.os == 'macOS'
run: |
mkdir sqlite
cd sqlite
curl https://sqlite.org/$SQLITE_YEAR/sqlite-autoconf-$SQLITE_VERSION.tar.gz --output sqlite.tar.gz
tar zxvf sqlite.tar.gz
cd sqlite-autoconf-$SQLITE_VERSION
./configure
make -j
mkdir ../out
cp sqlite3 ../out
cp .libs/libsqlite3.dylib ../out
cp *.h ../out
- uses: ilammy/msvc-dev-cmd@v1
if: steps.cache_sqlite_build.outputs.cache-hit != 'true' && runner.os == 'Windows'
- name: Compile sqlite3 on Windows
if: steps.cache_sqlite_build.outputs.cache-hit != 'true' && runner.os == 'Windows'
run: |
mkdir sqlite
cd sqlite
curl https://sqlite.org/$Env:SQLITE_YEAR/sqlite-autoconf-$Env:SQLITE_VERSION.tar.gz --output sqlite.tar.gz
tar zxvf sqlite.tar.gz
cd sqlite-autoconf-$Env:SQLITE_VERSION
./configure
nmake /f Makefile.msc sqlite3.c
"#define SQLITE_API __declspec(dllexport)" | Out-File -FilePath sqlite3e.c
'#include "sqlite3.c"' | Out-File -FilePath sqlite3e.c -Append
cl sqlite3e.c -link -dll -out:sqlite3.dll
mkdir ../out
cp sqlite3.dll ../out
cp sqlite3.h ../out
cp sqlite3ext.h ../out
cp *.h ../out
- name: Upload built sqlite3 binaries
uses: actions/upload-artifact@v4
with:
name: sqlite3-${{ runner.os }}
path: sqlite/out
if-no-files-found: error
retention-days: 1
analyze:
needs: [compile_sqlite3]
strategy:
matrix:
package: [sqlite3]
dart: [stable]
name: Analyze on Dart ${{ matrix.dart }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.dart }}
- uses: actions/cache@v4
with:
path: "${{ env.PUB_CACHE }}"
key: dart-dependencies-${{ matrix.dart }}-${{ runner.os }}
restore-keys: |
dart-dependencies-${{ matrix.dart }}-
dart-dependencies-
- name: Pub get
run: dart pub get
working-directory: ${{ matrix.package }}
- name: Format dart
run: dart format --set-exit-if-changed .
working-directory: ${{ matrix.package }}
- name: Format native
run: clang-format --Werror --dry-run --style=google assets/sqlite3.h assets/wasm/*.{c,h} test/**/*.c
if: ${{ matrix.package == 'sqlite3' }}
working-directory: sqlite3
- name: Analyze
run: dart analyze --fatal-infos lib/ test/
working-directory: ${{ matrix.package }}
test:
needs: [analyze]
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
dart: [stable, dev]
name: Unit tests with Dart ${{ matrix.dart }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.dart }}
- name: Download compiled sqlite3
if: runner.os == 'Linux' || runner.os == 'Windows' || runner.os == 'macOS'
uses: actions/download-artifact@v4
with:
name: sqlite3-${{ runner.os }}
path: sqlite/out
- name: Install compiled sqlite3 (Linux)
if: runner.os == 'Linux'
run: |
chmod a+x sqlite/out/sqlite3
realpath sqlite/out >> $GITHUB_PATH
echo "LD_LIBRARY_PATH=$(realpath sqlite/out)" >> $GITHUB_ENV
echo "C_INCLUDE_PATH=$(realpath sqlite/out)" >> $GITHUB_ENV
- name: Install compiled sqlite3 (macOS)
if: runner.os == 'macOS'
run: |
chmod a+x sqlite/out/sqlite3
echo "$(pwd)/sqlite/out" >> $GITHUB_PATH
echo "DYLD_LIBRARY_PATH=$(pwd)/sqlite/out" >> $GITHUB_ENV
echo "CPATH=$(pwd)/sqlite/out" >> $GITHUB_ENV
- uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
- name: Install compiled sqlite3 (Windows)
if: runner.os == 'Windows'
run: |
echo $env:path
Resolve-Path -Path "sqlite/out" >> $env:GITHUB_PATH
"INCLUDE=" + $env:INCLUDE + ";" + (Resolve-Path -Path "sqlite/out") >> $env:GITHUB_EN
- uses: actions/cache@v4
with:
path: "${{ env.PUB_CACHE }}"
key: dart-dependencies-${{ matrix.dart }}-${{ runner.os }}
restore-keys: |
dart-dependencies-${{ matrix.dart }}-
dart-dependencies-
- name: Test
run: |
dart pub get
dart test -P ci
working-directory: sqlite3/
- name: Web tests
run: |
curl https://storage.googleapis.com/simon-public-euw3/assets/sqlite3/wasm/2.4.6/sqlite3.wasm -o example/web/sqlite3.wasm
dart test -P web -r expanded
# If browsers behave differently on different platforms, surely that's not our fault...
# So, only run browser tests on Linux to be faster.
# todo: Something broke Dart web tests in Dart 2.18, it looks like this is related to finalizers
if: runner.os == 'Linux'
working-directory: sqlite3/
# The integration tests for android are currently broken (the emulator doesn't want to
# start up...)
#
# integration_test_android:
# runs-on: macos-latest
# needs: [test]
# strategy:
# matrix:
# test:
# - flutter_libs
# - sqlcipher_flutter
# steps:
# - uses: actions/checkout@v4
# - uses: subosito/flutter-action@v2
# with:
# channel: dev
# - name: pub get
# working-directory: "integration_tests/${{ matrix.test }}"
# run: flutter pub get
#
# - name: run tests
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: 29
# script: flutter test integration_test
# working-directory: "integration_tests/${{ matrix.test }}"
integration_test_linux:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/[email protected]
- name: Setup Flutter
run: |
flutter config --enable-linux-desktop
sudo apt-get update -y
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev
flutter --version
- name: sqlite3 driver tests
run: "flutter pub get && xvfb-run -a flutter test integration_test"
working-directory: integration_tests/flutter_libs
- name: sqlcipher driver tests
run: "flutter pub get && xvfb-run -a flutter test integration_test"
working-directory: integration_tests/sqlcipher_flutter
# Shamelessly stolen from https://medium.com/flutter-community/run-flutter-driver-tests-on-github-actions-13c639c7e4ab
integration_test_ios:
if: "false" # Temporarily disabled since it causes timeouts
needs: [test]
runs-on: macos-latest
steps:
- name: List simulators
run: "xcrun xctrace list devices"
- name: Start simulator
run: |
IPHONE12=$(xcrun xctrace list devices 2>&1 | grep -m 1 "iPhone 14 Pro" | awk -F'[()]' '{print $4}')
xcrun simctl boot $IPHONE12
- uses: actions/checkout@v4
- uses: subosito/[email protected]
- name: Flutter version
run: flutter --version
- name: sqlite3 driver tests
run: "flutter pub get && flutter test integration_test"
working-directory: integration_tests/flutter_libs
- name: sqlcipher driver tests
run: "flutter pub get && flutter test integration_test"
working-directory: integration_tests/sqlcipher_flutter
integration_test_macos:
if: "false" # Temporarily disabled since it causes timeouts
needs: [test]
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/[email protected]
- name: Setup Flutter
run: |
flutter config --enable-macos-desktop
flutter --version
- name: sqlite3 driver tests
run: "flutter pub get && flutter test integration_test"
working-directory: integration_tests/flutter_libs
- name: sqlcipher driver tests
run: "flutter pub get && flutter test integration_test"
working-directory: integration_tests/sqlcipher_flutter