Skip to content

Commit 30d86ef

Browse files
authored
Add pre commit (#26)
1 parent 2164371 commit 30d86ef

33 files changed

+559
-490
lines changed

.eslintrc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"parserOptions": {
7+
"ecmaVersion": 2021,
8+
"sourceType": "module",
9+
"ecmaFeatures": {
10+
"jsx": true
11+
}
12+
},
13+
"rules": {
14+
"semi": ["error", "always"],
15+
"quotes": ["error", "double"],
16+
"indent": ["error", 2],
17+
"linebreak-style": ["error", "unix"],
18+
"brace-style": ["error", "1tbs"],
19+
"curly": ["error", "all"],
20+
"no-eval": ["error"],
21+
"prefer-const": ["error"],
22+
"arrow-spacing": ["error", { "before": true, "after": true }]
23+
}
24+
}

.github/workflows/pre-commit.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,27 @@ jobs:
1313
OS: ${{ matrix.os }}
1414
PYTHON: '3.10'
1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717
- name: Setup Python
18-
uses: actions/setup-python@v3
18+
uses: actions/setup-python@v5
1919
with:
2020
python-version: '3.10'
21+
- name: Update setuptools and wheel
22+
run: |
23+
pip install setuptools==68.2.2 wheel==0.41.2
24+
- name: Install pre-commit
25+
run: |
26+
pip install pre-commit
27+
- name: Install pre-commit hooks
28+
run: |
29+
pre-commit install
30+
- name: Run pre-commit
31+
run: |
32+
pre-commit run --all-files > pre-commit.log 2>&1 || true
33+
cat pre-commit.log
34+
if grep -q Failed pre-commit.log; then
35+
echo -e "\e[41m [**FAIL**] Please install pre-commit and format your code first. \e[0m"
36+
exit 1
37+
fi
38+
echo -e "\e[46m ********************************Passed******************************** \e[0m"
2139

.github/workflows/test_agent_deep_research.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: deep_research_runtime_test
2-
on:
3-
schedule:
4-
- cron: '0 0 */3 * *'
5-
workflow_dispatch:
2+
on: [push, pull_request]
63

74
jobs:
85
test:
@@ -33,5 +30,7 @@ jobs:
3330
pip install pytest pytest-asyncio pytest-mock
3431
3532
- name: Run tests
33+
env:
34+
PYTHONPATH: ${{ github.workspace }}/deep_research/agent_deep_research
3635
run: |
3736
python -m pytest tests/agent_deep_research_test.py -v

.github/workflows/test_browser_agent_test.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: BrowserAgent Tests
22

3-
on:
4-
schedule:
5-
- cron: '0 0 */3 * *'
6-
workflow_dispatch:
3+
on: [push]
74

85
jobs:
96
test:
@@ -33,13 +30,14 @@ jobs:
3330

3431
- name: Install Dependencies
3532
run: |
36-
cd browser_agent/agent_browser
33+
cd browser_use/agent_browser
3734
python -m pip install --upgrade pip
3835
pip install pytest pytest-asyncio
3936
pip install -r requirements.txt
4037
4138
- name: Run Tests
4239
env:
40+
PYTHONPATH: ${{ github.workspace }}/browser_use/agent_browser
4341
DASHSCOPE_API_KEY: ${{ secrets.DASHSCOPE_API_KEY }}
4442
run: |
4543
# ✅ Ensure test-results directory exists

.github/workflows/test_browser_use_fullstack_runtime.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: browser_use_fullstack_runtime_test
2-
on:
3-
schedule:
4-
- cron: '0 0 */3 * *'
5-
workflow_dispatch:
2+
on: [push]
63

74
jobs:
85
test:
@@ -37,6 +34,7 @@ jobs:
3734
- name: Run tests
3835
env:
3936
DASHSCOPE_API_KEY: ${{ secrets.DASHSCOPE_API_KEY }}
37+
PYTHONPATH: ${{ github.workspace }}/browser_use/browser_use_fullstack_runtime/backend
4038
run: |
4139
# ✅ Use validated path from debug output
4240
python -m pytest tests/browser_use_fullstack_runtime_test.py -v

.github/workflows/test_conversational_agents_chatbot.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: Conversational Agents Chatbot Test
2-
on:
3-
schedule:
4-
- cron: '0 0 */3 * *'
5-
workflow_dispatch:
2+
on: [push]
63

74
jobs:
85
test:
@@ -30,6 +27,7 @@ jobs:
3027
3128
- name: Run tests
3229
env:
30+
PYTHONPATH: ${{ github.workspace }}/conversational_agents/chatbot
3331
DASHSCOPE_API_KEY: ${{ secrets.DASHSCOPE_API_KEY }}
3432
run: |
3533
# ✅ Use correct relative path

.github/workflows/test_conversational_agents_chatbot_fullstack_runtime_webserver.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: Flask API Runtime Test
2-
on:
3-
schedule:
4-
- cron: '0 0 */3 * *'
5-
workflow_dispatch:
2+
on: [push]
63

74
jobs:
85
test:
@@ -33,5 +30,7 @@ jobs:
3330
pip install pytest pytest-asyncio
3431
3532
- name: Run tests
33+
env:
34+
PYTHONPATH: ${{ github.workspace }}/conversational_agents/chatbot_fullstack_runtime
3635
run: |
3736
python -m pytest tests/conversational_agents_chatbot_fullstack_runtime_webserver_test.py -v

.github/workflows/test_evaluation.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
name: ACE Benchmark Evaluation Test
2-
on:
3-
schedule:
4-
- cron: '0 0 */3 * *'
5-
workflow_dispatch:
2+
on: [push]
63

74
jobs:
85
test:
@@ -33,6 +30,7 @@ jobs:
3330
3431
- name: Run tests
3532
env:
33+
PYTHONPATH: ${{ env.GITHUB_WORKSPACE }}/evaluation/ace_bench
3634
DASHSCOPE_API_KEY: ${{ secrets.DASHSCOPE_API_KEY }}
3735
run: |
3836
python -m pytest tests/evaluation_test.py -v

.github/workflows/test_game.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Run test_game.py
22

3-
on:
4-
schedule:
5-
- cron: '0 0 */3 * *'
6-
workflow_dispatch:
3+
on: [push]
74

85
jobs:
96
test:
@@ -21,7 +18,7 @@ jobs:
2118
- name: Set up Python
2219
uses: actions/setup-python@v4
2320
with:
24-
python-version: 3.10
21+
python-version: "3.10"
2522

2623
- name: Install dependencies
2724
run: |
@@ -32,7 +29,7 @@ jobs:
3229
- name: Run game_test.py
3330
env:
3431
DASHSCOPE_API_KEY: ${{ secrets.DASHSCOPE_API_KEY }}
35-
PYTHONPATH: ${{ env.GITHUB_WORKSPACE }}/games/game_werewolves
32+
PYTHONPATH: $GITHUB_WORKSPACE/games/game_werewolves
3633
run: |
3734
# ✅ Ensure correct working directory
38-
python -m pytest tests/game_test.py -v
35+
PYTHONPATH=$GITHUB_WORKSPACE/games/game_werewolves python -m pytest tests/game_test.py -v

.pre-commit-config.yaml

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

0 commit comments

Comments
 (0)