Skip to content

Commit 5a7c744

Browse files
authored
add ci action (#12)
* add ci action * pre-commit hook * format
1 parent 24881c7 commit 5a7c744

10 files changed

Lines changed: 590 additions & 46 deletions

File tree

.github/workflows/ci.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
typescript:
11+
name: TypeScript (Node ${{ matrix.node-version }})
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
node-version: [20, 22]
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Setup pnpm
22+
uses: pnpm/action-setup@v4
23+
with:
24+
version: 9
25+
26+
- name: Setup Node.js ${{ matrix.node-version }}
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: ${{ matrix.node-version }}
30+
cache: pnpm
31+
32+
- name: Install dependencies
33+
run: pnpm install
34+
35+
- name: Typecheck
36+
run: pnpm typecheck
37+
38+
- name: Format check
39+
run: pnpm format:check
40+
41+
- name: Install Playwright browsers
42+
run: pnpm exec playwright install --with-deps chromium
43+
44+
- name: Run tests
45+
run: pnpm test
46+
47+
rust:
48+
name: Rust (${{ matrix.os }} - ${{ matrix.target }})
49+
runs-on: ${{ matrix.os }}
50+
strategy:
51+
matrix:
52+
include:
53+
- os: ubuntu-latest
54+
target: x86_64-unknown-linux-gnu
55+
- os: macos-latest
56+
target: aarch64-apple-darwin
57+
- os: macos-latest
58+
target: x86_64-apple-darwin
59+
- os: windows-latest
60+
target: x86_64-pc-windows-msvc
61+
62+
steps:
63+
- name: Checkout repository
64+
uses: actions/checkout@v4
65+
66+
- name: Setup Rust toolchain
67+
uses: dtolnay/rust-toolchain@stable
68+
with:
69+
targets: ${{ matrix.target }}
70+
71+
- name: Cache Cargo dependencies
72+
uses: actions/cache@v4
73+
with:
74+
path: |
75+
~/.cargo/bin/
76+
~/.cargo/registry/index/
77+
~/.cargo/registry/cache/
78+
~/.cargo/git/db/
79+
cli/target/
80+
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('cli/Cargo.lock') }}
81+
restore-keys: |
82+
${{ runner.os }}-cargo-${{ matrix.target }}-
83+
84+
- name: Build release binary
85+
run: cargo build --release --manifest-path cli/Cargo.toml --target ${{ matrix.target }}

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pnpm lint-staged

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"agent-browser": "./bin/agent-browser"
1414
},
1515
"scripts": {
16+
"prepare": "husky",
1617
"build": "tsc",
1718
"build:native": "cargo build --release --manifest-path cli/Cargo.toml && node scripts/copy-native.js",
1819
"build:linux": "docker compose -f docker/docker-compose.yml run --rm build-linux",
@@ -52,10 +53,15 @@
5253
},
5354
"devDependencies": {
5455
"@types/node": "^20.10.0",
56+
"husky": "^9.1.7",
57+
"lint-staged": "^15.2.11",
5558
"playwright": "^1.57.0",
5659
"prettier": "^3.7.4",
5760
"tsx": "^4.6.0",
5861
"typescript": "^5.3.0",
5962
"vitest": "^4.0.16"
63+
},
64+
"lint-staged": {
65+
"src/**/*.ts": "prettier --write"
6066
}
6167
}

0 commit comments

Comments
 (0)