Skip to content

fix(ci): re-enable Go tests and fix compilation errors after ListModels signature change - #15862

Merged
yingfeng merged 2 commits into
infiniflow:mainfrom
xugangqiang:fix/ci-go-tests
Jun 9, 2026
Merged

yingfeng merged 2 commits into
infiniflow:mainfrom
xugangqiang:fix/ci-go-tests

Conversation

@xugangqiang

Copy link
Copy Markdown
Contributor

Summary

This PR re-enables the Go test steps in CI that were previously commented out, and fixes all compilation errors that have accumulated in internal/entity/models/ since the ListModels return type was changed from []string to []ListModelResponse.

Changes

CI (.github/workflows/tests.yml)

  • Re-enable Prepare test resources step (clones resource repo with WordNet data)
  • Re-enable Test Go packages step (runs go test ./internal/...)
  • Fix resource path race condition by using /tmp/resource-${GITHUB_RUN_ID} instead of /tmp/resource
  • Exclude /cli package from Go tests (contains main redeclarations)

Test fixes (16 model provider test files)

All errors were caused by the upstream change from []string to []ListModelResponse in the ListModels interface:

  • Add joinModelNames test helper to extract .Name from []ListModelResponse slices
  • strings.Join(models, ",") → joinModelNames(models, ",") (11 files)
  • ids[i] != "..." → ids[i].Name != "..." (cometapi, mistral)
  • got[i] != want[i] → got[i].Name != want[i] (bedrock)
  • []string return types → []ListModelResponse (google)

Pre-existing bugs in model_test.go

Bugs introduced by the upstream entity/ → entity/models/ directory rename:

  • Add missing pm := GetProviderManager() calls in 3 test functions
  • Fix InitProviderManager signature (_, err := → err :=)
  • Fix MaxTokens *int dereference (6 comparisons)
  • Fix readProviderConfig relative path (3 levels up instead of 2)

model.go

  • Add findRepoRoot() to make conf/all_models.json resolution work from any CWD, fixing TestSiliconFlowProviderConfigLoadsLatestProModels

Test validation

go build ./internal/...      # ✅
go test ./internal/entity/models/... -count=1  # ✅ all pass

🤖 Generated with Claude Code

- Re-enable Prepare test resources and Test Go packages steps in CI.
- Fix resource path race condition with GITHUB_RUN_ID.
- Exclude /cli package from Go tests.
- Fix ListModelResponse type mismatches in 16 model test files:
  strings.Join → joinModelNames helper, .Name field access,
  []string → []ListModelResponse return types.
- Fix pre-existing model_test.go issues: missing GetProviderManager()
  calls, InitProviderManager signature, MaxTokens *int dereference,
  and broken relative path in readProviderConfig.
- Add findRepoRoot() to make conf/all_models.json path resolution
  work from Go test CWD.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@xugangqiang xugangqiang added the ci Continue Integration label Jun 9, 2026
@xugangqiang
xugangqiang marked this pull request as ready for review June 9, 2026 13:00
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. 🧪 test Pull requests that update test cases. labels Jun 9, 2026
@coderabbitai

coderabbitai Bot commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d6351626-59c4-48b9-9d34-e15f61a5568a

📥 Commits

Reviewing files that changed from the base of the PR and between 88e4d6b and 6de4694.

📒 Files selected for processing (28)
  • .github/workflows/tests.yml
  • internal/entity/models/302ai_test.go
  • internal/entity/models/anthropic_test.go
  • internal/entity/models/astraflow_test.go
  • internal/entity/models/avian_test.go
  • internal/entity/models/bedrock_test.go
  • internal/entity/models/cometapi_test.go
  • internal/entity/models/google_test.go
  • internal/entity/models/gpustack_test.go
  • internal/entity/models/groq_test.go
  • internal/entity/models/hunyuan_test.go
  • internal/entity/models/jiekouai_test.go
  • internal/entity/models/longcat_test.go
  • internal/entity/models/minimax_test.go
  • internal/entity/models/mistral_test.go
  • internal/entity/models/model.go
  • internal/entity/models/model_test.go
  • internal/entity/models/modelscope_test.go
  • internal/entity/models/moonshot_test.go
  • internal/entity/models/perplexity_test.go
  • internal/entity/models/ppio_test.go
  • internal/entity/models/replicate_test.go
  • internal/entity/models/togetherai_test.go
  • internal/entity/models/tokenhub_test.go
  • internal/entity/models/tokenpony_test.go
  • internal/entity/models/volcengine_test.go
  • internal/entity/models/xai_test.go
  • internal/entity/models/xinference_test.go

