Skip to content

Merge pull request #21 from stefannovasky/deprecate-object-target-fil… #52

Merge pull request #21 from stefannovasky/deprecate-object-target-fil…

Merge pull request #21 from stefannovasky/deprecate-object-target-fil… #52

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