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

## 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

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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Jack
2026-06-09 21:12:15 +08:00
committed by GitHub
parent 88e4d6bddb
commit 2f99d52fb5
28 changed files with 108 additions and 72 deletions

View File

@@ -141,24 +141,25 @@ jobs:
sudo docker rm -f -v "${BUILDER_CONTAINER}"
fi
# - name: Prepare test resources
# run: |
# RESOURCE_REPO=https://github.com/infiniflow/resource.git
# RESOURCE_REF=549feaaf998954d65b668667f009125bc84a9c5e
# rm -rf /tmp/resource
# git clone "${RESOURCE_REPO}" /tmp/resource
# git -C /tmp/resource checkout "${RESOURCE_REF}"
# sudo mkdir -p /usr/share/infinity
# sudo ln -sf /tmp/resource /usr/share/infinity/resource
# mkdir -p resource
# ln -sf /tmp/resource/wordnet resource/wordnet
#
# - name: Test Go packages
# run: |
# set -euo pipefail
# packages=$(go list ./internal/... | grep -vE '/storage(/|$)')
# CGO_ENABLED=1 GOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct} \
# go test -count=1 ${packages}
- name: Prepare test resources
run: |
RESOURCE_REPO=https://github.com/infiniflow/resource.git
RESOURCE_REF=549feaaf998954d65b668667f009125bc84a9c5e
RESOURCE_PATH="/tmp/resource-${GITHUB_RUN_ID}"
if [ -d "${RESOURCE_PATH}" ]; then rm -rf "${RESOURCE_PATH}"; fi
git clone "${RESOURCE_REPO}" "${RESOURCE_PATH}"
git -C "${RESOURCE_PATH}" checkout "${RESOURCE_REF}"
sudo mkdir -p /usr/share/infinity
sudo ln -sf "${RESOURCE_PATH}" /usr/share/infinity/resource
mkdir -p resource
ln -sf "${RESOURCE_PATH}/wordnet" resource/wordnet
- name: Test Go packages
run: |
set -euo pipefail
packages=$(go list ./internal/... | grep -vE '/storage(/|$)|/cli\b')
CGO_ENABLED=1 GOPROXY=${GOPROXY:-https://goproxy.cn,https://proxy.golang.org,direct} \
go test -count=1 ${packages}
- name: Build ragflow:nightly
run: |