Skip to content

Commit 24ca313

Browse files
authored
add linux musl builds (#14)
* feat(workflow): add musl build for alpine container * feat(workflow): add musl arm64 builds * fix(workflow): update ARM architecture OS to ubuntu-24.04-arm in build matrix * fix(workflow): adjust build steps for musl target in CI workflow * fix(workflow): adjust shell usage for musl builds in CI workflow * feat(workflow): add install build dependencies for musl * feat(workflow): add curl to build dependencies for musl * feat(workflow): add openssl-dev to build dependencies for musl * feat(workflow): enable musl test * feat(workflow): add git clone step for musl arm64 builds * feat(workflow): add sqlite to build dependencies for musl * fix(workflow): update condition for checkout step and git clone for musl arm64 after git install * fix(workflow): add safe.directory configuration for musl arm64 git clone * fix(workflow): add diagnostic commands for gcc and make in musl arm64 build step * fix(workflow): remove diagnostic commands for gcc and make from musl arm64 build step * fix(workflow): update safe.directory configuration for musl arm64 git clone * fix(workflow): rename musl arm64 git clone step and remove unnecessary echo commands * fix(workflow): remove unnecessary build dependencies for linux-musl arm64 * fix(workflow): streamline installation of build dependencies for linux-musl * fix(workflow): move linux-musl configurations * fix(workflow): update linux-musl job configurations for arm64 and x86_64 * fix(workflow): add musl-gcc as compiler for linux-musl arm64 job * fix(workflow): update shell command for linux-musl job to use alpine condition * fix(workflow): enhance linux-musl arm64 job to build and install OpenSSL with musl-gcc * fix(workflow): update arm64 dependencies for linux-musl job to include linux-libc-dev and wget * fix(workflow): add CPPFLAGS for musl-gcc configuration in OpenSSL build step * fix(workflow): update linux-musl arm64 job to use Docker for building and testing * fix(workflow): update OS version for linux-musl arm64 job to use ubuntu-22.04-arm * fix(workflow): add error handling in linux-musl arm64 build step * fix(workflow): refactor linux-musl arm64 build to use Docker for dependency installation and execution * bump version to 0.8.22 * fix(workflow): update OS versions in CI configuration and improve coverage handling in Makefile
1 parent bb81148 commit 24ca313

File tree

3 files changed

+57
-37
lines changed

3 files changed

+57
-37
lines changed

.github/workflows/main.yml

Lines changed: 53 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,48 +11,57 @@ permissions:
1111
jobs:
1212
build:
1313
runs-on: ${{ matrix.os }}
14+
container: ${{ matrix.container && matrix.container || '' }}
1415
name: ${{ matrix.name }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} build${{ matrix.arch != 'arm64-v8a' && matrix.name != 'ios-sim' && matrix.name != 'ios' && matrix.name != 'wasm' && matrix.name != 'apple-xcframework' && ' + test' || ''}}
1516
timeout-minutes: 20
1617
strategy:
1718
fail-fast: false
1819
matrix:
1920
include:
20-
- os: ubuntu-latest
21+
- os: ubuntu-22.04
2122
arch: x86_64
2223
name: linux
23-
- os: LinuxARM64
24+
- os: ubuntu-22.04-arm
2425
arch: arm64
2526
name: linux
26-
- os: macos-latest
27+
- os: ubuntu-22.04
28+
arch: x86_64
29+
name: linux-musl
30+
container: alpine:latest
31+
- os: ubuntu-22.04-arm
32+
arch: arm64
33+
name: linux-musl
34+
- os: macos-15
2735
name: macos
28-
- os: windows-latest
36+
make: COVERAGE=ON
37+
- os: windows-2022
2938
arch: x86_64
3039
name: windows
31-
- os: ubuntu-latest
40+
- os: ubuntu-22.04
3241
arch: arm64-v8a
3342
name: android
3443
make: PLATFORM=android ARCH=arm64-v8a
35-
- os: ubuntu-latest
44+
- os: ubuntu-22.04
3645
arch: x86_64
3746
name: android
3847
make: PLATFORM=android ARCH=x86_64
3948
sqlite-amalgamation-zip: https://sqlite.org/2025/sqlite-amalgamation-3490100.zip
40-
- os: macos-latest
49+
- os: macos-15
4150
name: ios
4251
make: PLATFORM=ios
43-
- os: macos-latest
52+
- os: macos-15
4453
name: ios-sim
4554
make: PLATFORM=ios-sim
46-
- os: ubuntu-latest
55+
- os: ubuntu-22.04
4756
name: wasm
4857
make: PLATFORM=wasm
49-
- os: macos-latest
58+
- os: macos-15
5059
name: apple-xcframework
5160
make: xcframework
5261

5362
defaults:
5463
run:
55-
shell: bash
64+
shell: ${{ contains(matrix.container, 'alpine') && 'sh' || 'bash' }}
5665

5766
env:
5867
CONNECTION_STRING: ${{ secrets.CONNECTION_STRING }}
@@ -64,15 +73,39 @@ jobs:
6473
- uses: actions/checkout@v4.2.2
6574

6675
- uses: msys2/setup-msys2@v2.27.0
67-
if: matrix.os == 'windows-latest'
76+
if: matrix.name == 'windows'
6877
with:
6978
msystem: mingw64
70-
install: >-
71-
mingw-w64-x86_64-cc
72-
make
79+
install: mingw-w64-x86_64-cc make
80+
81+
- name: windows install dependencies
82+
if: matrix.name == 'windows'
83+
run: choco install sqlite -y
84+
85+
- name: macos install dependencies
86+
if: matrix.name == 'macos'
87+
run: brew link sqlite --force && brew install lcov
88+
89+
- name: linux-musl x86_64 install dependencies
90+
if: matrix.name == 'linux-musl' && matrix.arch == 'x86_64'
91+
run: apk update && apk add --no-cache gcc make curl sqlite openssl-dev musl-dev linux-headers
92+
93+
- name: linux-musl arm64 setup container
94+
if: matrix.name == 'linux-musl' && matrix.arch == 'arm64'
95+
run: |
96+
docker run -d --name alpine \
97+
--platform linux/arm64 \
98+
-v ${{ github.workspace }}:/workspace \
99+
-w /workspace \
100+
-e CONNECTION_STRING="${{ env.CONNECTION_STRING }}" \
101+
-e APIKEY="${{ env.APIKEY }}" \
102+
-e WEBLITE="${{ env.WEBLITE }}" \
103+
alpine:latest \
104+
tail -f /dev/null
105+
docker exec alpine sh -c "apk update && apk add --no-cache gcc make curl sqlite openssl-dev musl-dev linux-headers"
73106
74107
- name: windows build curl
75-
if: matrix.os == 'windows-latest'
108+
if: matrix.name == 'windows'
76109
run: make curl/windows/libcurl.a
77110
shell: msys2 {0}
78111

@@ -81,15 +114,7 @@ jobs:
81114
run: sudo apt install wabt
82115

83116
- name: build sqlite-sync
84-
run: make extension ${{ matrix.make && matrix.make || ''}}
85-
86-
- name: windows install sqlite3
87-
if: matrix.os == 'windows-latest'
88-
run: choco install sqlite -y
89-
90-
- name: macos install sqlite3 without SQLITE_OMIT_LOAD_EXTENSION
91-
if: matrix.name == 'macos'
92-
run: brew link sqlite --force
117+
run: ${{ matrix.name == 'linux-musl' && matrix.arch == 'arm64' && 'docker exec alpine' || '' }} make extension ${{ matrix.make && matrix.make || ''}}
93118

94119
- name: android setup test environment
95120
if: matrix.name == 'android' && matrix.arch != 'arm64-v8a'
@@ -135,12 +160,8 @@ jobs:
135160
adb shell "sh /data/local/tmp/commands.sh"
136161
137162
- name: test sqlite-sync
138-
if: matrix.name == 'linux' || matrix.name == 'windows'
139-
run: make test
140-
141-
- name: test sqlite-sync + coverage
142-
if: matrix.name == 'macos'
143-
run: brew install lcov && make test COVERAGE=true
163+
if: contains(matrix.name, 'linux') || matrix.name == 'windows' || matrix.name == 'macos'
164+
run: ${{ matrix.name == 'linux-musl' && matrix.arch == 'arm64' && 'docker exec alpine' || '' }} make test ${{ matrix.make && matrix.make || ''}}
144165

145166
- uses: actions/upload-pages-artifact@v3.0.1
146167
if: matrix.name == 'macos'
@@ -155,7 +176,7 @@ jobs:
155176
if-no-files-found: error
156177

157178
release:
158-
runs-on: ubuntu-latest
179+
runs-on: ubuntu-22.04
159180
name: release
160181
needs: build
161182
if: github.ref == 'refs/heads/main'

Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ CC = gcc
3535
CFLAGS = -Wall -Wextra -Wno-unused-parameter -I$(SRC_DIR) -I$(SQLITE_DIR) -I$(CURL_DIR)/include
3636
T_CFLAGS = $(CFLAGS) -DSQLITE_CORE -DCLOUDSYNC_UNITTEST -DCLOUDSYNC_OMIT_NETWORK -DCLOUDSYNC_OMIT_PRINT_RESULT
3737
LDFLAGS = -L./$(CURL_DIR)/$(PLATFORM) -lcurl
38-
COVERAGE = false
3938

4039
# Directories
4140
SRC_DIR = src
@@ -128,7 +127,7 @@ else # linux
128127
STRIP = strip --strip-unneeded $@
129128
endif
130129

131-
ifneq ($(COVERAGE),false)
130+
ifdef COVERAGE
132131
ifneq (,$(filter $(platform),linux windows))
133132
T_LDFLAGS += -lgcov
134133
endif
@@ -207,7 +206,7 @@ $(BUILD_TEST)/%.o: %.c
207206
test: $(TARGET) $(TEST_TARGET)
208207
$(SQLITE3) ":memory:" -cmd ".bail on" ".load ./$<" "SELECT cloudsync_version();"
209208
set -e; for t in $(TEST_TARGET); do ./$$t; done
210-
ifneq ($(COVERAGE),false)
209+
ifdef COVERAGE
211210
mkdir -p $(COV_DIR)
212211
lcov --capture --directory . --output-file $(COV_DIR)/coverage.info $(subst src, --include src,${COV_FILES})
213212
genhtml $(COV_DIR)/coverage.info --output-directory $(COV_DIR)
@@ -386,7 +385,7 @@ help:
386385
@echo "Targets:"
387386
@echo " all - Build the extension (default)"
388387
@echo " clean - Remove built files"
389-
@echo " test [COVERAGE=true] - Test the extension with optional coverage output"
388+
@echo " test [COVERAGE=ON] - Test the extension with optional coverage output"
390389
@echo " help - Display this help message"
391390

392391
.PHONY: all clean test extension help xcframework

src/cloudsync.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "sqlite3.h"
1717
#endif
1818

19-
#define CLOUDSYNC_VERSION "0.8.21"
19+
#define CLOUDSYNC_VERSION "0.8.22"
2020

2121
int sqlite3_cloudsync_init (sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi);
2222

0 commit comments

Comments
 (0)