Skip to content

Commit e33a58d

Browse files
authored
Merge branch 'dashscope:main' into main
2 parents 268a705 + 9f529ec commit e33a58d

197 files changed

Lines changed: 20250 additions & 11848 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## Description
2+
[Describe what this PR does and why]
3+
4+
**Related Issue:** Fixes #[issue_number] or Relates to #[issue_number]
5+
6+
**Security Considerations:** [Check if API keys or sensitive credentials are exposed in code/logs]
7+
8+
## Type of Change
9+
- [ ] Bug fix
10+
- [ ] New feature
11+
- [ ] Breaking change
12+
- [ ] Documentation
13+
- [ ] Refactoring
14+
15+
## Component(s) Affected
16+
- [ ] Model
17+
- [ ] Application
18+
- [ ] Common
19+
- [ ] Documentation
20+
- [ ] Tests
21+
- [ ] CI/CD
22+
23+
## Checklist
24+
- [ ] Pre-commit hooks pass
25+
- [ ] Tests pass locally
26+
- [ ] Documentation updated (if needed)
27+
- [ ] Ready for review
28+
29+
## Testing
30+
[How to test these changes]
31+
32+
## Additional Notes
33+
[Optional: any other context]

.github/workflows/pre-commit.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Pre-commit Checks
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
run:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: true
10+
env:
11+
OS: ubuntu-latest
12+
PYTHON: '3.8'
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Setup Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: '3.8'
19+
- name: Update setuptools and wheel
20+
run: |
21+
pip install setuptools==68.2.2 wheel==0.41.2
22+
- name: Install dashscope python sdk
23+
run: |
24+
pip install -r requirements.txt
25+
pip install -r requirements-test.txt
26+
- name: Install pre-commit hooks
27+
run: |
28+
pre-commit install
29+
- name: Run pre-commit
30+
run: |
31+
pre-commit run --all-files > pre-commit.log 2>&1 || true
32+
cat pre-commit.log
33+
if grep -q Failed pre-commit.log; then
34+
echo -e "\e[41m [**FAIL**] Please install pre-commit and format your code first. \e[0m"
35+
exit 1
36+
fi
37+
echo -e "\e[46m ********************************Passed******************************** \e[0m"

.github/workflows/unit_test.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Unit Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request:
8+
branches:
9+
- 'main'
10+
11+
jobs:
12+
test:
13+
if: ${{ !(github.event_name == 'pull_request' && startsWith(github.event.pull_request.title, 'docs:')) }}
14+
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ ubuntu-latest ]
19+
python-version: [ '3.8' ]
20+
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
31+
- name: Cache pip dependencies
32+
uses: actions/cache@v4
33+
with:
34+
path: ~/.cache/pip
35+
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
36+
restore-keys: |
37+
${{ runner.os }}-pip-
38+
39+
- name: Update setuptools
40+
run: |
41+
pip install --upgrade pip
42+
pip install setuptools==68.2.2 wheel==0.41.2
43+
44+
- name: Set PYTHONPATH
45+
run: |
46+
echo "PYTHONPATH=$PYTHONPATH:${{ github.workspace }}/src" >> $GITHUB_ENV
47+
48+
- name: Install dependencies
49+
run: |
50+
export PIP_DEFAULT_TIMEOUT=300
51+
pip install -r requirements.txt
52+
pip install -r requirements-test.txt
53+
54+
- name: Show installed pip packages (versions)
55+
run: |
56+
python -m pip list --format=columns
57+
58+
- name: Run tests with coverage
59+
run: |
60+
coverage run -m pytest tests/unit
61+
62+
- name: Generate coverage report
63+
run: |
64+
coverage report -m

