Skip to content

chore: updated and linted #394

chore: updated and linted

chore: updated and linted #394

Workflow file for this run

name: CI C#
on:
push:
branches: [main]
paths:
- '.github/actions/**'
- '.github/workflows/ci-csharp.yaml'
- '.cargo/config.toml'
- 'rust-toolchain.toml'
- 'Cargo.toml'
- 'Cargo.lock'
- 'crates/kreuzberg/**'
- 'crates/kreuzberg-ffi/**'
- 'crates/kreuzberg-tesseract/**'
- 'packages/csharp/**'
- 'e2e/csharp/**'
- 'test_documents/**'
- 'fixtures/**'
- 'tools/e2e-generator/**'
- 'scripts/ci/csharp/**'
- 'scripts/ci/cache/**'
- 'scripts/ci/actions/**'
pull_request:
branches: [main]
paths:
- '.github/actions/**'
- '.github/workflows/ci-csharp.yaml'
- '.cargo/config.toml'
- 'rust-toolchain.toml'
- 'Cargo.toml'
- 'Cargo.lock'
- 'crates/kreuzberg/**'
- 'crates/kreuzberg-ffi/**'
- 'crates/kreuzberg-tesseract/**'
- 'packages/csharp/**'
- 'e2e/csharp/**'
- 'test_documents/**'
- 'fixtures/**'
- 'tools/e2e-generator/**'
- 'scripts/ci/csharp/**'
- 'scripts/ci/cache/**'
- 'scripts/ci/actions/**'
concurrency:
group: ci-csharp-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_PROFILE_DEV_DEBUG: 0
RUST_BACKTRACE: short
RUST_MIN_STACK: 16777216
BUILD_PROFILE: "ci"
DOTNET_VERSION: '10.0.x'
PDFIUM_VERSION: '7578'
PDFIUM_STATIC_VERSION: '7442b'
ORT_VERSION: '1.23.2'
MACOSX_DEPLOYMENT_TARGET: '14.0'
jobs:
build-csharp:
name: C# Build + Smoke (${{ matrix.os }})
if: ${{ github.actor != 'dependabot[bot]' }}
timeout-minutes: 180
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Enable symlinks on Windows
if: runner.os == 'Windows'
shell: bash
run: |
git config core.symlinks true
git reset --hard HEAD
- name: Install system dependencies
uses: ./.github/actions/install-system-deps
- name: Setup OpenSSL
uses: ./.github/actions/setup-openssl
- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
cache-key-prefix: csharp-${{ matrix.os }}
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages (Windows)
if: runner.os == 'Windows'
uses: actions/cache@v5
with:
path: |
~\.nuget\packages
~\AppData\Local\NuGet\v3-cache
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '**/packages.lock.json') }}
restore-keys: nuget-${{ runner.os }}-
- name: Cache NuGet packages (Unix)
if: runner.os != 'Windows'
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '**/packages.lock.json') }}
restore-keys: nuget-${{ runner.os }}-
- name: Cache PDFium
uses: ./.github/actions/cache-pdfium
with:
pdfium-version: ${{ env.PDFIUM_VERSION }}
- name: Download PDFium
uses: ./.github/actions/download-pdfium
with:
pdfium-version: ${{ env.PDFIUM_VERSION }}
- name: Stage PDFium runtime
uses: ./.github/actions/stage-pdfium-runtime
with:
destination: target/release
- name: Setup ONNX Runtime
uses: ./.github/actions/setup-onnx-runtime
with:
ort-version: ${{ env.ORT_VERSION }}
- name: Install Task
uses: ./.github/actions/install-task
- name: Build FFI library
id: ffi
shell: bash
run: |
echo "=== Building FFI Library ==="
echo "Building kreuzberg-ffi from source (no caching)"
cargo build --release --package kreuzberg-ffi
- name: Set library paths for .NET
shell: bash
run: |
if [[ "${{ runner.os }}" == "macOS" ]]; then
echo "DYLD_LIBRARY_PATH=${{ github.workspace }}/target/release:$DYLD_LIBRARY_PATH" >> "$GITHUB_ENV"
elif [[ "${{ runner.os }}" == "Linux" ]]; then
echo "LD_LIBRARY_PATH=${{ github.workspace }}/target/release:$LD_LIBRARY_PATH" >> "$GITHUB_ENV"
elif [[ "${{ runner.os }}" == "Windows" ]]; then
echo "${{ github.workspace }}/target/release" >> "$GITHUB_PATH"
fi
- name: Build C# bindings
run: task csharp:build:ci
- name: Upload FFI library
uses: actions/upload-artifact@v6
with:
name: csharp-ffi-lib-${{ matrix.os }}
path: |
target/release/libkreuzberg_ffi.dylib
target/release/libkreuzberg_ffi.so
target/release/kreuzberg_ffi.dll
retention-days: 7
- name: Cleanup Rust cache
if: always()
uses: ./.github/actions/cleanup-rust-cache
test-csharp:
name: C# Tests (${{ matrix.os }})
if: ${{ github.actor != 'dependabot[bot]' }}
needs: build-csharp
timeout-minutes: 180
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Enable symlinks on Windows
if: runner.os == 'Windows'
shell: bash
run: |
git config core.symlinks true
git reset --hard HEAD
- name: Install system dependencies
uses: ./.github/actions/install-system-deps
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages (Windows)
if: runner.os == 'Windows'
uses: actions/cache@v5
with:
path: |
~\.nuget\packages
~\AppData\Local\NuGet\v3-cache
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '**/packages.lock.json') }}
restore-keys: nuget-${{ runner.os }}-
- name: Cache NuGet packages (Unix)
if: runner.os != 'Windows'
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: nuget-${{ runner.os }}-${{ hashFiles('**/*.csproj', '**/packages.lock.json') }}
restore-keys: nuget-${{ runner.os }}-
- name: Cache PDFium
uses: ./.github/actions/cache-pdfium
with:
pdfium-version: ${{ env.PDFIUM_VERSION }}
- name: Download PDFium
uses: ./.github/actions/download-pdfium
with:
pdfium-version: ${{ env.PDFIUM_VERSION }}
- name: Stage PDFium runtime
uses: ./.github/actions/stage-pdfium-runtime
with:
destination: target/release
- name: Setup ONNX Runtime
uses: ./.github/actions/setup-onnx-runtime
with:
ort-version: ${{ env.ORT_VERSION }}
- name: Setup Tesseract environment
shell: bash
run: scripts/ci/csharp/setup-tessdata-env.sh
- name: Download FFI library
uses: actions/download-artifact@v7
with:
name: csharp-ffi-lib-${{ matrix.os }}
path: target/release/
- name: Prepare crash dumps
shell: bash
run: mkdir -p packages/csharp/target/crash-dumps
- name: Install Task
uses: ./.github/actions/install-task
- name: Run C# tests
env:
KREUZBERG_FFI_DIR: ${{ github.workspace }}/target/release
COMPlus_DbgEnableMiniDump: "1"
COMPlus_DbgMiniDumpType: "4"
COMPlus_DbgMiniDumpName: ${{ github.workspace }}/packages/csharp/target/crash-dumps/kreuzberg.%p.dmp
DOTNET_DbgEnableMiniDump: "1"
DOTNET_DbgMiniDumpType: "4"
DOTNET_DbgMiniDumpName: ${{ github.workspace }}/packages/csharp/target/crash-dumps/kreuzberg.%p.dmp
DOTNET_EnableDiagnostics: "1"
RUST_BACKTRACE: full
run: task csharp:test:ci
- name: Run E2E tests
env:
KREUZBERG_FFI_DIR: ${{ github.workspace }}/target/release
LD_LIBRARY_PATH: ${{ github.workspace }}/target/release:${{ env.LD_LIBRARY_PATH }}
DYLD_LIBRARY_PATH: ${{ github.workspace }}/target/release:${{ env.DYLD_LIBRARY_PATH }}
KREUZBERG_SKIP_LEGACY_OFFICE: ${{ runner.os == 'Windows' && '1' || '' }}
run: task csharp:e2e:test
- name: Upload C# crash dumps
if: always()
uses: actions/upload-artifact@v6
with:
name: csharp-crash-dumps-${{ matrix.os }}
path: |
packages/csharp/target/crash-dumps
if-no-files-found: ignore
retention-days: 7