106 lines
2.1 KiB
Plaintext
106 lines
2.1 KiB
Plaintext
name: 单元测试
|
|
|
|
on:
|
|
push:
|
|
branches: [main, dev]
|
|
pull_request:
|
|
branches: [main, dev]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
matrix:
|
|
node-version: [20.x, 22.x]
|
|
|
|
steps:
|
|
- name: 检出代码
|
|
uses: actions/checkout@v4
|
|
|
|
- name: 安装 pnpm
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 8
|
|
|
|
- name: 设置 Node.js ${{ matrix.node-version }}
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
cache: "pnpm"
|
|
|
|
- name: 安装依赖
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: 运行测试
|
|
run: pnpm test:run
|
|
|
|
- name: 生成覆盖率报告
|
|
run: pnpm test:coverage
|
|
|
|
- name: 上传覆盖率报告
|
|
uses: codecov/codecov-action@v3
|
|
with:
|
|
files: ./coverage/coverage-final.json
|
|
flags: unittests
|
|
name: codecov-umbrella
|
|
|
|
- name: 检查覆盖率阈值
|
|
run: |
|
|
echo "检查测试覆盖率是否达到目标..."
|
|
# 可以在这里添加覆盖率阈值检查逻辑
|
|
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: 检出代码
|
|
uses: actions/checkout@v4
|
|
|
|
- name: 安装 pnpm
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 8
|
|
|
|
- name: 设置 Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20.x
|
|
cache: "pnpm"
|
|
|
|
- name: 安装依赖
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: 运行 ESLint
|
|
run: pnpm lint:eslint
|
|
|
|
- name: 运行 Prettier
|
|
run: pnpm lint:prettier
|
|
|
|
- name: 运行 Stylelint
|
|
run: pnpm lint:stylelint
|
|
|
|
type-check:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: 检出代码
|
|
uses: actions/checkout@v4
|
|
|
|
- name: 安装 pnpm
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 8
|
|
|
|
- name: 设置 Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20.x
|
|
cache: "pnpm"
|
|
|
|
- name: 安装依赖
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: 类型检查
|
|
run: pnpm type-check
|