Skip to content

Commit 29d69bf

Browse files
committed
Add GitHub Actions
1 parent 79827af commit 29d69bf

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

.github/workflows/ci.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
# Unified build on default GitHub runners
12+
build:
13+
name: Build (${{ matrix.os }})
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest, macos-latest, macos-26, windows-latest]
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
- name: Build and Test
23+
shell: bash
24+
run: |
25+
./test.sh
26+
27+
# Examples on all default runners
28+
examples:
29+
name: Examples (${{ matrix.os }})
30+
runs-on: ${{ matrix.os }}
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
os: [ubuntu-latest, macos-latest, macos-26, windows-latest]
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
- name: Build and run examples (Linux/macOS)
39+
if: ${{ runner.os != 'Windows' }}
40+
shell: bash
41+
run: |
42+
set -e
43+
cd examples/c-tasks && ./build.sh
44+
build/objectbox-examples-c-tasks "Buy raspberries"
45+
build/objectbox-examples-c-tasks
46+
cd ../c-tasks-lowlevel && ./build.sh
47+
build/objectbox-examples-c-tasks-lowlevel "Buy blueberries"
48+
build/objectbox-examples-c-tasks-lowlevel
49+
cd ../tasks && ./build.sh
50+
printf "new \"Buy apples\"\nls\nexit" | build/objectbox-examples-tasks
51+
cd ../tasks-sync && ./build.sh || true
52+
if [ -x build/objectbox-examples-tasks-sync ]; then printf "new \"Buy bananas\"\nls\nexit" | build/objectbox-examples-tasks-sync; fi
53+
cd ../vectorsearch-cities && ./build.sh
54+
printf "name berlin\nexit" | build/objectbox-examples-vectorsearch-cities
55+
- name: Build and run examples (Windows)
56+
if: ${{ runner.os == 'Windows' }}
57+
shell: bash
58+
run: |
59+
set -e
60+
61+
find_bin() {
62+
local base="$1"
63+
for cand in "build/$base" "build/Debug/$base.exe" "build/Release/$base.exe"; do
64+
if [ -f "$cand" ]; then
65+
echo "$cand"
66+
return 0
67+
fi
68+
done
69+
return 1
70+
}
71+
72+
ensure_dll() {
73+
local bindir="$1"
74+
for dll_src in \
75+
"build/_deps/objectbox-sync-download-src/lib/objectbox.dll" \
76+
"build/_deps/objectbox-download-src/lib/objectbox.dll"; do
77+
if [ -f "$dll_src" ]; then
78+
echo "Copying DLL: $dll_src to $bindir/"
79+
cp -f "$dll_src" "$bindir/"
80+
return 0
81+
fi
82+
done
83+
echo "Warning: DLL not found"
84+
return 1
85+
}
86+
87+
# c-tasks example
88+
cd examples/c-tasks && ./build.sh
89+
bin=$(find_bin objectbox-examples-c-tasks)
90+
ensure_dll "$(dirname "$bin")"
91+
"$bin" "Buy raspberries"
92+
"$bin"
93+
94+
# c-tasks-lowlevel example
95+
cd ../c-tasks-lowlevel && ./build.sh
96+
bin=$(find_bin objectbox-examples-c-tasks-lowlevel)
97+
ensure_dll "$(dirname "$bin")"
98+
"$bin" "Buy blueberries"
99+
"$bin"
100+
101+
# tasks example
102+
cd ../tasks && ./build.sh
103+
bin=$(find_bin objectbox-examples-tasks)
104+
ensure_dll "$(dirname "$bin")"
105+
printf "new \"Buy apples\"\r\nls\r\nexit\r\n" | "$bin"
106+
107+
# tasks-sync example (may fail to build without sync feature)
108+
cd ../tasks-sync && ./build.sh || true
109+
if bin=$(find_bin objectbox-examples-tasks-sync); then
110+
ensure_dll "$(dirname "$bin")"
111+
printf "new \"Buy bananas\"\r\nls\r\nexit\r\n" | "$bin" || echo "tasks-sync failed; continuing"
112+
fi
113+
114+
# vectorsearch-cities example (may fail without vector search feature)
115+
cd ../vectorsearch-cities && ./build.sh
116+
if bin=$(find_bin objectbox-examples-vectorsearch-cities); then
117+
ensure_dll "$(dirname "$bin")"
118+
echo -e "name berlin\nexit" | "$bin" || echo "vectorsearch-cities returned non-zero (likely missing feature); continuing"
119+
fi

0 commit comments

Comments
 (0)