Skip to content

Commit 3543e6b

Browse files
authored
Merge pull request #1 from sqliteai/update-build-pipeline
new build, test and release workflow; makefile refactor; fixes to guarantee cross-platform compatibility
2 parents a6333a6 + 1f78c53 commit 3543e6b

40 files changed

+467
-6404
lines changed

.github/workflows/main.yml

Lines changed: 171 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
name: build sqlitesync
1+
name: build, test and release sqlite-sync
22
on:
33
push:
4-
branches:
5-
- main
4+
5+
permissions:
6+
contents: write
7+
pages: write
8+
id-token: write
69

710
jobs:
811
build:
912
runs-on: ${{ matrix.os }}
10-
name: build for ${{ matrix.name }}-${{ matrix.arch }}
13+
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.name != 'isim' && matrix.name != 'ios' && ' + test' || ''}}
1114
timeout-minutes: 20
1215
strategy:
1316
fail-fast: false
@@ -22,23 +25,22 @@ jobs:
2225
configure: --with-openssl
2326
name: linux
2427
- os: macos-latest
25-
arch: arm64
26-
configure: --with-secure-transport
27-
name: macos
28-
- os: macos-13
29-
arch: x86_64
30-
configure: --with-secure-transport
28+
configure:
29+
--with-secure-transport
30+
CFLAGS="-arch x86_64 -arch arm64"
3131
name: macos
3232
- os: windows-latest
3333
arch: x86_64
34-
configure: --with-schannel
34+
configure:
35+
--with-schannel
36+
CFLAGS="-DCURL_STATICLIB"
3537
name: windows
3638
- os: ubuntu-latest
37-
arch: arm64
39+
arch: arm64-v8a
3840
configure:
3941
--host aarch64-linux-android26
4042
--with-openssl=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr
41-
LIBS="-lssl -lcrypto -lc++"
43+
LIBS="-lssl -lcrypto"
4244
AR=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
4345
AS=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as
4446
CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang
@@ -47,12 +49,15 @@ jobs:
4749
RANLIB=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib
4850
STRIP=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip
4951
name: android
52+
make:
53+
PLATFORM=android
54+
CC=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android26-clang
5055
- os: ubuntu-latest
5156
arch: x86_64
5257
configure:
5358
--host x86_64-linux-android26
5459
--with-openssl=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr
55-
LIBS="-lssl -lcrypto -lc++"
60+
LIBS="-lssl -lcrypto"
5661
AR=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
5762
AS=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-as
5863
CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android26-clang
@@ -61,27 +66,24 @@ jobs:
6166
RANLIB=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ranlib
6267
STRIP=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip
6368
name: android
69+
make:
70+
PLATFORM=android
71+
CC=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android26-clang
72+
sqlite-amalgamation-zip: https://sqlite.org/2025/sqlite-amalgamation-3490100.zip
6473
- os: macos-latest
65-
arch: arm64
6674
configure:
6775
--host=arm64-apple-darwin
6876
--with-secure-transport
6977
CFLAGS="-arch arm64 -isysroot $(xcrun --sdk iphoneos --show-sdk-path) -miphoneos-version-min=11.0"
7078
name: ios
79+
make: PLATFORM=ios
7180
- os: macos-latest
72-
arch: arm64
7381
configure:
7482
--host=arm64-apple-darwin
7583
--with-secure-transport
76-
CFLAGS="-arch arm64 -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path) -miphonesimulator-version-min=11.0"
77-
name: isim
78-
- os: macos-latest
79-
arch: x86_64
80-
configure:
81-
--host=x86_64-apple-darwin
82-
--with-secure-transport
83-
CFLAGS="-arch x86_64 -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path) -miphonesimulator-version-min=11.0"
84+
CFLAGS="-arch x86_64 -arch arm64 -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path) -miphonesimulator-version-min=11.0"
8485
name: isim
86+
make: PLATFORM=isim
8587

8688
defaults:
8789
run:
@@ -108,27 +110,27 @@ jobs:
108110
extract: true
109111
fileName: curl-*.tar.gz
110112

