Skip to content

Commit 4355be9

Browse files
committed
Add native library copying and debugging to CI - Copy native libraries to test project output directory - Add debug step to show available files after build - Copy to both runtimes subfolder and output root for fallback - Should fix 'Unable to load shared library libdl' error in tests
1 parent b41f5e8 commit 4355be9

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.github/workflows/ci.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,58 @@ jobs:
132132
- name: Build solution
133133
run: dotnet build --configuration Release --no-restore
134134

135+
- name: Debug - Show available files
136+
if: matrix.os != 'windows-latest'
137+
shell: bash
138+
run: |
139+
echo "=== Main project output directory ==="
140+
ls -la src/PgQuery.NET/bin/Release/net8.0/ || echo "Main project bin not found"
141+
142+
echo "=== Native libraries in source ==="
143+
find src/PgQuery.NET/runtimes/ -type f 2>/dev/null || echo "No runtimes directory"
144+
145+
echo "=== Files in workspace root ==="
146+
ls -la libpgquery_wrapper.* 2>/dev/null || echo "No wrapper libraries in root"
147+
148+
- name: Copy native libraries to test project
149+
if: matrix.os != 'windows-latest'
150+
shell: bash
151+
run: |
152+
# Determine platform
153+
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
154+
TARGET_RID="linux-x64"
155+
LIBRARY_EXT="so"
156+
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
157+
if [[ $(uname -m) == "arm64" ]]; then
158+
TARGET_RID="osx-arm64"
159+
else
160+
TARGET_RID="osx-x64"
161+
fi
162+
LIBRARY_EXT="dylib"
163+
fi
164+
165+
# Copy native libraries to test project output
166+
TEST_OUTPUT_DIR="tests/PgQuery.NET.Tests/bin/Release/net9.0"
167+
mkdir -p "$TEST_OUTPUT_DIR/runtimes/$TARGET_RID/native"
168+
169+
if [ -f "src/PgQuery.NET/runtimes/$TARGET_RID/native/libpgquery_wrapper.$LIBRARY_EXT" ]; then
170+
# Copy to runtimes subfolder (standard .NET location)
171+
cp "src/PgQuery.NET/runtimes/$TARGET_RID/native/libpgquery_wrapper.$LIBRARY_EXT" "$TEST_OUTPUT_DIR/runtimes/$TARGET_RID/native/"
172+
173+
# Also copy directly to output directory root for fallback
174+
cp "src/PgQuery.NET/runtimes/$TARGET_RID/native/libpgquery_wrapper.$LIBRARY_EXT" "$TEST_OUTPUT_DIR/"
175+
176+
echo "Copied native library to test output directory"
177+
echo "Runtime location:"
178+
ls -la "$TEST_OUTPUT_DIR/runtimes/$TARGET_RID/native/"
179+
echo "Direct location:"
180+
ls -la "$TEST_OUTPUT_DIR/libpgquery_wrapper.$LIBRARY_EXT"
181+
else
182+
echo "Warning: Native library not found at src/PgQuery.NET/runtimes/$TARGET_RID/native/libpgquery_wrapper.$LIBRARY_EXT"
183+
echo "Available files in src/PgQuery.NET/runtimes/:"
184+
find src/PgQuery.NET/runtimes/ -name "*.so" -o -name "*.dylib" || echo "No native libraries found"
185+
fi
186+
135187
- name: Run tests
136188
run: dotnet test --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage"
137189

0 commit comments

Comments
 (0)