feat: Optimize PR workflow with on-demand skill loading and project-l… #378
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 | |
| permissions: | |
| contents: read | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| - develop | |
| - v2 | |
| types: [ready_for_review, synchronize, opened, edited] | |
| jobs: | |
| ci: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| task: [basic-checks, general-test, render-test] | |
| env: | |
| CI: true | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.pull_request.draft == false | |
| steps: | |
| - name: Check out Git repository | |
| uses: actions/checkout@v6 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Get pnpm store directory | |
| id: pnpm-cache | |
| shell: bash | |
| run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT | |
| - name: Cache pnpm dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm- | |
| - name: Install Dependencies | |
| run: pnpm install | |
| - name: Lint Check | |
| if: matrix.task == 'basic-checks' | |
| run: pnpm test:lint | |
| - name: Format Check | |
| if: matrix.task == 'basic-checks' | |
| run: pnpm format:check | |
| - name: Type Check | |
| if: matrix.task == 'basic-checks' | |
| run: pnpm typecheck | |
| - name: i18n Check | |
| if: matrix.task == 'basic-checks' | |
| run: pnpm i18n:check | |
| - name: Hardcoded Strings Check | |
| if: matrix.task == 'basic-checks' | |
| run: pnpm i18n:hardcoded:strict | |
| - name: Skills Check | |
| if: matrix.task == 'basic-checks' | |
| run: pnpm skills:check | |
| - name: Main Process Test | |
| if: matrix.task == 'general-test' | |
| run: pnpm test:main | |
| - name: AI Core Test | |
| if: matrix.task == 'general-test' | |
| run: pnpm test:aicore | |
| - name: Shared Package Test | |
| if: matrix.task == 'general-test' | |
| run: pnpm test:shared | |
| - name: Scripts Test | |
| if: matrix.task == 'general-test' | |
| run: pnpm test:scripts | |
| - name: Renderer Test | |
| if: matrix.task == 'render-test' | |
| run: pnpm test:renderer | |
| skills-check-windows: | |
| runs-on: windows-latest | |
| env: | |
| CI: true | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.pull_request.draft == false | |
| steps: | |
| - name: Check out Git repository | |
| uses: actions/checkout@v6 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Get pnpm store directory | |
| id: pnpm-cache | |
| shell: bash | |
| run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT | |
| - name: Cache pnpm dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm- | |
| - name: Install Dependencies | |
| run: pnpm install | |
| - name: Skills Check | |
| run: pnpm skills:check | |
| notify: | |
| runs-on: ubuntu-latest | |
| needs: [ci, skills-check-windows] | |
| if: always() && (needs.ci.result == 'failure' || needs.skills-check-windows.result == 'failure') && github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Check out Git repository | |
| uses: actions/checkout@v6 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Get pnpm store directory | |
| id: pnpm-cache | |
| shell: bash | |
| run: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT | |
| - name: Cache pnpm dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm- | |
| - name: Install Dependencies | |
| run: pnpm install | |
| - name: Send failure notification to Feishu | |
| env: | |
| FEISHU_WEBHOOK_URL: ${{ secrets.FEISHU_WEBHOOK_URL }} | |
| FEISHU_WEBHOOK_SECRET: ${{ secrets.FEISHU_WEBHOOK_SECRET }} | |
| RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | |
| COMMIT_SHA: ${{ github.sha }} | |
| COMMIT_MSG: ${{ github.event.head_commit.message }} | |
| run: | | |
| DESCRIPTION=$(printf "**分支:** main\n\n**提交:** %.7s\n\n**信息:** %s\n\n**工作流:** [查看详情](%s)" "$COMMIT_SHA" "$COMMIT_MSG" "$RUN_URL") | |
| pnpm tsx scripts/feishu-notify.ts send \ | |
| -t "Main 分支 CI 失败" \ | |
| -d "$DESCRIPTION" \ | |
| -c "red" |