Skip to content

Commit f58638d

Browse files
committed
Add GitHub Actions
1 parent 79827af commit f58638d

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed

.github/workflows/ci.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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
39+
# unified script for Linux/macOS/Windows
40+
shell: bash
41+
run: |
42+
set -e
43+
44+
# Only needed on Windows runners: copy required DLL next to the executable
45+
copy_dll_to_dir() {
46+
local bin_dir="$1"
47+
local src
48+
for src in \
49+
build/_deps/objectbox-sync-download-src/lib/objectbox.dll \
50+
build/_deps/objectbox-download-src/lib/objectbox.dll; do
51+
if [ -f "$src" ]; then
52+
cp -f "$src" "$bin_dir/"
53+
return 0
54+
fi
55+
done
56+
return 1
57+
}
58+
59+
find_bin() {
60+
local base="$1"
61+
local candidate
62+
local exe_file="$base"
63+
if [ "${RUNNER_OS:-}" == "Windows" ]; then
64+
exe_file="$base.exe"
65+
fi
66+
67+
for candidate in "build/$exe_file" "build/Debug/$exe_file" "build/Release/$exe_file"; do
68+
if [ -f "$candidate" ]; then
69+
if [ "${RUNNER_OS:-}" == "Windows" ]; then
70+
copy_dll_to_dir "$(dirname "$candidate")"
71+
fi
72+
echo "$candidate"
73+
return 0
74+
fi
75+
done
76+
return 1
77+
}
78+
79+
# c-tasks example
80+
cd examples/c-tasks && ./build.sh
81+
bin=$(find_bin objectbox-examples-c-tasks)
82+
"$bin" "Buy raspberries"
83+
"$bin"
84+
85+
# c-tasks-lowlevel example
86+
cd ../c-tasks-lowlevel && ./build.sh
87+
bin=$(find_bin objectbox-examples-c-tasks-lowlevel)
88+
"$bin" "Buy blueberries"
89+
"$bin"
90+
91+
# tasks example
92+
cd ../tasks && ./build.sh
93+
bin=$(find_bin objectbox-examples-tasks)
94+
printf "new \"Buy apples\"\nls\nexit\n" | "$bin"
95+
96+
# tasks-sync example
97+
cd ../tasks-sync && ./build.sh
98+
bin=$(find_bin objectbox-examples-tasks-sync)
99+
printf "new \"Buy bananas\"\nls\nexit\n" | "$bin"
100+
101+
# vectorsearch-cities example
102+
cd ../vectorsearch-cities && ./build.sh
103+
bin=$(find_bin objectbox-examples-vectorsearch-cities)
104+
printf "name berlin\nexit\n" | "$bin"

0 commit comments

Comments
 (0)