feat(miniapps/forge): 锻造小程序后端 API 集成 #313
Workflow file for this run
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: CI - PR Checks | |
| on: | |
| pull_request: | |
| workflow_dispatch: | |
| env: | |
| NODE_VERSION: '24' | |
| jobs: | |
| # ==================== Self-hosted 快速链路 ==================== | |
| ci-fast: | |
| if: vars.USE_SELF_HOSTED == 'true' | |
| runs-on: self-hosted | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Git checkout | |
| run: | | |
| if [ ! -d ".git" ]; then | |
| git clone --depth=1 https://github.com/${{ github.repository }}.git . | |
| fi | |
| git fetch origin ${{ github.event.pull_request.head.sha || github.sha }} --depth=1 | |
| git checkout ${{ github.event.pull_request.head.sha || github.sha }} | |
| - name: Detect changes | |
| id: changes | |
| run: | | |
| CODE_CHANGED=$(git diff --name-only origin/${{ github.base_ref || 'main' }}...HEAD | grep -E '^src/|^e2e/' || true) | |
| if [ -n "$CODE_CHANGED" ]; then | |
| echo "code=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "code=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Install & Run | |
| env: | |
| E2E_TEST_MNEMONIC: ${{ secrets.E2E_TEST_MNEMONIC }} | |
| run: | | |
| # Enable pipefail to capture turbo exit code through pipe | |
| set -o pipefail | |
| pnpm install --frozen-lockfile | |
| if [ "${{ steps.changes.outputs.code }}" == "true" ]; then | |
| # 运行所有测试:lint + 单元测试 + Storybook 组件测试 + E2E 测试 + 主题检查 | |
| TASKS="lint:run typecheck:run build i18n:run theme:run test:run test:storybook e2e:audit e2e:ci e2e:ci:mock e2e:ci:real" | |
| else | |
| TASKS="lint:run typecheck:run build i18n:run theme:run test:run test:storybook" | |
| fi | |
| # Run turbo and capture output, pipefail ensures we get turbo's exit code | |
| if ! pnpm turbo run $TASKS 2>&1 | tee turbo-output.log; then | |
| echo "" | |
| echo "========== TURBO FAILED ==========" | |
| grep -A 50 "error\|Error\|ERROR\|failed\|Failed\|FAILED" turbo-output.log || cat turbo-output.log | |
| exit 1 | |
| fi | |
| echo "All checks passed!" | |
| checks-fast: | |
| if: vars.USE_SELF_HOSTED == 'true' | |
| needs: ci-fast | |
| runs-on: self-hosted | |
| steps: | |
| - run: echo "CI fast passed" | |
| # ==================== GitHub-hosted 标准链路 ==================== | |
| ci-standard: | |
| if: vars.USE_SELF_HOSTED != 'true' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Detect changes | |
| id: changes | |
| uses: dorny/paths-filter@v3 | |
| with: | |
| filters: | | |
| code: | |
| - 'src/**' | |
| - 'e2e/**' | |
| - uses: oven-sh/setup-bun@v2 | |
| - uses: pnpm/action-setup@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Cache Playwright browsers | |
| if: steps.changes.outputs.code == 'true' | |
| id: playwright-cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/ms-playwright | |
| key: playwright-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }} | |
| - name: Install Playwright | |
| if: steps.changes.outputs.code == 'true' && steps.playwright-cache.outputs.cache-hit != 'true' | |
| run: pnpm exec playwright install --with-deps chromium | |
| - name: Install Playwright deps | |
| if: steps.changes.outputs.code == 'true' && steps.playwright-cache.outputs.cache-hit == 'true' | |
| run: pnpm exec playwright install-deps chromium | |
| - name: Run all checks | |
| env: | |
| E2E_TEST_MNEMONIC: ${{ secrets.E2E_TEST_MNEMONIC }} | |
| run: | | |
| if [ "${{ steps.changes.outputs.code }}" == "true" ]; then | |
| # 运行所有测试:lint + 单元测试 + Storybook 组件测试 + E2E 测试 + 主题检查 | |
| pnpm turbo run lint:run typecheck:run build i18n:run theme:run test:run test:storybook e2e:audit e2e:ci e2e:ci:mock e2e:ci:real | |
| else | |
| pnpm turbo run lint:run typecheck:run build i18n:run theme:run test:run test:storybook | |
| fi | |
| checks-standard: | |
| if: vars.USE_SELF_HOSTED != 'true' | |
| needs: ci-standard | |
| runs-on: ubuntu-latest | |
| steps: | |
| - run: echo "CI standard passed" | |
| # ==================== 聚合 Job(满足分支保护) ==================== | |
| checks: | |
| if: always() | |
| needs: [checks-fast, checks-standard] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check results | |
| run: | | |
| if [ "${{ needs.checks-fast.result }}" == "success" ] || [ "${{ needs.checks-standard.result }}" == "success" ]; then | |
| echo "CI passed via $( [ '${{ needs.checks-fast.result }}' == 'success' ] && echo 'fast path' || echo 'standard path' )" | |
| exit 0 | |
| fi | |
| echo "CI failed: fast=${{ needs.checks-fast.result }}, standard=${{ needs.checks-standard.result }}" | |
| exit 1 |