Skip to content

Commit d518050

Browse files
committed
ci: 添加 GitHub Actions 工作流用于代码检查和测试
添加 lint.yml 和 test.yml 工作流文件,分别在代码提交和 PR 时自动运行代码检查和测试
1 parent cd9a6ed commit d518050

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

.github/workflows/lint.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Lint
2+
3+
# Controls when the action will run.
4+
on:
5+
# Triggers the workflow on pull request events but only for the main branch
6+
pull_request:
7+
branches: [main]
8+
push:
9+
branches: [main]
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
lint:
19+
runs-on: ubuntu-latest
20+
21+
# Steps represent a sequence of tasks that will be executed as part of the job
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v4
25+
26+
- name: Install Pnpm
27+
run: npm i -g corepack@latest --force && corepack enable
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: 22
33+
cache: "pnpm"
34+
35+
- name: Install Dependencies
36+
run: pnpm install
37+
38+
- name: Run Lint
39+
run: pnpm run lint

.github/workflows/test.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Test
2+
3+
# Controls when the action will run.
4+
on:
5+
# Triggers the workflow on pull request events but only for the main branch
6+
pull_request:
7+
branches: [main]
8+
push:
9+
branches: [main]
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
16+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
17+
jobs:
18+
test:
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
matrix:
22+
os: [ubuntu-latest, windows-latest]
23+
24+
# Steps represent a sequence of tasks that will be executed as part of the job
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Install Pnpm
30+
run: npm i -g corepack@latest --force && corepack enable
31+
32+
- name: Setup Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: 22
36+
cache: "pnpm"
37+
38+
- name: Install Dependencies
39+
run: pnpm install && npx playwright install chromium
40+
41+
- name: Run Test
42+
run: pnpm run test

0 commit comments

Comments
 (0)