Skip to content

release: v1.0.16

release: v1.0.16 #890

Workflow file for this run

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: |
COMMIT="${{ github.event.pull_request.head.sha || github.sha }}"
EXCLUDES="-e .turbo -e '**/.turbo' -e node_modules -e '**/node_modules' -e 'packages/*/dist' -e 'miniapps/*/dist'"
if [ ! -d ".git" ]; then
git clone --depth=1 https://github.com/${{ github.repository }}.git .
git fetch origin $COMMIT --depth=1
git checkout -f $COMMIT
else
git fetch origin $COMMIT --depth=1
git checkout -f $COMMIT
eval "git clean -fdx $EXCLUDES"
fi
- name: Detect changes
id: changes
run: |
CODE_CHANGED=$(git diff --name-only origin/${{ github.base_ref || 'main' }}...HEAD | grep -E '^src/|^e2e/|^packages/|^miniapps/' || 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
# 运行静态检查
pnpm i18n:run
pnpm turbo run lint:run typecheck:run build i18n:run theme:run test:run test:storybook e2e:audit
# 使用 e2e:runner 分片运行 E2E 测试,避免单次全部运行
pnpm e2e:runner --all --mock -j 2
pnpm e2e:runner --all -j 2
pnpm e2e:ci:real
else
pnpm i18n:run
pnpm turbo run lint:run typecheck:run build i18n:run theme:run test:run test:storybook
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: always() && (vars.USE_SELF_HOSTED != 'true' || needs.ci-fast.result != 'success')
needs: [ci-fast]
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/**'
- 'packages/**'
- 'miniapps/**'
- 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
id: playwright-cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
- name: Install Playwright deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: pnpm exec playwright install --with-deps chromium webkit
- name: Ensure Playwright browsers
run: pnpm exec playwright install chromium webkit chromium-headless-shell
- name: Run all checks
env:
E2E_TEST_MNEMONIC: ${{ secrets.E2E_TEST_MNEMONIC }}
run: |
if [ "${{ steps.changes.outputs.code }}" == "true" ]; then
# 运行所有测试:lint + 单元测试 + Storybook 组件测试 + E2E 测试 + 主题检查
pnpm i18n:run
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 i18n:run
pnpm turbo run lint:run typecheck:run build i18n:run theme:run test:run test:storybook
fi
checks-standard:
if: always() && needs.ci-standard.result == 'success'
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