.pre-commit-config.yaml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.3.0
4+
hooks:
5+
- id: check-ast
6+
exclude: ^(tests/legacy|samples)/
7+
- id: sort-simple-yaml
8+
exclude: ^(tests/legacy|samples)/
9+
- id: check-yaml
10+
exclude: |
11+
(?x)^(
12+
meta.yaml
13+
| tests/legacy/
14+
| samples/
15+
)$
16+
- id: check-xml
17+
exclude: ^(tests/legacy|samples)/
18+
- id: check-toml
19+
exclude: ^(tests/legacy|samples)/
20+
- id: check-docstring-first
21+
exclude: ^(tests/legacy|samples)/
22+
- id: check-json
23+
exclude: ^(tests/legacy|samples)/
24+
- id: fix-encoding-pragma
25+
exclude: ^(tests/legacy|samples)/
26+
- id: detect-private-key
27+
exclude: ^(tests/legacy|samples)/
28+
- id: trailing-whitespace
29+
exclude: ^(tests/legacy|samples)/
30+
- repo: https://github.com/asottile/add-trailing-comma
31+
rev: v3.1.0
32+
hooks:
33+
- id: add-trailing-comma
34+
exclude: ^(tests/legacy|samples)/
35+
- repo: https://github.com/pre-commit/mirrors-mypy
36+
rev: v1.7.0
37+
hooks:
38+
- id: mypy
39+
exclude:
40+
(?x)(
41+
pb2\.py$
42+
| grpc\.py$
43+
| ^docs
44+
| ^tests/legacy/
45+
| ^samples/
46+
| \.html$
47+
)
48+
args: [
49+
--ignore-missing-imports,
50+
--disable-error-code=var-annotated,
51+
--disable-error-code=union-attr,
52+
--disable-error-code=assignment,
53+
--disable-error-code=attr-defined,
54+
--disable-error-code=import-untyped,
55+
--disable-error-code=truthy-function,
56+
--follow-imports=skip,
57+
--explicit-package-bases,
58+
]
59+
- repo: https://github.com/psf/black
60+
rev: 23.3.0
61+
hooks:
62+
- id: black
63+
args: [ --line-length=79 ]
64+
exclude: ^(tests/legacy|samples)/
65+
- repo: https://github.com/PyCQA/flake8
66+
rev: 6.1.0
67+
hooks:
68+
- id: flake8
69+
args: [ "--extend-ignore=E203"]
70+
exclude: ^(tests/legacy|samples)/
71+
- repo: https://github.com/pylint-dev/pylint
72+
rev: v3.0.2
73+
hooks:
74+
- id: pylint
75+
exclude:
76+
(?x)(
77+
^docs
78+
| ^tests/legacy/
79+
| ^samples/
80+
| pb2\.py$
81+
| grpc\.py$
82+
| \.demo$
83+
| \.md$
84+
| \.html$
85+
)
86+
args: [
87+
--disable=W0511,
88+
--disable=W0718,
89+
--disable=W0122,
90+
--disable=C0103,
91+
--disable=R0913,
92+
--disable=E0401,
93+
--disable=E1101,
94+
--disable=C0415,
95+
--disable=W0603,
96+
--disable=R1705,
97+
--disable=R0914,
98+
--disable=E0601,
99+
--disable=W0602,
100+
--disable=W0604,
101+
--disable=R0801,
102+
--disable=R0902,
103+
--disable=R0903,
104+
--disable=C0123,
105+
--disable=W0231,
106+
--disable=W1113,
107+
--disable=W0221,
108+
--disable=R0401,
109+
--disable=W0632,
110+
--disable=W0123,
111+
--disable=C3001,
112+
--disable=W0201,
113+
--disable=C0302,
114+
--disable=W1203,
115+
--disable=C2801,
116+
--disable=C0114, # Disable missing module docstring for quick dev
117+
--disable=C0115, # Disable missing class docstring for quick dev
118+
--disable=C0116, # Disable missing function or method docstring for quick dev
119+
]
120+
- repo: https://github.com/pre-commit/mirrors-eslint
121+
rev: v7.32.0
122+
hooks:
123+
- id: eslint
124+
files: \.(js|jsx)$
125+
exclude: '(.*js_third_party.*|^tests/legacy/|^samples/)'
126+
args: [ '--fix' ]
127+
- repo: https://github.com/thibaudcolas/pre-commit-stylelint
128+
rev: v14.4.0
129+
hooks:
130+
- id: stylelint
131+
files: \.(css)$
132+
exclude: '(.*css_third_party.*|^tests/legacy/|^samples/)'
133+
args: [ '--fix' ]
134+
- repo: https://github.com/pre-commit/mirrors-prettier
135+
rev: 'v3.0.0'
136+
hooks:
137+
- id: prettier
138+
additional_dependencies: [ 'prettier@3.0.0' ]
139+
files: \.(tsx?)$
140+
exclude: ^(tests/legacy|samples)/

0 commit comments

Comments
 (0)