Skip to content

chore: updated and linted #84

chore: updated and linted

chore: updated and linted #84

Workflow file for this run

name: CI PHP
on:
push:
branches: [main]
paths:
- '.github/actions/**'
- '.github/workflows/ci-php.yaml'
- '.cargo/config.toml'
- 'rust-toolchain.toml'
- 'Cargo.toml'
- 'Cargo.lock'
- 'crates/kreuzberg/**'
- 'crates/kreuzberg-php/**'
- 'crates/kreuzberg-ffi/**'
- 'crates/kreuzberg-tesseract/**'
- 'packages/php/**'
- 'e2e/php/**'
- 'test_documents/**'
- 'fixtures/**'
- 'tools/e2e-generator/**'
- 'scripts/ci/php/**'
- 'scripts/ci/cache/**'
- 'scripts/ci/actions/**'
pull_request:
branches: [main]
paths:
- '.github/actions/**'
- '.github/workflows/ci-php.yaml'
- '.cargo/config.toml'
- 'rust-toolchain.toml'
- 'Cargo.toml'
- 'Cargo.lock'
- 'crates/kreuzberg/**'
- 'crates/kreuzberg-php/**'
- 'crates/kreuzberg-ffi/**'
- 'crates/kreuzberg-tesseract/**'
- 'packages/php/**'
- 'e2e/php/**'
- 'test_documents/**'
- 'fixtures/**'
- 'tools/e2e-generator/**'
- 'scripts/ci/php/**'
- 'scripts/ci/cache/**'
- 'scripts/ci/actions/**'
concurrency:
group: ci-php-${{ 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: full
RUST_MIN_STACK: 16777216
PDFIUM_VERSION: "7578"
ORT_VERSION: "1.23.2"
MACOSX_DEPLOYMENT_TARGET: "14.0"
CARGO_LOG: cargo::core::compiler::fingerprint=info
RUST_LOG: debug
BUILD_PROFILE: "ci"
jobs:
build-php-extension:
name: PHP Build (${{ 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: Install system dependencies
uses: ./.github/actions/install-system-deps
- name: Free disk space before setup
if: startsWith(matrix.os, 'ubuntu')
uses: ./.github/actions/free-disk-space-linux
with:
show-initial: "true"
show-final: "true"
- name: Setup OpenSSL
uses: ./.github/actions/setup-openssl
- name: Setup Rust
id: rust
uses: ./.github/actions/setup-rust
with:
cache-key-prefix: php-${{ matrix.os }}
- name: Detect partial cache hit and clean stale fingerprints
shell: bash
run: |
# Check if cache was a partial hit (restored from fallback key)
# For now, we'll do a more conservative check: always clean before build
# since the current Cargo.lock changes frequently
echo "Preparing clean Rust build environment..."
cargo clean --release -p kreuzberg-php 2>/dev/null || true
cargo clean --release -p kreuzberg 2>/dev/null || true
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
extensions: ffi
tools: composer
- name: Export PHP build config
if: matrix.os != 'windows-latest'
shell: bash
run: |
PHP_CONFIG_BIN="$(command -v php-config || true)"
if [ -z "$PHP_CONFIG_BIN" ]; then
echo "php-config not found in PATH" >&2
exit 1
fi
echo "PHP_CONFIG=$PHP_CONFIG_BIN" >> "$GITHUB_ENV"
- name: Print PHP environment
shell: bash
run: |
echo "=== PHP Environment ==="
echo "PHP version: $(php --version)"
if command -v php-config >/dev/null 2>&1; then
echo "PHP config (php-config): $(php-config --version)"
else
echo "PHP config (php-config): not available"
fi
echo "PHP ini: $(php --ini)"
echo "Composer version: $(composer --version)"
- name: Install Composer dependencies
shell: bash
working-directory: packages/php
run: composer install --no-progress --prefer-dist
- 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: Export macOS PHP linker flags
if: matrix.os == 'macos-latest'
shell: bash
run: |
EXTRA_FLAGS="-C link-arg=-Wl,-undefined,dynamic_lookup"
if [ -n "${RUSTFLAGS:-}" ]; then
echo "RUSTFLAGS=${RUSTFLAGS} ${EXTRA_FLAGS}" >> "$GITHUB_ENV"
else
echo "RUSTFLAGS=${EXTRA_FLAGS}" >> "$GITHUB_ENV"
fi
- name: Install Task
uses: ./.github/actions/install-task
- name: Build FFI library
id: ffi
shell: bash
run: |
echo "=== Building FFI Library ==="
echo "Building kreuzberg-php from source (no caching)"
cargo build --release --package kreuzberg-php
- name: Build PHP extension
shell: bash
run: |
task php:build:ci
# Create PHP ini file for loading the extension
bash scripts/ci/php/create-ci-php-ini.sh
- name: Cleanup Rust cache
if: always()
uses: ./.github/actions/cleanup-rust-cache
test-php:
name: PHP Tests (${{ matrix.os }})
if: ${{ github.actor != 'dependabot[bot]' }}
needs: build-php-extension
timeout-minutes: 180
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:
RUSTC_WRAPPER: ""
steps:
- uses: actions/checkout@v4
- name: Install system dependencies
uses: ./.github/actions/install-system-deps
- name: Setup Rust
id: rust
uses: ./.github/actions/setup-rust
with:
cache-key-prefix: php-test-${{ matrix.os }}
- name: Detect partial cache hit and clean stale fingerprints
shell: bash
run: |
# Check if cache was a partial hit (restored from fallback key)
# For now, we'll do a more conservative check: always clean before build
# since the current Cargo.lock changes frequently
echo "Preparing clean Rust build environment..."
cargo clean --release -p kreuzberg-php 2>/dev/null || true
cargo clean --release -p kreuzberg 2>/dev/null || true
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.2"
extensions: ffi
tools: composer
- name: Install Composer dependencies
shell: bash
working-directory: packages/php
run: composer install --no-progress --prefer-dist
- 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: Export macOS PHP linker flags
if: matrix.os == 'macos-latest'
shell: bash
run: |
EXTRA_FLAGS="-C link-arg=-Wl,-undefined,dynamic_lookup"
if [ -n "${RUSTFLAGS:-}" ]; then
echo "RUSTFLAGS=${RUSTFLAGS} ${EXTRA_FLAGS}" >> "$GITHUB_ENV"
else
echo "RUSTFLAGS=${EXTRA_FLAGS}" >> "$GITHUB_ENV"
fi
- name: Build FFI library
id: ffi
shell: bash
run: |
echo "=== Building FFI Library ==="
echo "Building kreuzberg-php from source (no caching)"
cargo build --release --package kreuzberg-php
- name: Build PHP extension
shell: bash
run: task php:build:ci
- name: Run PHP tests
shell: bash
run: task php:test:ci
- name: Build kreuzberg CLI binary
shell: bash
run: cargo build --release --package kreuzberg-cli
- name: Run E2E tests
shell: bash
run: task php:e2e:test