Skip to content

Commit 08a2ed7

Browse files
committed
Add GitHub Actions
1 parent 79827af commit 08a2ed7

File tree

1 file changed

+118
-0
lines changed

1 file changed

+118
-0
lines changed

.github/workflows/ci.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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+
find_bin() {
61+
local base="$1"
62+
local cand
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+
# Typical locations where CMake FetchContent puts the DLL
75+
local dll_src=
76+
for dll_src in \
77+
"build/_deps/objectbox-download-src/lib/objectbox.dll" \
78+
"build/_deps/objectbox-sync-download-src/lib/objectbox.dll"; do
79+
if [ -f "$dll_src" ]; then
80+
echo "Found DLL: $dll_src"
81+
cp -f "$dll_src" "$bindir/"
82+
return 0
83+
fi
84+
done
85+
echo "DLL not found"
86+
return 1
87+
}
88+
89+
cd examples/c-tasks && ./build.sh
90+
bin=$(find_bin objectbox-examples-c-tasks)
91+
ensure_dll "$(dirname "$bin")"
92+
"$bin" "Buy raspberries"
93+
"$bin"
94+
cd ../c-tasks-lowlevel && ./build.sh
95+
bin=$(find_bin objectbox-examples-c-tasks-lowlevel)
96+
ensure_dll "$(dirname "$bin")"
97+
"$bin" "Buy blueberries"
98+
"$bin"
99+
cd ../tasks && ./build.sh
100+
bin=$(find_bin objectbox-examples-tasks)
101+
ensure_dll "$(dirname "$bin")"
102+
printf "new \"Buy apples\"\nls\nexit" | "$bin"
103+
cd ../tasks-sync && ./build.sh || true
104+
if bin=$(find_bin objectbox-examples-tasks-sync); then
105+
ensure_dll "$(dirname "$bin")"
106+
# Feed commands via here-doc to reliably close stdin on Windows
107+
timeout 25s bash -lc 'cat <<EOF | "'$bin'"
108+
new "Buy bananas"
109+
ls
110+
exit
111+
EOF
112+
' || echo "tasks-sync timed out; continuing"
113+
fi
114+
cd ../vectorsearch-cities && ./build.sh
115+
if bin=$(find_bin objectbox-examples-vectorsearch-cities); then
116+
ensure_dll "$(dirname "$bin")"
117+
printf "name berlin\nexit" | "$bin" || echo "vectorsearch example returned non-zero (likely missing OBXFeature_VectorSearch); continuing"
118+
fi

0 commit comments

Comments
 (0)