Skip to content

Commit c00dff1

Browse files
authored
fix: stabilize backend ci dependency install (#835)
* fix: stabilize backend ci dependency install * fix: split backend gate workflow phases * fix: retry backend ci dependency install * fix: install litellm from github source
1 parent 6a070eb commit c00dff1

4 files changed

Lines changed: 82 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,31 @@ jobs:
5050
with:
5151
python-version: '3.11'
5252
cache: 'pip'
53+
cache-dependency-path: |
54+
requirements.txt
55+
requirements-ci.txt
5356
- name: 📦 Install dependencies
5457
run: |
55-
pip install --upgrade pip
56-
pip install -r requirements.txt
57-
pip install flake8 pytest
58-
- name: ✅ Run backend gate
59-
run: ./scripts/ci_gate.sh
58+
python -m pip install --upgrade pip
59+
for attempt in 1 2 3; do
60+
if python -m pip install -r requirements-ci.txt; then
61+
break
62+
fi
63+
if [ "$attempt" -eq 3 ]; then
64+
echo "Dependency install failed after ${attempt} attempts." >&2
65+
exit 1
66+
fi
67+
echo "Dependency install attempt ${attempt} failed, retrying in 15s..." >&2
68+
sleep 15
69+
done
70+
- name: ✅ Python syntax check
71+
run: ./scripts/ci_gate.sh syntax
72+
- name: ✅ Flake8 critical checks
73+
run: ./scripts/ci_gate.sh flake8
74+
- name: ✅ Local deterministic checks
75+
run: ./scripts/ci_gate.sh deterministic
76+
- name: ✅ Offline test suite
77+
run: ./scripts/ci_gate.sh offline-tests
6078

6179
docker-build:
6280
name: docker-build

requirements-ci.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Backend CI dependencies.
2+
-r requirements.txt
3+
4+
# Test and lint tooling used by backend-gate.
5+
flake8
6+
pytest

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ numpy>=1.24.0 # 数值计算
2929
json-repair>=0.55.1 # JSON 修复
3030

3131
# AI 分析
32-
litellm>=1.80.10 # Unified LLM client (Gemini/Anthropic/OpenAI/DeepSeek etc.)
32+
# PyPI project was quarantined on 2026-03-24; install from the upstream GitHub stable tag for now.
33+
litellm @ https://github.com/BerriAI/litellm/archive/refs/tags/v1.82.3-stable.patch.2.tar.gz # Unified LLM client (Gemini/Anthropic/OpenAI/DeepSeek etc.)
3334
tiktoken>=0.8.0,<0.12.0 # BPE tokenizer for LLM token counting (pin <0.12 to avoid plugin registration issues, #537)
3435
openai>=1.0.0 # OpenAI SDK (transitive dependency of litellm, kept explicit)
3536
PyYAML>=6.0 # YAML parser for LITELLM_CONFIG support

scripts/ci_gate.sh

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,58 @@
22

33
set -euo pipefail
44

5-
echo "==> backend-gate: Python syntax check"
6-
python -m py_compile main.py src/config.py src/auth.py src/analyzer.py src/notification.py
7-
python -m py_compile src/storage.py src/scheduler.py src/search_service.py
8-
python -m py_compile src/market_analyzer.py src/stock_analyzer.py
9-
python -m py_compile data_provider/*.py
5+
syntax_check() {
6+
echo "==> backend-gate: Python syntax check"
7+
python -m py_compile main.py src/config.py src/auth.py src/analyzer.py src/notification.py
8+
python -m py_compile src/storage.py src/scheduler.py src/search_service.py
9+
python -m py_compile src/market_analyzer.py src/stock_analyzer.py
10+
python -m py_compile data_provider/*.py
11+
}
1012

11-
echo "==> backend-gate: flake8 critical checks"
12-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
13+
flake8_checks() {
14+
echo "==> backend-gate: flake8 critical checks"
15+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
16+
}
1317

14-
echo "==> backend-gate: local deterministic checks"
15-
./test.sh code
16-
./test.sh yfinance
18+
deterministic_checks() {
19+
echo "==> backend-gate: local deterministic checks"
20+
./test.sh code
21+
./test.sh yfinance
22+
}
1723

18-
echo "==> backend-gate: offline test suite"
19-
python -m pytest -m "not network"
24+
offline_test_suite() {
25+
echo "==> backend-gate: offline test suite"
26+
python -m pytest -m "not network"
27+
}
2028

21-
echo "==> backend-gate: all checks passed"
29+
run_all() {
30+
syntax_check
31+
flake8_checks
32+
deterministic_checks
33+
offline_test_suite
34+
echo "==> backend-gate: all checks passed"
35+
}
36+
37+
phase="${1:-all}"
38+
39+
case "$phase" in
40+
all)
41+
run_all
42+
;;
43+
syntax)
44+
syntax_check
45+
;;
46+
flake8)
47+
flake8_checks
48+
;;
49+
deterministic)
50+
deterministic_checks
51+
;;
52+
offline-tests)
53+
offline_test_suite
54+
;;
55+
*)
56+
echo "Usage: $0 [all|syntax|flake8|deterministic|offline-tests]" >&2
57+
exit 2
58+
;;
59+
esac

0 commit comments

Comments
 (0)