Skip to content

Commit 381ec5e

Browse files
committed
Add GitHub Actions
1 parent 79827af commit 381ec5e

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

.github/workflows/ci.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build:
12+
name: Build (${{ matrix.os }})
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
os: [ubuntu-latest, macos-latest, macos-26, windows-latest]
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Build and Test
22+
shell: bash
23+
run: |
24+
./test.sh
25+
26+
examples:
27+
name: Examples (${{ matrix.os }})
28+
runs-on: ${{ matrix.os }}
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
os: [ubuntu-latest, macos-latest, macos-26, windows-latest]
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
- name: Build and run examples
37+
shell: bash
38+
run: |
39+
set -e
40+
41+
# Only needed on Windows runners: copy required DLL next to the executable
42+
copy_dll_to_dir() {
43+
local bin_dir="$1"
44+
local src
45+
for src in \
46+
build/_deps/objectbox-sync-download-src/lib/objectbox.dll \
47+
build/_deps/objectbox-download-src/lib/objectbox.dll; do
48+
if [ -f "$src" ]; then
49+
cp -f "$src" "$bin_dir/"
50+
return 0
51+
fi
52+
done
53+
return 1
54+
}
55+
56+
# This is mainly useful for Windows, as it defaults to use Debug/Release sub-directories
57+
find_bin() {
58+
local base="$1"
59+
local candidate
60+
local exe_file="$base"
61+
if [ "${RUNNER_OS:-}" == "Windows" ]; then
62+
exe_file="$base.exe"
63+
fi
64+
65+
for candidate in "build/$exe_file" "build/Debug/$exe_file" "build/Release/$exe_file"; do
66+
if [ -f "$candidate" ]; then
67+
if [ "${RUNNER_OS:-}" == "Windows" ]; then
68+
copy_dll_to_dir "$(dirname "$candidate")"
69+
fi
70+
echo "$candidate"
71+
return 0
72+
fi
73+
done
74+
return 1
75+
}
76+
77+
echo "### c-tasks example ###"
78+
cd examples/c-tasks && ./build.sh
79+
bin=$(find_bin objectbox-examples-c-tasks)
80+
"$bin" "Buy raspberries"
81+
"$bin"
82+
83+
echo "### c-tasks-lowlevel example ###"
84+
cd ../c-tasks-lowlevel && ./build.sh
85+
bin=$(find_bin objectbox-examples-c-tasks-lowlevel)
86+
"$bin" "Buy blueberries"
87+
"$bin"
88+
89+
echo "### tasks example ###"
90+
cd ../tasks && ./build.sh
91+
bin=$(find_bin objectbox-examples-tasks)
92+
printf "new \"Buy apples\"\nls\nexit\n" | "$bin"
93+
94+
echo "### tasks-sync example ###"
95+
cd ../tasks-sync && ./build.sh
96+
bin=$(find_bin objectbox-examples-tasks-sync)
97+
printf "new \"Buy bananas\"\nls\nexit\n" | "$bin"
98+
99+
echo "### vectorsearch-cities example ###"
100+
cd ../vectorsearch-cities && ./build.sh
101+
bin=$(find_bin objectbox-examples-vectorsearch-cities)
102+
printf "name berlin\nexit\n" | "$bin"

0 commit comments

Comments
 (0)