-
Notifications
You must be signed in to change notification settings - Fork 2
282 lines (248 loc) · 10 KB
/
Copy pathbuild_and_test.yml
File metadata and controls
282 lines (248 loc) · 10 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
name: TidesDB C# CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:
jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
name: Linux x64
- os: macos-latest
name: macOS x64
- os: windows-latest
name: Windows x64
runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}
steps:
- name: Checkout tidesdb-cs repo
uses: actions/checkout@v4
with:
repository: tidesdb/tidesdb-cs
path: tidesdb-cs
- name: Checkout tidesdb repo
uses: actions/checkout@v4
with:
repository: tidesdb/tidesdb
path: tidesdb
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install -y libzstd-dev liblz4-dev libsnappy-dev build-essential cmake pkg-config
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: brew install zstd lz4 snappy
- name: Setup MSYS2 (Windows)
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
cache: false
install: >-
mingw-w64-x86_64-gcc
mingw-w64-x86_64-cmake
mingw-w64-x86_64-make
mingw-w64-x86_64-zstd
mingw-w64-x86_64-lz4
mingw-w64-x86_64-snappy
- name: Configure and build TidesDB (Linux)
if: runner.os == 'Linux'
run: |
cd tidesdb
cmake -S . -B build -DTIDESDB_BUILD_TESTS=OFF -DTIDESDB_WITH_SANITIZER=OFF -DBUILD_SHARED_LIBS=ON
cmake --build build --config Release
sudo cmake --install build
sudo ldconfig
- name: Configure and build TidesDB (macOS)
if: runner.os == 'macOS'
run: |
cd tidesdb
export HOMEBREW_PREFIX=$(brew --prefix)
cmake -S . -B build \
-DTIDESDB_BUILD_TESTS=OFF \
-DTIDESDB_WITH_SANITIZER=OFF \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_PREFIX_PATH="${HOMEBREW_PREFIX}"
cmake --build build --config Release
sudo cmake --install build
- name: Create CMake config files for MSYS2 packages (Windows)
if: runner.os == 'Windows'
shell: msys2 {0}
run: |
MINGW_PREFIX_WIN=$(cygpath -m /mingw64)
mkdir -p /mingw64/lib/cmake/lz4
mkdir -p /mingw64/lib/cmake/zstd
mkdir -p /mingw64/lib/cmake/Snappy
mkdir -p /mingw64/lib/cmake/PThreads4W
cat > /mingw64/lib/cmake/lz4/lz4-config.cmake << EOF
if(NOT TARGET lz4::lz4)
add_library(lz4::lz4 SHARED IMPORTED)
set_target_properties(lz4::lz4 PROPERTIES
IMPORTED_LOCATION "${MINGW_PREFIX_WIN}/bin/liblz4.dll"
IMPORTED_IMPLIB "${MINGW_PREFIX_WIN}/lib/liblz4.dll.a"
INTERFACE_INCLUDE_DIRECTORIES "${MINGW_PREFIX_WIN}/include"
)
endif()
EOF
cat > /mingw64/lib/cmake/zstd/zstd-config.cmake << EOF
if(NOT TARGET zstd::libzstd_shared)
add_library(zstd::libzstd_shared SHARED IMPORTED)
set_target_properties(zstd::libzstd_shared PROPERTIES
IMPORTED_LOCATION "${MINGW_PREFIX_WIN}/bin/libzstd.dll"
IMPORTED_IMPLIB "${MINGW_PREFIX_WIN}/lib/libzstd.dll.a"
INTERFACE_INCLUDE_DIRECTORIES "${MINGW_PREFIX_WIN}/include"
)
endif()
EOF
cat > /mingw64/lib/cmake/Snappy/Snappy-config.cmake << EOF
if(NOT TARGET Snappy::snappy)
add_library(Snappy::snappy SHARED IMPORTED)
set_target_properties(Snappy::snappy PROPERTIES
IMPORTED_LOCATION "${MINGW_PREFIX_WIN}/bin/libsnappy.dll"
IMPORTED_IMPLIB "${MINGW_PREFIX_WIN}/lib/libsnappy.dll.a"
INTERFACE_INCLUDE_DIRECTORIES "${MINGW_PREFIX_WIN}/include"
)
endif()
EOF
cat > /mingw64/lib/cmake/PThreads4W/PThreads4W-config.cmake << EOF
if(NOT TARGET PThreads4W::PThreads4W)
add_library(PThreads4W::PThreads4W SHARED IMPORTED)
set_target_properties(PThreads4W::PThreads4W PROPERTIES
IMPORTED_LOCATION "${MINGW_PREFIX_WIN}/bin/libwinpthread-1.dll"
IMPORTED_IMPLIB "${MINGW_PREFIX_WIN}/lib/libpthread.dll.a"
INTERFACE_INCLUDE_DIRECTORIES "${MINGW_PREFIX_WIN}/include"
)
endif()
EOF
- name: Configure and build TidesDB (Windows)
if: runner.os == 'Windows'
shell: msys2 {0}
run: |
cd tidesdb
cmake -G "MinGW Makefiles" \
-DCMAKE_MAKE_PROGRAM=mingw32-make \
-DCMAKE_PREFIX_PATH=/mingw64 \
-DTIDESDB_WITH_SANITIZER=OFF \
-DTIDESDB_BUILD_TESTS=OFF \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON \
-S . -B build
cmake --build build --config Release
cmake --install build --prefix /mingw64
# Copy the DLL to bin directory for runtime discovery
cp build/libtidesdb.dll /mingw64/bin/
# Verify the DLL has the expected exports
echo "=== Verifying DLL exports ==="
objdump -p build/libtidesdb.dll | grep -E "tidesdb_open|tidesdb_close" || echo "Warning: Expected exports not found"
# Print the Windows path for debugging
echo "=== MSYS2 to Windows path mapping ==="
cygpath -w /mingw64/bin/libtidesdb.dll
echo "RUNNER_TEMP=$RUNNER_TEMP"
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Build (Linux/macOS)
if: runner.os != 'Windows'
run: |
cd tidesdb-cs
dotnet build --configuration Release
- name: Build (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cd tidesdb-cs
dotnet build --configuration Release
- name: Test (Linux)
if: runner.os == 'Linux'
run: |
cd tidesdb-cs
dotnet test --configuration Release --no-build --verbosity normal
- name: Test (macOS)
if: runner.os == 'macOS'
run: |
cd tidesdb-cs
export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH
dotnet test --configuration Release --no-build --verbosity normal
- name: Verify TidesDB DLL (Windows)
if: runner.os == 'Windows'
shell: msys2 {0}
run: |
echo "=== Checking DLL locations ==="
ls -la /mingw64/bin/libtidesdb* || echo "No libtidesdb in bin"
ls -la /mingw64/bin/tidesdb* || echo "No tidesdb in bin"
ls -la /mingw64/lib/libtidesdb* || echo "No libtidesdb in lib"
echo "=== Windows paths ==="
echo "libtidesdb.dll Windows path: $(cygpath -w /mingw64/bin/libtidesdb.dll)"
echo "tidesdb.dll Windows path: $(cygpath -w /mingw64/bin/tidesdb.dll)"
echo "=== Checking DLL exports ==="
objdump -p /mingw64/bin/libtidesdb.dll | grep -A 50 "Export Table" || echo "Could not read exports"
- name: Test (Windows)
if: runner.os == 'Windows'
shell: pwsh
env:
CI: "true"
TIDESDB_DEBUG: "1"
run: |
Write-Host "=== TidesDB Windows Test ==="
# Find MSYS2 mingw64 bin directory
$msys2Bin = "$env:RUNNER_TEMP\msys64\mingw64\bin"
if (-not (Test-Path $msys2Bin)) {
Write-Host "ERROR: MSYS2 bin directory not found at $msys2Bin"
exit 1
}
Write-Host "MSYS2 bin: $msys2Bin"
# Find libtidesdb.dll
$libtidesdbPath = $null
if (Test-Path "$msys2Bin\libtidesdb.dll") {
$libtidesdbPath = "$msys2Bin\libtidesdb.dll"
} else {
$found = Get-ChildItem -Path "$PWD\tidesdb" -Recurse -Filter "libtidesdb.dll" -ErrorAction SilentlyContinue | Select-Object -First 1
if ($found) { $libtidesdbPath = $found.FullName }
}
if (-not $libtidesdbPath) {
Write-Host "ERROR: Could not find libtidesdb.dll!"
exit 1
}
Write-Host "Found libtidesdb.dll: $libtidesdbPath"
# Add MSYS2 bin to PATH for runtime dependency resolution
$env:PATH = "$msys2Bin;$env:PATH"
# Locate test and library output directories (relative to workspace root)
$testDir = "tidesdb-cs\tests\TidesDB.Tests\bin\Release\net8.0"
$libDir = "tidesdb-cs\src\TidesDB\bin\Release\net8.0"
if (-not (Test-Path $testDir)) {
Write-Host "ERROR: Test directory does not exist: $testDir"
Get-ChildItem "tidesdb-cs" -Recurse -Directory | Where-Object { $_.Name -eq "net8.0" } | ForEach-Object { Write-Host $_.FullName }
exit 1
}
# Copy native DLLs to test and library output directories
$nativeDlls = @(
"libzstd.dll",
"liblz4.dll",
"libsnappy.dll",
"libwinpthread-1.dll",
"libgcc_s_seh-1.dll",
"libstdc++-6.dll"
)
foreach ($dir in @($testDir, $libDir)) {
if (-not (Test-Path $dir)) { continue }
Copy-Item $libtidesdbPath "$dir\libtidesdb.dll" -Force
foreach ($dep in $nativeDlls) {
$src = "$msys2Bin\$dep"
if (Test-Path $src) { Copy-Item $src $dir -Force }
}
}
Write-Host "=== DLLs in test directory ==="
Get-ChildItem "$testDir\*.dll" | ForEach-Object { Write-Host $_.Name }
# Run tests from the repo root so global.json is picked up
Write-Host "=== Running tests ==="
cd tidesdb-cs
Write-Host "=== .NET SDK version: $(dotnet --version) ==="
dotnet test --configuration Release --no-build --verbosity normal