📝 Walkthrough

Walkthrough

The PR refactors model provider tests to adapt to a ListModels API contract change. The workflow prepares external test resources and model.go implements repo-root-relative configuration loading. Test files are updated to assert against ListModelResponse objects using a unified joinModelNames() helper instead of comparing raw strings.

Changes

Model Provider Test Refactoring

Layer / File(s) Summary
CI test resources and repo-root config loading
.github/workflows/tests.yml, internal/entity/models/model.go
Workflow clones pinned external test resources into a run-scoped directory and excludes CLI packages from testing. model.go adds findRepoRoot() helper and updates InitProviderManager to load conf/all_models.json from repository root instead of current working directory.
Test helper and provider-manager assertion infrastructure
internal/entity/models/model_test.go
Introduces joinModelNames() helper to extract and join Name fields from ListModelResponse objects. Updates provider manager access patterns and revises MaxTokens assertions across PPIO and SiliconFlow tests to dereference pointer fields.
Google ListModels test contract migration
internal/entity/models/google_test.go
Migrates withGoogleListModelsStub helper and all dependent tests from []string stubs to []ListModelResponse stubs, updating assertions across API-key validation, successful listing, connection tests, base-URL checks, and pagination collection.
Provider list-model tests standardized on joinModelNames
internal/entity/models/{302ai,anthropic,astraflow,avian,gpustack,groq,hunyuan,jiekouai,longcat,minimax,modelscope,moonshot,perplexity,ppio,replicate,togetherai,tokenhub,tokenpony,volcengine,xai,xinference}_test.go
Provider test files uniformly switch list-model string comparisons from strings.Join() to joinModelNames(), enabling consistent Name-field-based assertions across 22 provider integrations.
Provider tests asserting ListModelResponse.Name field on structured results
internal/entity/models/{bedrock,cometapi,mistral}_test.go
Update assertions to access and compare ListModelResponse.Name fields instead of comparing raw response objects or incorrectly typed elements directly to strings.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • infiniflow/ragflow#15845: The main PR's updates to InitProviderManager and model-listing tests to assert against ListModelResponse are directly tied to this PR's contract change from []string to []ListModelResponse.
  • infiniflow/ragflow#15750: Both PRs modify .github/workflows/tests.yml to set up the pinned infiniflow/resource test assets and adjust Go package exclusion logic.
  • infiniflow/ragflow#15786: The model.go repo-root discovery for conf/all_models.json is directly related to this PR's changes that introduce and load the same model catalog.

Suggested labels

size:L

Suggested reviewers

  • Haruko386
  • yingfeng
  • yuzhichang
  • JinHai-CN

Poem

🐰 With bundle files and models bright,
joinModelNames makes tests align just right,
From root we search, through directories deep,
ListResponse's Name fields we now keep—
Twenty-five providers dance in step,
Structured assertions, no more regex checks yet! 🎯

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: re-enabling Go tests in CI and fixing compilation errors caused by the ListModels signature change.
Description check ✅ Passed The description provides a comprehensive summary of changes with clear sections for CI, test fixes, pre-existing bugs, and model.go updates. It explains the problem and includes validation results.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@xugangqiang
xugangqiang requested review from JinHai-CN and yingfeng June 9, 2026 13:05
@yingfeng
yingfeng merged commit 2f99d52 into infiniflow:main Jun 9, 2026
1 check passed
@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (64b860f) to head (6de4694).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15862   +/-   ##
=======================================
  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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:S This PR changes 10-29 lines, ignoring generated files. 🧪 test Pull requests that update test cases.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants