name: Tests

on:
  push:
    branches: [ main, dev ]
  pull_request:
    branches: [ main, dev ]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Use Node.js
      uses: actions/setup-node@v3
      with:
        node-version: '19'
    - name: Install pnpm
      uses: pnpm/action-setup@v2
      with:
        version: 9.9.0  # 使用与本地相同的版本
    - name: Check pnpm version
      run: pnpm --version
    - name: Install dependencies
      run: pnpm install --frozen-lockfile
    - name: Run tests
      run: pnpm test -- --coverage
    - name: Upload results to Codecov
      uses: codecov/codecov-action@v4
      with:
        token: ${{ secrets.CODECOV_TOKEN }}