Skip to content

fix(build): validate platform build options at the CLI/MCP entry #2865

fix(build): validate platform build options at the CLI/MCP entry

fix(build): validate platform build options at the CLI/MCP entry #2865

Workflow file for this run

name: PR Test
on:
pull_request:
types: [opened, synchronize, reopened, edited]
issue_comment:
types: [created]
jobs:
check-changes:
# 检查是否有需要运行 pr-test 的文件变更
if: |
github.event_name == 'pull_request' ||
(github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, 'rerun pr test'))
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.filter.outputs.should_run }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request && format('refs/pull/{0}/head', github.event.issue.number) || github.ref }}
- name: Check changed files
id: filter
shell: bash
run: |
# 评论触发时始终运行
if [ "${{ github.event_name }}" = "issue_comment" ]; then
echo "should_run=true" >> "$GITHUB_OUTPUT"
exit 0
fi
BASE_REF="origin/${{ github.base_ref }}"
CHANGED_FILES=$(git diff --name-only "$BASE_REF"...HEAD)
# 仅 dts/snapshot 相关文件变更时跳过 pr-test
DTS_ONLY=true
while IFS= read -r file; do
case "$file" in
.github/workflows/check-dts.yml|\
.github/workflows/publish-dts.yml|\
packages/cocos-cli-types/*|\
packages/cocos-cli-types/**/*) ;;
*) DTS_ONLY=false; break ;;
esac
done <<< "$CHANGED_FILES"
if [ "$DTS_ONLY" = "true" ]; then
echo "Only dts-related files changed, skipping pr-test."
echo "should_run=false" >> "$GITHUB_OUTPUT"
else
echo "should_run=true" >> "$GITHUB_OUTPUT"
fi
pr-test:
needs: check-changes
if: needs.check-changes.outputs.should_run == 'true'
strategy:
matrix:
# Windows native build still uses the bundled CMake 3.24.3 and VS2022 generator.
os: [windows-2022, macos-latest]
runs-on: ${{matrix.os}}
# 抬高 Node 堆上限:E2E 会 spawn dist/cli.js 在 fixture 上编译整个引擎,默认 ~2GB 堆偏紧,
# macOS runner 上易 OOM(Ineffective mark-compacts near heap limit)。NODE_OPTIONS 会被
# 所有子进程(jest / 被 spawn 的 CLI)继承。
env:
NODE_OPTIONS: --max-old-space-size=8192
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
clean: false
persist-credentials: true
fetch-depth: 0
# 如果是评论触发,需要检出 PR 的代码
ref: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request && format('refs/pull/{0}/head', github.event.issue.number) || github.ref }}
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: '22.17.0'
- name: Setup configuration
id: setup-config
uses: ./.github/actions/setup-config
with:
feishu-webhook-url: ${{ secrets.FEISHU_WEBHOOK_URL }}
- name: Setup environment
uses: ./.github/actions/setup-env
env:
MINIMAL_DOWNLOAD_TOOLS: 'true'
- name: Type check
id: type-check
run: npx tsc -b
- name: Run unit tests
id: unit-tests
run: npm run test:quiet
# pull_request 与 issue_comment 的 PR 标题字段不同,取当前事件中存在的标题进行检测。
- name: Run AssetDB package tests
if: runner.os == 'Windows' && contains(github.event.pull_request.title || github.event.issue.title, 'asset-db')
run: npm run test:asset-db
- name: Run E2E tests
id: e2e-tests
uses: ./.github/actions/run-e2e-tests
with:
report-server-url: ${{ steps.setup-config.outputs.REPORT_SERVER_URL }}
# 如果是评论触发且包含 "rerun pr test:debug",则以 debug 模式运行 E2E
debug: ${{ github.event_name == 'issue_comment' && github.event.issue.pull_request && contains(github.event.comment.body, 'rerun pr test:debug') }}
- name: Check E2E coverage
id: coverage
uses: ./.github/actions/check-e2e-coverage
with:
report-server-url: ${{ steps.setup-config.outputs.REPORT_SERVER_URL }}