Skip to content

revert: roll back tests.yml CI changes from PR #16391 - #16505

Merged
yingfeng merged 2 commits into
infiniflow:mainfrom
xugangqiang:revert/16391-tests-ci-rollback
Jun 30, 2026
Merged

yingfeng merged 2 commits into
infiniflow:mainfrom
xugangqiang:revert/16391-tests-ci-rollback

Conversation

@xugangqiang

@xugangqiang xugangqiang commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two changes to make Go build & run independent of native libraries (office_oxide, pdfium, pdf_oxide).

1. Make native libraries optional (build.sh + Go source)

Problem: build.sh --go added -loffice_oxide / -lpdfium / -lpdf_oxide to global CGO_LDFLAGS, causing every cgo package to link against these .so files. The resulting binary had NEEDED entries for all three, making it fail at startup with "cannot open shared object file" on any machine without them.

Fix:

  • build.sh: split setup_cgo_env into a base variant (only -I and -L paths, no -l flags) and setup_cgo_env_pdf (pdfium/pdf_oxide, non-fatal, only for --test)
  • build.sh: make native lib checks non-fatal — warn instead of exit 1
  • build.sh --run: auto-set LD_LIBRARY_PATH for libraries that are present
  • 6 office parser CGo files: //go:build cgo → //go:build cgo \&\& office
  • office_parsers_no_cgo.go: //go:build !cgo → //go:build !cgo || !office
  • pdfium/pdfium.go: add explicit //go:build cgo guard

Result: ./build.sh --go succeeds without any native libs. The built binary has ZERO NEEDED entries for office_oxide/pdfium/pdf_oxide.

2. Roll back tests.yml CI changes from PR #16391