111-
- name: build boringssl
113+
- name: build openssl
112114
if: matrix.name == 'android'
113115
run: |
114-
git clone https://boringssl.googlesource.com/boringssl
115-
cd boringssl
116-
mkdir build
117-
cd build
118-
cmake \
119-
-DANDROID_ABI=${{ matrix.arch == 'arm64' && 'arm64-v8a' || 'x86_64' }} \
120-
-DANDROID_PLATFORM=android-26 \
121-
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
122-
-DOPENSSL_SMALL=1 \
123-
-DCMAKE_BUILD_TYPE=Release \
124-
..
116+
git clone https://github.com/openssl/openssl.git
117+
cd openssl
118+
export TOOLCHAIN=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64
119+
export ARCH=${{ matrix.arch }}
120+
export PATH=$TOOLCHAIN/bin:$PATH
121+
122+
./Configure android-${{ matrix.arch == 'arm64-v8a' && 'arm64' || matrix.arch }} \
123+
--prefix=$PWD/build \
124+
--openssldir=$PWD/build/ssl \
125+
no-shared \
126+
no-unit-test \
127+
-D__ANDROID_API__=26
125128
make
129+
make install_sw
126130
127-
cd ..
128-
TOOLCHAIN="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64"
129-
cp build/libssl.a $TOOLCHAIN/sysroot/usr/lib/
130-
cp build/libcrypto.a $TOOLCHAIN/sysroot/usr/lib/
131-
cp -r include/openssl $TOOLCHAIN/sysroot/usr/include/
131+
cp build/lib/libssl.a $TOOLCHAIN/sysroot/usr/lib/
132+
cp build/lib/libcrypto.a $TOOLCHAIN/sysroot/usr/lib/
133+
cp -r build/include/openssl $TOOLCHAIN/sysroot/usr/include/
132134
133135
- name: build curl
134136
run: |
@@ -205,15 +207,137 @@ jobs:
205207
# --without-libgsasl \
206208
207209
cd ..
208-
mkdir -p network/curl/${{ matrix.name }}
209-
mv $folder/lib/.libs/libcurl.a network/curl/${{ matrix.name }}/lib${{matrix.arch}}.a
210+
mkdir -p curl/${{ matrix.name }}
211+
mv $folder/lib/.libs/libcurl.a curl/${{ matrix.name }}
212+
213+
- name: build sqlite-sync
214+
run: make ${{ matrix.make && matrix.make || ''}}
215+
shell: bash
216+
217+
- name: windows install sqlite3
218+
if: matrix.os == 'windows-latest'
219+
run: choco install sqlite -y
220+
shell: bash
221+
222+
- name: macos install sqlite3 without SQLITE_OMIT_LOAD_EXTENSION
223+
if: matrix.name == 'macos'
224+
run: brew link sqlite --force
225+
226+
- name: android setup test environment
227+
if: matrix.name == 'android' && matrix.arch != 'arm64-v8a'
228+
run: |
229+
230+
echo "::group::enable kvm group perms"
231+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
232+
sudo udevadm control --reload-rules
233+
sudo udevadm trigger --name-match=kvm
234+
echo "::endgroup::"
235+
236+
echo "::group::download and build sqlite3 without SQLITE_OMIT_LOAD_EXTENSION"
237+
curl -O ${{ matrix.sqlite-amalgamation-zip }}
238+
unzip sqlite-amalgamation-*.zip
239+
export ${{ matrix.make }}
240+
$CC sqlite-amalgamation-*/shell.c sqlite-amalgamation-*/sqlite3.c -o sqlite3 -ldl
241+
# remove unused folders to save up space
242+
rm -rf sqlite-amalgamation-*.zip sqlite-amalgamation-* curl-* openssl
243+
echo "::endgroup::"
244+
245+
echo "::group::prepare the test script"
246+
make test CC=$CC PLATFORM=$PLATFORM || echo "It should fail. Running remaining commands in the emulator"
247+
cat > commands.sh << EOF
248+
mv -f /data/local/tmp/sqlite3 /system/xbin
249+
cd /data/local/tmp
250+
$(make test CC=$CC PLATFORM=$PLATFORM -n)
251+
EOF
252+
echo "::endgroup::"
253+
254+
- name: android test sqlite-sync
255+
if: matrix.name == 'android' && matrix.arch != 'arm64-v8a'
256+
uses: reactivecircus/[email protected]
257+
with:
258+
api-level: 26
259+
arch: ${{ matrix.arch }}
260+
script: |
261+
adb root
262+
adb remount
263+
adb push ${{ github.workspace }}/. /data/local/tmp/
264+
adb shell "sh /data/local/tmp/commands.sh"
265+
266+
- name: test sqlite-sync
267+
if: matrix.name == 'linux' || matrix.name == 'windows'
268+
run: make test
269+
shell: bash
270+
271+
- name: test sqlite-sync + coverage
272+
if: matrix.name == 'macos'
273+
run: brew install lcov && make test COVERAGE=true
274+
275+
- uses: actions/[email protected]
276+
if: matrix.name == 'macos'
277+
with:
278+
path: coverage
210279

211280
- uses: actions/[email protected]
281+
if: always()
212282
with:
213-
name: libcurl-${{ matrix.name }}-${{ matrix.arch }}
214-
path: network/curl/${{ matrix.name }}/lib${{matrix.arch}}.a
283+
name: cloudsync-${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }}
284+
path: dist/cloudsync.*
215285
if-no-files-found: error
216286

217-
- name: build sqlitesync
287+
release:
288+
runs-on: ubuntu-latest
289+
name: release
290+
needs: build
291+
if: github.ref == 'refs/heads/main'
292+
293+
env:
294+
GH_TOKEN: ${{ github.token }}
295+
296+
steps:
297+
298+
- uses: actions/[email protected]
299+
300+
- uses: actions/[email protected]
301+
with:
302+
path: artifacts
303+
304+
- name: setup GitHub Pages
305+
uses: actions/configure-pages@v5
306+
307+
- name: deploy coverage to GitHub Pages
308+
uses: actions/[email protected]
309+
310+
- name: release tag version from cloudsync.h
311+
id: tag
312+
run: |
313+
FILE="src/cloudsync.h"
314+
VERSION=$(grep -oP '#define CLOUDSYNC_VERSION\s+"\K[^"]+' "$FILE")
315+
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
316+
echo "version=$VERSION" >> $GITHUB_OUTPUT
317+
exit 0
318+
fi
319+
echo "❌ CLOUDSYNC_VERSION not found in cloudsync.h"
320+
exit 1
321+
322+
- name: zip artifacts
218323
run: |
219-
echo "TODO: build sqlitesync"
324+
for folder in "artifacts"/*; do
325+
if [ -d "$folder" ]; then
326+
name=$(basename "$folder")
327+
if [[ "$name" != "github-pages" ]]; then
328+
zip -jq "${name}-${{ steps.tag.outputs.version }}.zip" "$folder"/*
329+
tar -cJf "${name}-${{ steps.tag.outputs.version }}.tar.xz" -C "$folder" .
330+
tar -czf "${name}-${{ steps.tag.outputs.version }}.tar.gz" -C "$folder" .
331+
fi
332+
fi
333+
done
334+
335+
- uses: softprops/[email protected]
336+
with:
337+
generate_release_notes: true
338+
tag_name: ${{ steps.tag.outputs.version }}
339+
files: |
340+
cloudsync-*-${{ steps.tag.outputs.version }}.zip
341+
cloudsync-*-${{ steps.tag.outputs.version }}.tar.xz
342+
cloudsync-*-${{ steps.tag.outputs.version }}.tar.gz
343+
make_latest: true

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
.DS_Store
2+
*.xcworkspacedata
3+
*.xcuserstate
4+
*.xcbkptlist
5+
*.plist
6+
/build
7+
/dist
8+
/coverage
9+
*.sqlite
10+
*.a

0 commit comments

Comments
 (0)