Skip to content

Commit 53c3a03

Browse files
committed
Add back main workflow
1 parent a153836 commit 53c3a03

File tree

1 file changed

+281
-0
lines changed

1 file changed

+281
-0
lines changed

.github/workflows/main.yml

Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ['**']
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
compile_sqlite3:
11+
strategy:
12+
matrix:
13+
os: [windows-latest, ubuntu-latest, macos-latest]
14+
15+
name: Compile sqlite3 for ${{ matrix.os }}
16+
runs-on: ${{ matrix.os }}
17+
env:
18+
SQLITE_YEAR: "2023"
19+
SQLITE_VERSION: "3420000"
20+
21+
steps:
22+
- uses: actions/cache@v4
23+
id: cache_sqlite_build
24+
with:
25+
path: sqlite/out
26+
key: sqlite-${{ runner.os }}-${{ env.SQLITE_VERSION }}
27+
- name: Compile sqlite3 on Linux
28+
if: steps.cache_sqlite_build.outputs.cache-hit != 'true' && runner.os == 'Linux'
29+
run: |
30+
mkdir sqlite
31+
cd sqlite
32+
curl https://sqlite.org/$SQLITE_YEAR/sqlite-autoconf-$SQLITE_VERSION.tar.gz --output sqlite.tar.gz
33+
tar zxvf sqlite.tar.gz
34+
cd sqlite-autoconf-$SQLITE_VERSION
35+
./configure
36+
make -j
37+
mkdir ../out
38+
cp sqlite3 ../out
39+
cp .libs/libsqlite3.so ../out
40+
- name: Compile sqlite3 on macOS
41+
if: steps.cache_sqlite_build.outputs.cache-hit != 'true' && runner.os == 'macOS'
42+
run: |
43+
mkdir sqlite
44+
cd sqlite
45+
curl https://sqlite.org/$SQLITE_YEAR/sqlite-autoconf-$SQLITE_VERSION.tar.gz --output sqlite.tar.gz
46+
tar zxvf sqlite.tar.gz
47+
cd sqlite-autoconf-$SQLITE_VERSION
48+
./configure
49+
make -j
50+
mkdir ../out
51+
cp sqlite3 ../out
52+
cp .libs/libsqlite3.dylib ../out
53+
- uses: ilammy/msvc-dev-cmd@v1
54+
if: steps.cache_sqlite_build.outputs.cache-hit != 'true' && runner.os == 'Windows'
55+
- name: Compile sqlite3 on Windows
56+
if: steps.cache_sqlite_build.outputs.cache-hit != 'true' && runner.os == 'Windows'
57+
run: |
58+
mkdir sqlite
59+
cd sqlite
60+
curl https://sqlite.org/$Env:SQLITE_YEAR/sqlite-autoconf-$Env:SQLITE_VERSION.tar.gz --output sqlite.tar.gz
61+
tar zxvf sqlite.tar.gz
62+
cd sqlite-autoconf-$Env:SQLITE_VERSION
63+
./configure
64+
nmake /f Makefile.msc sqlite3.c
65+
"#define SQLITE_API __declspec(dllexport)" | Out-File -FilePath sqlite3e.c
66+
'#include "sqlite3.c"' | Out-File -FilePath sqlite3e.c -Append
67+
cl sqlite3e.c -link -dll -out:sqlite3.dll
68+
mkdir ../out
69+
cp sqlite3.dll ../out
70+
cp sqlite3.h ../out
71+
cp sqlite3ext.h ../out
72+
- name: Upload built sqlite3 binaries
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: sqlite3-${{ runner.os }}
76+
path: sqlite/out
77+
if-no-files-found: error
78+
retention-days: 1
79+
80+
analyze:
81+
needs: [compile_sqlite3]
82+
strategy:
83+
matrix:
84+
package: [sqlite3]
85+
dart: [stable]
86+
87+
name: Analyze on Dart ${{ matrix.dart }}
88+
runs-on: ubuntu-latest
89+
steps:
90+
- uses: actions/checkout@v4
91+
- uses: dart-lang/setup-dart@v1
92+
with:
93+
sdk: ${{ matrix.dart }}
94+
- uses: actions/cache@v4
95+
with:
96+
path: "${{ env.PUB_CACHE }}"
97+
key: dart-dependencies-${{ matrix.dart }}-${{ runner.os }}
98+
restore-keys: |
99+
dart-dependencies-${{ matrix.dart }}-
100+
dart-dependencies-
101+
102+
- name: Pub get
103+
run: dart pub get
104+
working-directory: ${{ matrix.package }}
105+
106+
- name: Format dart
107+
run: dart format --set-exit-if-changed .
108+
working-directory: ${{ matrix.package }}
109+
110+
- name: Format native
111+
run: clang-format --Werror --dry-run --style=google assets/sqlite3.h assets/wasm/*.{c,h} test/**/*.c
112+
if: ${{ matrix.package == 'sqlite3' }}
113+
working-directory: sqlite3
114+
115+
- name: Analyze
116+
run: dart analyze --fatal-infos lib/ test/
117+
working-directory: ${{ matrix.package }}
118+
119+
test:
120+
needs: [analyze]
121+
strategy:
122+
matrix:
123+
os: [ubuntu-latest, windows-latest, macos-latest]
124+
dart: [stable, dev]
125+
126+
name: Unit tests with Dart ${{ matrix.dart }} on ${{ matrix.os }}
127+
runs-on: ${{ matrix.os }}
128+
129+
steps:
130+
- uses: actions/checkout@v4
131+
- uses: dart-lang/setup-dart@v1
132+
with:
133+
sdk: ${{ matrix.dart }}
134+
135+
- name: Download compiled sqlite3
136+
if: runner.os == 'Linux' || runner.os == 'Windows' || runner.os == 'macOS'
137+
uses: actions/download-artifact@v4
138+
with:
139+
name: sqlite3-${{ runner.os }}
140+
path: sqlite/out
141+
142+
- name: Install compiled sqlite3 (Linux)
143+
if: runner.os == 'Linux'
144+
run: |
145+
chmod a+x sqlite/out/sqlite3
146+
realpath sqlite/out >> $GITHUB_PATH
147+
echo "LD_LIBRARY_PATH=$(realpath sqlite/out)" >> $GITHUB_ENV
148+
- name: Install compiled sqlite3 (macOS)
149+
if: runner.os == 'macOS'
150+
run: |
151+
chmod a+x sqlite/out/sqlite3
152+
echo "$(pwd)/sqlite/out" >> $GITHUB_PATH
153+
echo "DYLD_LIBRARY_PATH=$(pwd)/sqlite/out" >> $GITHUB_ENV
154+
- uses: ilammy/msvc-dev-cmd@v1
155+
if: runner.os == 'Windows'
156+
- name: Install compiled sqlite3 (Windows)
157+
if: runner.os == 'Windows'
158+
run: |
159+
echo $env:path
160+
Resolve-Path -Path "sqlite/out" >> $env:GITHUB_PATH
161+
"INCLUDE=" + $env:INCLUDE + ";" + (Resolve-Path -Path "sqlite/out") >> $env:GITHUB_EN
162+
163+
- uses: actions/cache@v4
164+
with:
165+
path: "${{ env.PUB_CACHE }}"
166+
key: dart-dependencies-${{ matrix.dart }}-${{ runner.os }}
167+
restore-keys: |
168+
dart-dependencies-${{ matrix.dart }}-
169+
dart-dependencies-
170+
171+
- name: Test
172+
run: |
173+
dart pub get
174+
dart test -P ci
175+
working-directory: sqlite3/
176+
177+
- name: Web tests
178+
run: |
179+
curl https://storage.googleapis.com/simon-public-euw3/assets/sqlite3/wasm/2.4.3/sqlite3.wasm -o example/web/sqlite3.wasm
180+
dart test -P web -r expanded
181+
# If browsers behave differently on different platforms, surely that's not our fault...
182+
# So, only run browser tests on Linux to be faster.
183+
# todo: Something broke Dart web tests in Dart 2.18, it looks like this is related to finalizers
184+
if: runner.os == 'Linux'
185+
working-directory: sqlite3/
186+
187+
# The integration tests for android are currently broken (the emulator doesn't want to
188+
# start up...)
189+
#
190+
# integration_test_android:
191+
# runs-on: macos-latest
192+
# needs: [test]
193+
# strategy:
194+
# matrix:
195+
# test:
196+
# - flutter_libs
197+
# - sqlcipher_flutter
198+
# steps:
199+
# - uses: actions/checkout@v4
200+
# - uses: subosito/flutter-action@v2
201+
# with:
202+
# channel: dev
203+
# - name: pub get
204+
# working-directory: "integration_tests/${{ matrix.test }}"
205+
# run: flutter pub get
206+
#
207+
# - name: run tests
208+
# uses: reactivecircus/android-emulator-runner@v2
209+
# with:
210+
# api-level: 29
211+
# script: flutter test integration_test
212+
# working-directory: "integration_tests/${{ matrix.test }}"
213+
214+
integration_test_linux:
215+
needs: [test]
216+
runs-on: ubuntu-latest
217+
steps:
218+
- uses: actions/checkout@v4
219+
- uses: subosito/[email protected]
220+
- name: Setup Flutter
221+
run: |
222+
flutter config --enable-linux-desktop
223+
sudo apt-get update -y
224+
sudo apt-get install -y clang cmake ninja-build pkg-config libgtk-3-dev liblzma-dev
225+
flutter --version
226+
227+
- name: sqlite3 driver tests
228+
run: "flutter pub get && xvfb-run -a flutter test integration_test"
229+
working-directory: integration_tests/flutter_libs
230+
231+
- name: sqlcipher driver tests
232+
run: "flutter pub get && xvfb-run -a flutter test integration_test"
233+
working-directory: integration_tests/sqlcipher_flutter
234+
235+
# Shamelessly stolen from https://medium.com/flutter-community/run-flutter-driver-tests-on-github-actions-13c639c7e4ab
236+
237+
integration_test_ios:
238+
needs: [test]
239+
runs-on: macos-latest
240+
steps:
241+
- name: List simulators
242+
run: "xcrun xctrace list devices"
243+
244+
- name: Start simulator
245+
run: |
246+
IPHONE12=$(xcrun xctrace list devices 2>&1 | grep -m 1 "iPhone 14 Pro" | awk -F'[()]' '{print $4}')
247+
xcrun simctl boot $IPHONE12
248+
249+
- uses: actions/checkout@v4
250+
- uses: subosito/[email protected]
251+
252+
- name: Flutter version
253+
run: flutter --version
254+
255+
- name: sqlite3 driver tests
256+
run: "flutter pub get && flutter test integration_test"
257+
working-directory: integration_tests/flutter_libs
258+
259+
- name: sqlcipher driver tests
260+
run: "flutter pub get && flutter test integration_test"
261+
working-directory: integration_tests/sqlcipher_flutter
262+
263+
integration_test_macos:
264+
if: "false" # Temporarily disabled since it causes timeouts
265+
needs: [test]
266+
runs-on: macos-latest
267+
steps:
268+
- uses: actions/checkout@v4
269+
- uses: subosito/[email protected]
270+
- name: Setup Flutter
271+
run: |
272+
flutter config --enable-macos-desktop
273+
flutter --version
274+
275+
- name: sqlite3 driver tests
276+
run: "flutter pub get && flutter test integration_test"
277+
working-directory: integration_tests/flutter_libs
278+
279+
- name: sqlcipher driver tests
280+
run: "flutter pub get && flutter test integration_test"
281+
working-directory: integration_tests/sqlcipher_flutter

0 commit comments

Comments
 (0)