chore: updated and linted #444
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI Go | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - '.github/actions/**' | |
| - '.github/workflows/ci-go.yaml' | |
| - '.cargo/config.toml' | |
| - 'rust-toolchain.toml' | |
| - 'Cargo.toml' | |
| - 'Cargo.lock' | |
| - 'crates/kreuzberg/**' | |
| - 'crates/kreuzberg-ffi/**' | |
| - 'crates/kreuzberg-tesseract/**' | |
| - 'packages/go/v4/**' | |
| - 'e2e/go/**' | |
| - 'test_documents/**' | |
| - 'fixtures/**' | |
| - 'tools/e2e-generator/**' | |
| - 'packages/go/v4/go.mod' | |
| - 'packages/go/v4/go.sum' | |
| - 'scripts/ci/go/**' | |
| - 'scripts/ci/cache/**' | |
| - 'scripts/ci/actions/**' | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - '.github/actions/**' | |
| - '.github/workflows/ci-go.yaml' | |
| - '.cargo/config.toml' | |
| - 'rust-toolchain.toml' | |
| - 'Cargo.toml' | |
| - 'Cargo.lock' | |
| - 'crates/kreuzberg/**' | |
| - 'crates/kreuzberg-ffi/**' | |
| - 'crates/kreuzberg-tesseract/**' | |
| - 'packages/go/v4/**' | |
| - 'e2e/go/**' | |
| - 'test_documents/**' | |
| - 'fixtures/**' | |
| - 'tools/e2e-generator/**' | |
| - 'packages/go/v4/go.mod' | |
| - 'packages/go/v4/go.sum' | |
| - 'scripts/ci/go/**' | |
| - 'scripts/ci/cache/**' | |
| - 'scripts/ci/actions/**' | |
| concurrency: | |
| group: ci-go-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| BUILD_PROFILE: "ci" | |
| CARGO_TERM_COLOR: always | |
| CARGO_INCREMENTAL: 0 | |
| CARGO_PROFILE_DEV_DEBUG: 0 | |
| RUST_BACKTRACE: short | |
| RUST_MIN_STACK: 16777216 | |
| PDFIUM_VERSION: "7578" | |
| PDFIUM_STATIC_VERSION: "7442b" | |
| ORT_VERSION: "1.23.2" | |
| MACOSX_DEPLOYMENT_TARGET: "14.0" | |
| IS_CI: "true" | |
| jobs: | |
| build-go: | |
| name: Go Bindings (${{ 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: Configure Windows GNU toolchain env | |
| if: matrix.os == 'windows-latest' | |
| shell: bash | |
| run: scripts/ci/go/configure-windows-gnu-env.sh | |
| - name: Install system dependencies | |
| uses: ./.github/actions/install-system-deps | |
| - name: Debug build environment | |
| if: always() | |
| shell: bash | |
| run: scripts/ci/go/debug-build-environment.sh | |
| - name: Debug Windows environment | |
| if: always() && matrix.os == 'windows-latest' | |
| shell: pwsh | |
| run: scripts/ci/go/debug-windows-environment.ps1 | |
| - 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 Rust | |
| uses: ./.github/actions/setup-rust | |
| with: | |
| cache-key-prefix: ${{ matrix.os == 'windows-latest' && 'go-windows-gnu' || format('go-{0}', matrix.os) }} | |
| use-sccache: ${{ matrix.os != 'windows-latest' }} | |
| target: ${{ matrix.os == 'windows-latest' && 'x86_64-pc-windows-gnu' || '' }} | |
| toolchain: ${{ matrix.os == 'windows-latest' && 'stable-x86_64-pc-windows-gnu' || '' }} | |
| - name: Set GNU as default Rust toolchain (Windows only) | |
| if: matrix.os == 'windows-latest' | |
| shell: pwsh | |
| run: pwsh -File scripts/ci/go/set-gnu-toolchain-windows.ps1 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25' | |
| cache-dependency-path: packages/go/v4/go.sum | |
| - 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 MSYS2 MinGW toolchain (Windows only) | |
| if: matrix.os == 'windows-latest' | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: MINGW64 | |
| update: true | |
| install: >- | |
| mingw-w64-x86_64-gcc | |
| mingw-w64-x86_64-cmake | |
| mingw-w64-x86_64-pkg-config | |
| mingw-w64-x86_64-nasm | |
| mingw-w64-x86_64-zstd | |
| mingw-w64-x86_64-binutils | |
| - name: Verify MSYS2 toolchain and add to PATH (Windows only) | |
| if: matrix.os == 'windows-latest' | |
| shell: pwsh | |
| run: scripts/ci/go/setup-msys2-windows.ps1 | |
| - 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: Setup Go CGO environment | |
| uses: ./.github/actions/setup-go-cgo-env | |
| with: | |
| ffi-lib-dir: 'target/release' | |
| enable-rpath: 'true' | |
| - name: Verify FFI build artifacts | |
| if: always() | |
| shell: bash | |
| run: | | |
| echo "=== FFI Build Artifacts ===" | |
| echo "target/release/:" | |
| ls -lh target/release/libkreuzberg_ffi* 2>/dev/null || echo " (none found)" | |
| echo "" | |
| if [[ -d "target/x86_64-pc-windows-gnu/release" ]]; then | |
| echo "target/x86_64-pc-windows-gnu/release/:" | |
| ls -lh target/x86_64-pc-windows-gnu/release/libkreuzberg_ffi* 2>/dev/null || echo " (none found)" | |
| fi | |
| echo "" | |
| echo "pkg-config file:" | |
| ls -lh crates/kreuzberg-ffi/kreuzberg-ffi.pc 2>/dev/null || echo " (not found)" | |
| - name: Build Go bindings | |
| run: task go:build:ci | |
| env: | |
| CGO_ENABLED: ${{ env.CGO_ENABLED }} | |
| CGO_CFLAGS: ${{ env.CGO_CFLAGS }} | |
| CGO_LDFLAGS: ${{ env.CGO_LDFLAGS }} | |
| PKG_CONFIG_PATH: ${{ env.PKG_CONFIG_PATH }} | |
| - name: Upload FFI library | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: go-ffi-lib-${{ matrix.os }} | |
| path: | | |
| target/release/libkreuzberg_ffi.* | |
| target/x86_64-pc-windows-gnu/release/libkreuzberg_ffi.* | |
| retention-days: 7 | |
| - name: Cleanup Rust cache | |
| if: always() | |
| uses: ./.github/actions/cleanup-rust-cache | |
| test-go: | |
| name: Go Tests (${{ matrix.os }}) | |
| if: ${{ github.actor != 'dependabot[bot]' }} | |
| needs: build-go | |
| 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: Configure Windows GNU toolchain env | |
| if: matrix.os == 'windows-latest' | |
| shell: bash | |
| run: scripts/ci/go/configure-windows-gnu-env.sh | |
| - name: Install system dependencies | |
| uses: ./.github/actions/install-system-deps | |
| - name: Debug build environment (test job) | |
| if: always() | |
| shell: bash | |
| run: scripts/ci/go/debug-build-environment.sh | |
| - name: Debug Windows environment (test job) | |
| if: always() && runner.os == 'Windows' | |
| shell: pwsh | |
| run: scripts/ci/go/debug-windows-environment.ps1 | |
| - name: Setup OpenSSL | |
| uses: ./.github/actions/setup-openssl | |
| - name: Setup Rust | |
| uses: ./.github/actions/setup-rust | |
| with: | |
| cache-key-prefix: go-tests-${{ matrix.os }} | |
| use-sccache: ${{ matrix.os != 'windows-latest' }} | |
| target: ${{ matrix.os == 'windows-latest' && 'x86_64-pc-windows-gnu' || '' }} | |
| toolchain: ${{ matrix.os == 'windows-latest' && 'stable-x86_64-pc-windows-gnu' || '' }} | |
| - name: Set GNU as default Rust toolchain (Windows only) | |
| if: matrix.os == 'windows-latest' | |
| shell: pwsh | |
| run: pwsh -File scripts/ci/go/set-gnu-toolchain-windows.ps1 | |
| - name: Setup MSYS2 MinGW toolchain (Windows only) | |
| if: matrix.os == 'windows-latest' | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: MINGW64 | |
| update: true | |
| install: >- | |
| mingw-w64-x86_64-gcc | |
| mingw-w64-x86_64-cmake | |
| mingw-w64-x86_64-pkg-config | |
| mingw-w64-x86_64-nasm | |
| mingw-w64-x86_64-zstd | |
| mingw-w64-x86_64-binutils | |
| - name: Verify MSYS2 toolchain and add to PATH (Windows only) | |
| if: matrix.os == 'windows-latest' | |
| shell: pwsh | |
| run: scripts/ci/go/setup-msys2-windows.ps1 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.25" | |
| cache-dependency-path: packages/go/v4/go.sum | |
| - 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: Download FFI library | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: go-ffi-lib-${{ matrix.os }} | |
| path: ffi-download | |
| - name: Move FFI library to correct location | |
| shell: bash | |
| run: scripts/ci/go/move-downloaded-ffi-library.sh | |
| - name: Verify FFI library location and permissions | |
| shell: bash | |
| run: scripts/ci/go/verify-ffi-library.sh | |
| - name: Make FFI library executable (Unix) | |
| if: runner.os != 'Windows' | |
| run: scripts/ci/go/make-ffi-executable-unix.sh | |
| - name: Setup Tesseract Cache | |
| uses: ./.github/actions/setup-tesseract-cache | |
| with: | |
| label: ${{ runner.os }}-tesseract-${{ env.PDFIUM_VERSION }} | |
| enable-cache: 'true' | |
| - name: Setup Go CGO environment | |
| uses: ./.github/actions/setup-go-cgo-env | |
| env: | |
| KREUZBERG_GO_LINKER_VERBOSE: ${{ runner.os == 'Windows' && '1' || '' }} | |
| with: | |
| ffi-lib-dir: 'target/release' | |
| enable-rpath: 'true' | |
| - name: Set library paths for test execution | |
| shell: bash | |
| run: scripts/ci/go/export-library-paths-for-tests.sh | |
| - name: Verify CGO configuration | |
| shell: bash | |
| run: scripts/ci/go/verify-cgo-config.sh | |
| - name: Force Go buildmode=exe (Windows only) | |
| if: runner.os == 'Windows' | |
| shell: bash | |
| run: echo "GOFLAGS=-buildmode=exe" >> "$GITHUB_ENV" | |
| - name: Print CGO compilation flags | |
| if: always() | |
| shell: bash | |
| run: | | |
| echo "=== CGO Compilation Flags ===" | |
| echo "CGO_ENABLED: ${CGO_ENABLED:-<not set>}" | |
| echo "CGO_CFLAGS: ${CGO_CFLAGS:-<not set>}" | |
| echo "CGO_LDFLAGS: ${CGO_LDFLAGS:-<not set>}" | |
| echo "PKG_CONFIG_PATH: ${PKG_CONFIG_PATH:-<not set>}" | |
| echo "GOFLAGS: ${GOFLAGS:-<not set>}" | |
| echo "" | |
| echo "=== Library Paths ===" | |
| echo "LD_LIBRARY_PATH: ${LD_LIBRARY_PATH:-<not set>}" | |
| echo "DYLD_LIBRARY_PATH: ${DYLD_LIBRARY_PATH:-<not set>}" | |
| echo "PATH (first 1000 chars):" | |
| echo "${PATH:0:1000}..." | |
| - name: Install Task | |
| uses: ./.github/actions/install-task | |
| - name: Run Go tests | |
| run: task go:test:ci | |
| env: | |
| LD_LIBRARY_PATH: ${{ env.LD_LIBRARY_PATH }} | |
| DYLD_LIBRARY_PATH: ${{ env.DYLD_LIBRARY_PATH }} | |
| DYLD_FALLBACK_LIBRARY_PATH: ${{ env.DYLD_FALLBACK_LIBRARY_PATH }} | |
| PATH: ${{ env.PATH }} | |
| CGO_ENABLED: ${{ env.CGO_ENABLED }} | |
| CGO_CFLAGS: ${{ env.CGO_CFLAGS }} | |
| CGO_LDFLAGS: ${{ env.CGO_LDFLAGS }} | |
| PKG_CONFIG_PATH: ${{ env.PKG_CONFIG_PATH }} | |
| GO_TEST_FLAGS: ${{ runner.os == 'Windows' && '-ldflags=-linkmode=external -extldflags=-Wl,--verbose' || '' }} | |
| - name: Generate Go E2E tests | |
| run: task go:e2e:generate | |
| - name: Run E2E tests | |
| run: task go:e2e:test | |
| env: | |
| LD_LIBRARY_PATH: ${{ env.LD_LIBRARY_PATH }} | |
| DYLD_LIBRARY_PATH: ${{ env.DYLD_LIBRARY_PATH }} | |
| DYLD_FALLBACK_LIBRARY_PATH: ${{ env.DYLD_FALLBACK_LIBRARY_PATH }} | |
| PATH: ${{ env.PATH }} | |
| CGO_ENABLED: ${{ env.CGO_ENABLED }} | |
| CGO_CFLAGS: ${{ env.CGO_CFLAGS }} | |
| CGO_LDFLAGS: ${{ env.CGO_LDFLAGS }} | |
| PKG_CONFIG_PATH: ${{ env.PKG_CONFIG_PATH }} |