forked from opendatalab/WebMainBench
-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (109 loc) · 3.88 KB
/
test.yml
File metadata and controls
131 lines (109 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Tests
on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install --ignore-requires-python -r requirements.txt
pip install pytest pytest-cov pytest-xdist coverage
- name: Install optional dependencies (ignore failures)
run: |
# 尝试安装可选依赖,失败时继续
pip install requests || echo "requests installation failed, continuing..."
# llm_web_kit 可能不可用,所以允许失败
pip install llm_web_kit || echo "llm_web_kit not available, tests will skip related functionality"
continue-on-error: true
- name: Create test directories
run: |
mkdir -p data results
- name: Run tests
run: |
# 运行测试,生成覆盖率报告
python -m pytest tests/ -v --cov=webmainbench --cov-report=xml --cov-report=term-missing
- name: Test basic usage example
run: |
# 测试基本使用示例是否能正常运行
python examples/basic_usage.py
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3
# with:
# file: ./coverage.xml
# flags: unittests
# name: codecov-umbrella
# fail_ci_if_error: false
# lint:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Set up Python 3.10
# uses: actions/setup-python@v4
# with:
# python-version: '3.10'
# - name: Install lint dependencies
# run: |
# python -m pip install --upgrade pip
# pip install flake8 black isort mypy
# pip install -e .
# - name: Run flake8
# run: |
# # 检查代码风格,忽略一些常见的问题
# flake8 webmainbench/ --count --select=E9,F63,F7,F82 --show-source --statistics
# flake8 webmainbench/ --count --exit-zero --max-complexity=10 --max-line-length=88 --statistics
# - name: Check import sorting
# run: |
# isort --check-only --diff webmainbench/
# - name: Check code formatting
# run: |
# black --check --diff webmainbench/
# docs:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Set up Python 3.10
# uses: actions/setup-python@v4
# with:
# python-version: '3.10'
# - name: Install doc dependencies
# run: |
# python -m pip install --upgrade pip
# pip install -e .
# - name: Check README and documentation
# run: |
# # 验证README中的示例代码是否有效
# python -c "
# import webmainbench
# from webmainbench.data import DataLoader, BenchmarkDataset
# from webmainbench.evaluator import Evaluator
# from webmainbench.extractors import ExtractorFactory
# print('✅ 所有主要模块导入成功')
# "
# - name: Validate examples
# run: |
# # 检查examples目录下的所有Python文件语法
# python -m py_compile examples/*.py
# echo "✅ 所有示例文件语法正确"