Repository navigation
🔒 全面加固跨世界 GM RPC、用户脚本、Sandbox 与 Agent 边界 #6236
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: test | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - release/* | |
| - develop/* | |
| pull_request: | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| name: Lint | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| - name: Setup pnpm | |
| env: | |
| COREPACK_ENABLE_DOWNLOAD_PROMPT: 0 | |
| run: | | |
| corepack enable | |
| corepack install | |
| pnpm --version | |
| - name: Get pnpm store path | |
| id: pnpm-store | |
| shell: bash | |
| run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT" | |
| - name: Cache pnpm store | |
| uses: actions/cache@v6 | |
| with: | |
| path: ${{ steps.pnpm-store.outputs.path }} | |
| key: ${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('package.json', 'pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ runner.arch }}-pnpm- | |
| - name: Install dependencies | |
| run: pnpm i --frozen-lockfile | |
| - name: Cache ESLint cache | |
| uses: actions/cache@v6 | |
| with: | |
| path: .eslintcache | |
| key: eslint-${{ hashFiles('pnpm-lock.yaml', '.eslintrc*') }} | |
| restore-keys: | | |
| eslint- | |
| - name: Lint | |
| run: pnpm lint:ci | |
| test-shards: | |
| runs-on: ubuntu-latest | |
| name: Run test shard (${{ matrix.shardIndex }}/${{ matrix.shardTotal }}) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| shardIndex: [1, 2] | |
| shardTotal: [2] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| - name: Setup pnpm | |
| env: | |
| COREPACK_ENABLE_DOWNLOAD_PROMPT: 0 | |
| run: | | |
| corepack enable | |
| corepack install | |
| pnpm --version | |
| - name: Get pnpm store path | |
| id: pnpm-store | |
| shell: bash | |
| run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT" | |
| - name: Cache pnpm store | |
| uses: actions/cache@v6 | |
| with: | |
| path: ${{ steps.pnpm-store.outputs.path }} | |
| key: ${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('package.json', 'pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ runner.arch }}-pnpm- | |
| - name: Install dependencies | |
| run: pnpm i --frozen-lockfile | |
| - name: Run test shard | |
| run: > | |
| pnpm exec vitest run | |
| --coverage | |
| --silent=passed-only | |
| --reporter=blob | |
| --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} | |
| - name: Upload blob report | |
| if: ${{ !cancelled() }} | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: vitest-report-${{ matrix.shardIndex }} | |
| path: .vitest-reports/* | |
| include-hidden-files: true | |
| retention-days: 1 | |
| tests: | |
| runs-on: ubuntu-latest | |
| name: Run tests | |
| needs: [lint, test-shards] | |
| if: ${{ !cancelled() }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| - name: Setup pnpm | |
| env: | |
| COREPACK_ENABLE_DOWNLOAD_PROMPT: 0 | |
| run: | | |
| corepack enable | |
| corepack install | |
| pnpm --version | |
| - name: Get pnpm store path | |
| id: pnpm-store | |
| shell: bash | |
| run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT" | |
| - name: Cache pnpm store | |
| uses: actions/cache@v6 | |
| with: | |
| path: ${{ steps.pnpm-store.outputs.path }} | |
| key: ${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('package.json', 'pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ runner.arch }}-pnpm- | |
| - name: Install dependencies | |
| run: pnpm i --frozen-lockfile | |
| - name: Download blob reports | |
| uses: actions/download-artifact@v6 | |
| with: | |
| pattern: vitest-report-* | |
| path: .vitest-reports | |
| merge-multiple: true | |
| - name: Merge test and coverage reports | |
| run: > | |
| pnpm exec vitest | |
| --merge-reports | |
| --coverage | |
| --silent=passed-only | |
| --reporter=default | |
| --reporter.default.summary=false | |
| - name: Verify prerequisite jobs | |
| if: ${{ always() && (needs.lint.result != 'success' || needs.test-shards.result != 'success') }} | |
| run: exit 1 | |
| - name: Upload coverage reports to Codecov with GitHub Action | |
| uses: codecov/codecov-action@v5 | |
| # 运行时启动链路一旦断掉,所有 E2E 都会等到超时才失败;先用单个用例在几秒内暴露,失败时不再启动 E2E 分片。 | |
| runtime-smoke: | |
| runs-on: ubuntu-latest | |
| name: Runtime smoke | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| - name: Setup pnpm | |
| env: | |
| COREPACK_ENABLE_DOWNLOAD_PROMPT: 0 | |
| run: | | |
| corepack enable | |
| corepack install | |
| pnpm --version | |
| - name: Get pnpm store path | |
| id: pnpm-store | |
| shell: bash | |
| run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT" | |
| - name: Cache pnpm store | |
| uses: actions/cache@v6 | |
| with: | |
| path: ${{ steps.pnpm-store.outputs.path }} | |
| key: ${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('package.json', 'pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ runner.arch }}-pnpm- | |
| - name: Install dependencies | |
| run: pnpm i --frozen-lockfile | |
| - name: Cache Playwright browsers | |
| id: playwright-cache | |
| uses: actions/cache@v6 | |
| with: | |
| path: ~/.cache/ms-playwright | |
| key: playwright-${{ hashFiles('pnpm-lock.yaml') }} | |
| restore-keys: | | |
| playwright- | |
| - name: Install Playwright Chromium | |
| if: steps.playwright-cache.outputs.cache-hit != 'true' | |
| run: pnpm test:e2e:install | |
| - name: Build extension | |
| run: pnpm build | |
| - name: Run runtime smoke | |
| run: pnpm run test:runtime-smoke | |
| - name: Upload test artifacts | |
| if: failure() | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: runtime-smoke-results | |
| path: | | |
| test-results/ | |
| playwright-report/ | |
| retention-days: 14 | |
| e2e: | |
| runs-on: ubuntu-latest | |
| name: Run E2E tests (${{ matrix.shardIndex }}/${{ matrix.shardTotal }}) | |
| needs: [lint, test-shards, runtime-smoke] | |
| if: ${{ needs.lint.result == 'success' && needs.test-shards.result == 'success' && needs.runtime-smoke.result == 'success' }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| shardIndex: [1, 2, 3, 4] | |
| shardTotal: [4] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| - name: Setup pnpm | |
| env: | |
| COREPACK_ENABLE_DOWNLOAD_PROMPT: 0 | |
| run: | | |
| corepack enable | |
| corepack install | |
| pnpm --version | |
| - name: Get pnpm store path | |
| id: pnpm-store | |
| shell: bash | |
| run: echo "path=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT" | |
| - name: Cache pnpm store | |
| uses: actions/cache@v6 | |
| with: | |
| path: ${{ steps.pnpm-store.outputs.path }} | |
| key: ${{ runner.os }}-${{ runner.arch }}-pnpm-${{ hashFiles('package.json', 'pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ runner.arch }}-pnpm- | |
| - name: Show runner CPU count | |
| run: nproc | |
| - name: Install dependencies | |
| run: pnpm i --frozen-lockfile | |
| - name: Cache Playwright browsers | |
| id: playwright-cache | |
| uses: actions/cache@v6 | |
| with: | |
| path: ~/.cache/ms-playwright | |
| key: playwright-${{ hashFiles('pnpm-lock.yaml') }} | |
| restore-keys: | | |
| playwright- | |
| - name: Install Playwright Chromium | |
| if: steps.playwright-cache.outputs.cache-hit != 'true' | |
| run: pnpm test:e2e:install | |
| - name: Build extension | |
| run: pnpm build | |
| - name: Run E2E tests | |
| run: pnpm exec playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} | |
| - name: Upload test artifacts | |
| if: failure() | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: e2e-test-results-${{ matrix.shardIndex }} | |
| path: | | |
| test-results/ | |
| playwright-report/ | |
| retention-days: 14 |