Revert 4 changes introduced to .github/workflows/tests.yml by PR #16391 in both ragflow_tests_infinity and ragflow_tests_elasticsearch jobs:

  • Remove uv sync from Build step (no longer needed — Go build doesn't require .venv)
  • Remove duplicate "Prepare Python test environment" step
  • Restore grep -v exclusions for pdfium/pdfoxide/pdf Go test packages
  • Move "Prepare Python test environment" back before "Prepare function test environment"

Verification

./build.sh --go                              # ✓ builds without native libs
ldd bin/ragflow_server | grep -E 'office_oxide|pdfium|pdf_oxide'  # ✓ no NEEDED entries
./bin/ragflow_server                          # ✓ starts without ld.so errors
go build ./internal/ingestion/parser/         # ✓ compiles with !office stubs

🤖 Generated with Claude Code

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 30, 2026
@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR moves Python test environment setup out of the Go build steps in two CI jobs, expands Go test package exclusions, rewrites build.sh CGO dependency handling, and tightens build tags for office and PDFium parser files.

Changes

CI Workflow Step Sequencing and Go Test Exclusions

Layer / File(s) Summary
CI job sequencing and test filters
.github/workflows/tests.yml
Moves uv sync and uv pip install -e sdk/python out of the Go build step into a later dedicated step in both jobs, and adds exclusions for internal/deepdoc/parser/pdf/pdfium, internal/deepdoc/parser/pdf/pdfoxide, and internal/deepdoc/parser/pdf to the Go unit test package list.
CGO dependency and runtime setup
build.sh
Makes office_oxide dependency checks non-fatal, rewrites setup_cgo_env to conditionally set include and search paths, adds setup_cgo_env_pdf for pdfium and pdf_oxide paths, and calls CGO setup before server start.
Parser build tag gating
internal/deepdoc/parser/pdf/pdfium/pdfium.go, internal/ingestion/parser/*.go
Adds a CGO-only build constraint to the PDFium wrapper and updates office parser files so they compile only when the office tag is present, with the non-CGO fallback also selected when office is absent.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • infiniflow/ragflow#15976: Directly related build.sh work around office_oxide dependency handling and CGO environment wiring.
  • infiniflow/ragflow#16130: Directly related .github/workflows/tests.yml changes to Python environment setup sequencing in CI.
  • infiniflow/ragflow#16241: Related Go CI/test flow and build.sh test execution plumbing, including CGO test setup.

Suggested labels

🐞 bug

🐇 I hopped through CI and found the path,
Python moved aside, then Go took its bath.
CGO paths now set with care,
Office and PDFium know when to pair.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title matches one real part of the changeset—the tests.yml revert—but it omits the broader build.sh and parser tag changes.
Description check ✅ Passed The description is clearly related to the changeset and summarizes both the native-library build changes and the tests.yml revert.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

- Remove uv sync from Build ragflow go server step
- Remove duplicate Prepare Python test environment step after Build step
- Restore grep -v exclusions for pdfium/pdfoxide/pdf Go packages
- Move Prepare Python test environment back before Prepare function test environment

These changes were introduced in PR infiniflow#16391 (oss parser go refactor)
and are no longer needed since the pdf Go packages must be excluded
from unit tests that lack required CGo build dependencies.
Co-Authored-By: Claude <[email protected]>
@xugangqiang
xugangqiang force-pushed the revert/16391-tests-ci-rollback branch from 6170aa0 to fa94f83 Compare June 30, 2026 12:10
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jun 30, 2026
@xugangqiang xugangqiang added the ci Continue Integration label Jun 30, 2026
…pdfium/pdf_oxide)

- build.sh: split setup_cgo_env into base (no -l flags) and pdf variant
- build.sh: remove global -loffice_oxide/-lpdfium/-lpdf_oxide from CGO_LDFLAGS
- build.sh: make native lib checks non-fatal (warn instead of exit/return 1)
- build.sh: only set -L paths when libs are present, skip otherwise
- build.sh: --run now sets LD_LIBRARY_PATH automatically
- ingestion/parser: add 'office' build tag to CGo parsers (cgo && office)
- ingestion/parser: stub compiles when !cgo || !office
- pdfium: add explicit //go:build cgo guard

Co-Authored-By: Claude <[email protected]>
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Jun 30, 2026
@xugangqiang
xugangqiang marked this pull request as draft June 30, 2026 13:21
@xugangqiang
xugangqiang marked this pull request as ready for review June 30, 2026 13:21

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@build.sh`:
- Around line 449-486: The PDF CGO setup was split out, but `build_go()` and
`run()` no longer get the `pdfium` and `pdf_oxide` library search paths and
runtime library path setup. Update the build/run flow so `setup_cgo_env_pdf()`
is also invoked from the code paths used by `build_go()` and `run()`, or
otherwise ensure those paths still export the `CGO_LDFLAGS` and
`LD_LIBRARY_PATH` values for `${PDFIUM_PREFIX}` and `${PDF_OXIDE_PREFIX}`. Keep
the fix centered around the existing `setup_cgo_env()`, `setup_cgo_env_pdf()`,
`build_go()`, and `run()` helpers.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f1c15eba-0a93-46b7-95b8-91dd5be51e96

📥 Commits

Reviewing files that changed from the base of the PR and between fa94f83 and 7bceff9.

📒 Files selected for processing (9)
  • build.sh
  • internal/deepdoc/parser/pdf/pdfium/pdfium.go
  • internal/ingestion/parser/doc_parser.go
  • internal/ingestion/parser/docx_parser.go
  • internal/ingestion/parser/office_parsers_no_cgo.go
  • internal/ingestion/parser/ppt_parser.go
  • internal/ingestion/parser/pptx_parser.go
  • internal/ingestion/parser/xls_parser.go
  • internal/ingestion/parser/xlsx_parser.go
✅ Files skipped from review due to trivial changes (2)
  • internal/ingestion/parser/office_parsers_no_cgo.go
  • internal/ingestion/parser/docx_parser.go

Comment thread build.sh
Comment on lines +449 to +486
# Configure CGO flags for native libraries.
# setup_cgo_env — base: -I and -L paths only, no -l flags (those live in
# each package's own #cgo LDFLAGS pragma). Safe to call even when native
# libs are absent — just skips the paths that don't exist.
# setup_cgo_env_pdf — pdfium / pdf_oxide -L paths. Non-fatal when libs
# are missing. Only called by run_go_tests.
setup_cgo_env() {
# ── office_oxide ──────────────────────────────────────────────────
check_office_oxide_deps
export CGO_CFLAGS="-I${OFFICE_OXIDE_PREFIX}/include/office_oxide_c${CGO_CFLAGS:+ $CGO_CFLAGS}"
export CGO_LDFLAGS="-L${OFFICE_OXIDE_PREFIX}/lib -loffice_oxide -Wl,-rpath,${OFFICE_OXIDE_PREFIX}/lib"
export LD_LIBRARY_PATH="${OFFICE_OXIDE_PREFIX}/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
# ── office_oxide (header + search path only, no -loffice_oxide) ───
if [ -f "${OFFICE_OXIDE_PREFIX}/include/office_oxide_c/office_oxide.h" ]; then
export CGO_CFLAGS="-I${OFFICE_OXIDE_PREFIX}/include/office_oxide_c${CGO_CFLAGS:+ $CGO_CFLAGS}"
fi
if [ -f "${OFFICE_OXIDE_PREFIX}/lib/liboffice_oxide.so" ] || [ -f "${OFFICE_OXIDE_PREFIX}/lib/liboffice_oxide.dylib" ]; then
export CGO_LDFLAGS="-L${OFFICE_OXIDE_PREFIX}/lib${CGO_LDFLAGS:+ $CGO_LDFLAGS}"
export LD_LIBRARY_PATH="${OFFICE_OXIDE_PREFIX}/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
fi

echo "CGO_CFLAGS: $CGO_CFLAGS"
echo "CGO_LDFLAGS: $CGO_LDFLAGS"
}

setup_cgo_env_pdf() {
# ── pdfium ────────────────────────────────────────────────────────
check_pdfium_deps || return 1
check_pdfium_deps || true
if [ -f "${PDFIUM_PREFIX}/libpdfium.so" ]; then
export CGO_LDFLAGS="$CGO_LDFLAGS -L${PDFIUM_PREFIX} -Wl,-rpath,${PDFIUM_PREFIX}"
export CGO_LDFLAGS="$CGO_LDFLAGS -L${PDFIUM_PREFIX}"
export LD_LIBRARY_PATH="${PDFIUM_PREFIX}:${LD_LIBRARY_PATH}"
fi

# ── pdf_oxide ─────────────────────────────────────────────────────
check_pdf_oxide_deps || return 1
check_pdf_oxide_deps || true
if [ -f "${PDF_OXIDE_PREFIX}/libpdf_oxide.so" ]; then
export CGO_LDFLAGS="$CGO_LDFLAGS -L${PDF_OXIDE_PREFIX} -lpdf_oxide -Wl,-rpath,${PDF_OXIDE_PREFIX}"
export CGO_LDFLAGS="$CGO_LDFLAGS -L${PDF_OXIDE_PREFIX}"
export LD_LIBRARY_PATH="${PDF_OXIDE_PREFIX}:${LD_LIBRARY_PATH}"
elif [ -f "${PDF_OXIDE_PREFIX}/libpdf_oxide.a" ]; then
export CGO_LDFLAGS="$CGO_LDFLAGS ${PDF_OXIDE_PREFIX}/libpdf_oxide.a"
fi

echo "CGO_CFLAGS: $CGO_CFLAGS"
echo "Exporting CGO_CFLAGS: $CGO_CFLAGS"
echo "CGO_LDFLAGS: $CGO_LDFLAGS"
echo "Exporting CGO_LDFLAGS: $CGO_LDFLAGS"
echo "CGO_LDFLAGS (with PDF): $CGO_LDFLAGS"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Restore PDF CGO setup on the build and run paths.

After this split, only run_go_tests() invokes setup_cgo_env_pdf(). build_go() and run() now miss the pdfium / pdf_oxide -L and LD_LIBRARY_PATH setup that setup_cgo_env() used to cover, so builds can fail to link and built binaries can fail to start on machines that rely on ${PDFIUM_PREFIX} / ${PDF_OXIDE_PREFIX} rather than system library paths.

Suggested fix
 build_go() {
     ...
     check_office_oxide_deps || true
     setup_cgo_env
+    setup_cgo_env_pdf
     ...
 }

 run() {
     ...
     setup_cgo_env
+    setup_cgo_env_pdf
     ...
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@build.sh` around lines 449 - 486, The PDF CGO setup was split out, but
`build_go()` and `run()` no longer get the `pdfium` and `pdf_oxide` library
search paths and runtime library path setup. Update the build/run flow so
`setup_cgo_env_pdf()` is also invoked from the code paths used by `build_go()`
and `run()`, or otherwise ensure those paths still export the `CGO_LDFLAGS` and
`LD_LIBRARY_PATH` values for `${PDFIUM_PREFIX}` and `${PDF_OXIDE_PREFIX}`. Keep
the fix centered around the existing `setup_cgo_env()`, `setup_cgo_env_pdf()`,
`build_go()`, and `run()` helpers.

@xugangqiang xugangqiang added ci Continue Integration and removed ci Continue Integration labels Jun 30, 2026
@yingfeng
yingfeng merged commit 8e1dc4f into infiniflow:main Jun 30, 2026
6 of 12 checks passed
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (3633d08) to head (7bceff9).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16505   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

xugangqiang added a commit to xugangqiang/ragflow that referenced this pull request Jun 30, 2026
These tests were excluded by PR infiniflow#16505 because the old .so-based build
required system-native libraries at test-compile time. With the switch
to static linking (.a + -fuse-ld=lld), these packages compile and pass
correctly.

Co-Authored-By: Claude <[email protected]>
xugangqiang added a commit to xugangqiang/ragflow that referenced this pull request Jul 1, 2026
…niflow#16505)

## Summary

Two changes to make Go build \& run independent of native libraries
(office_oxide, pdfium, pdf_oxide).

## 1. Make native libraries optional (build.sh + Go source)

## 2. Roll back tests.yml CI changes from PR infiniflow#16391
@xugangqiang
xugangqiang deleted the revert/16391-tests-ci-rollback branch July 1, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants