Skip to content

Commit cdd8c98

Browse files
committed
chore: add formatting and CI checks
1 parent f82df7c commit cdd8c98

File tree

84 files changed

+7259
-3102
lines changed

Some content is hidden

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

84 files changed

+7259
-3102
lines changed

.github/CONTRIBUTING.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,13 @@ When you open a Pull Request, the CLA Assistant bot will automatically check if
6767
3. Install dependencies:
6868
```bash
6969
# Python dependencies
70-
uv sync
70+
uv sync --extra dev
7171

7272
# Extension dependencies
7373
cd extension && npm install && cd ..
74+
75+
# Install git hooks
76+
uv run pre-commit install
7477
```
7578

7679
## Development Setup
@@ -79,11 +82,14 @@ When you open a Pull Request, the CLA Assistant bot will automatically check if
7982

8083
```bash
8184
# Install with dev dependencies
82-
uv sync --group dev
85+
uv sync --extra dev
8386

8487
# Run the server
8588
uv run local-chrome-server serve
8689

90+
# Run pre-commit checks
91+
uv run pre-commit run --all-files
92+
8793
# Run tests
8894
uv run pytest
8995

@@ -105,8 +111,17 @@ npm run dev
105111
# Production build
106112
npm run build
107113

114+
# Format
115+
npm run format
116+
117+
# Lint
118+
npm run lint
119+
108120
# Type checking
109121
npm run typecheck
122+
123+
# Tests
124+
npm test
110125
```
111126

112127
## Pull Request Process
@@ -119,6 +134,7 @@ npm run typecheck
119134
2. **Make your changes** following our coding standards
120135

121136
3. **Test your changes**:
137+
- Run `uv run pre-commit run --all-files`
122138
- Run the test suite
123139
- Test manually if applicable
124140
- Check type errors
@@ -148,7 +164,7 @@ npm run typecheck
148164
- **Line length**: 88 characters (black/ruff)
149165
- **Target**: Python 3.12+
150166
- **Type hints**: Required (strict mypy)
151-
- **Formatting**: Use ruff for linting and formatting
167+
- **Formatting**: Use black for formatting and ruff for linting/import sorting
152168
- **Imports**: Sorted via ruff (isort compatible)
153169

154170
### TypeScript
@@ -157,6 +173,7 @@ npm run typecheck
157173
- **Strict mode**: Enabled
158174
- **Path alias**: Use `@/*` for `src/*`
159175
- **No type suppression**: Avoid `as any`, `@ts-ignore`, `@ts-expect-error`
176+
- **Formatting/Linting**: Use Prettier and ESLint before committing
160177

161178
### General
162179

@@ -172,4 +189,4 @@ npm run typecheck
172189

173190
---
174191

175-
Thank you for contributing to OpenBrowser!
192+
Thank you for contributing to OpenBrowser!

.github/workflows/ci.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
pre-commit:
11+
name: Pre-commit
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Check out code
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.12'
24+
25+
- name: Set up uv
26+
uses: astral-sh/setup-uv@v5
27+
28+
- name: Set up Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '22'
32+
cache: npm
33+
cache-dependency-path: extension/package-lock.json
34+
35+
- name: Install Python dependencies
36+
run: uv sync --extra dev
37+
38+
- name: Install extension dependencies
39+
working-directory: extension
40+
run: npm ci
41+
42+
- name: Run pre-commit
43+
shell: bash
44+
run: |
45+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
46+
base_sha="${{ github.event.pull_request.base.sha }}"
47+
else
48+
base_sha="${{ github.event.before }}"
49+
fi
50+
51+
if [[ -z "${base_sha}" || "${base_sha}" == "0000000000000000000000000000000000000000" ]]; then
52+
mapfile -t changed_files < <(git ls-files)
53+
else
54+
mapfile -t changed_files < <(git diff --name-only --diff-filter=ACMRTUXB "${base_sha}" "${{ github.sha }}")
55+
fi
56+
57+
if [[ ${#changed_files[@]} -eq 0 ]]; then
58+
echo "No changed files to check."
59+
exit 0
60+
fi
61+
62+
uv run pre-commit run --show-diff-on-failure --files "${changed_files[@]}"
63+
64+
pytest:
65+
name: Pytest
66+
runs-on: ubuntu-latest
67+
68+
steps:
69+
- name: Check out code
70+
uses: actions/checkout@v4
71+
72+
- name: Set up Python
73+
uses: actions/setup-python@v5
74+
with:
75+
python-version: '3.12'
76+
77+
- name: Set up uv
78+
uses: astral-sh/setup-uv@v5
79+
80+
- name: Install Python dependencies
81+
run: uv sync --extra dev
82+
83+
- name: Run pytest
84+
run: uv run pytest
85+
86+
extension:
87+
name: Extension Tests
88+
runs-on: ubuntu-latest
89+
90+
steps:
91+
- name: Check out code
92+
uses: actions/checkout@v4
93+
94+
- name: Set up Node.js
95+
uses: actions/setup-node@v4
96+
with:
97+
node-version: '22'
98+
cache: npm
99+
cache-dependency-path: extension/package-lock.json
100+
101+
- name: Set up Bun
102+
uses: oven-sh/setup-bun@v2
103+
with:
104+
bun-version: '1.3.11'
105+
106+
- name: Install extension dependencies
107+
working-directory: extension
108+
run: npm ci
109+
110+
- name: Run extension tests
111+
working-directory: extension
112+
run: npm test

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: check-toml
6+
files: ^pyproject\.toml$
7+
- id: check-yaml
8+
files: ^(\.pre-commit-config\.yaml|\.github/workflows/.*\.ya?ml)$
9+
10+
- repo: local
11+
hooks:
12+
- id: black
13+
name: black
14+
entry: uv run black
15+
language: system
16+
types_or: [python, pyi]
17+
require_serial: true
18+
19+
- id: extension-prettier
20+
name: extension prettier
21+
entry: npm --prefix extension exec prettier -- --write --ignore-unknown
22+
language: system
23+
files: ^extension/(?!package-lock\.json$).*\.(ts|tsx|js|mjs|cjs|json|html|css|md)$
24+
25+
- id: extension-eslint
26+
name: extension eslint
27+
entry: npm --prefix extension exec eslint -- --config extension/eslint.config.mjs --max-warnings=0
28+
language: system
29+
files: ^extension/.*\.ts$

0 commit comments

Comments
 (0)