Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .github/actions/ios-test-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@ outputs:
runs:
using: composite
steps:
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version-file: .nvmrc
cache: pnpm
- uses: ./.github/actions/setup-js
- shell: bash
run: |
pnpm install --frozen-lockfile
pnpm run convert
if ! command -v xcodegen >/dev/null 2>&1; then
brew install xcodegen
Expand Down
17 changes: 17 additions & 0 deletions .github/actions/setup-js/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Prepare JavaScript workspace
description: Install repository-pinned Node.js, pnpm and frozen workspace dependencies
inputs:
registry-url:
description: Optional npm registry configuration for jobs that also invoke npm
default: ''
runs:
using: composite
steps:
- uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7
with:
node-version-file: .nvmrc
cache: pnpm
registry-url: ${{ inputs.registry-url }}
- shell: bash
run: pnpm install --frozen-lockfile
66 changes: 14 additions & 52 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
core_key: ${{ steps.pr_core.outputs.key }}
core_run: ${{ steps.pr_core.outputs.run_id }}
skip_native: ${{ steps.changes.outputs.skip_native }}
skip_artifact: ${{ steps.changes.outputs.skip_artifact }}
ios_suites: ${{ steps.changes.outputs.ios_suites }}
ios_max_parallel: ${{ steps.changes.outputs.ios_max_parallel }}
ios_storekit_devices: ${{ steps.changes.outputs.ios_storekit_devices }}
Expand All @@ -53,7 +54,7 @@ jobs:
- name: Test isolated iOS infrastructure recovery
run: node --test test/iosTestInfrastructure.test.mjs test/iosStoreKitInfrastructure.test.mjs
- run: node --test test/iosCoreReuse.test.mjs
- name: Plan native CI coverage
- name: Plan CI coverage
id: changes
env:
GH_TOKEN: ${{ github.token }}
Expand All @@ -70,17 +71,7 @@ jobs:
steps:
- uses: actions/checkout@v7

- name: Install pnpm
uses: pnpm/action-setup@v6

- name: Set node
uses: actions/setup-node@v7
with:
node-version-file: .nvmrc
cache: pnpm

- name: Install
run: pnpm install --frozen-lockfile
- uses: ./.github/actions/setup-js

- name: Lint
run: pnpm run lint
Expand All @@ -90,17 +81,7 @@ jobs:
steps:
- uses: actions/checkout@v7

- name: Install pnpm
uses: pnpm/action-setup@v6

- name: Set node
uses: actions/setup-node@v7
with:
node-version-file: .nvmrc
cache: pnpm

- name: Install
run: pnpm install --frozen-lockfile
- uses: ./.github/actions/setup-js

- name: Convert CSV to JSON
run: pnpm run convert
Expand All @@ -114,12 +95,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v7
with:
node-version-file: .nvmrc
cache: pnpm
- run: pnpm install --frozen-lockfile
- uses: ./.github/actions/setup-js
- run: pnpm run build
- name: Build documentation
run: pnpm run docs:build
Expand All @@ -129,27 +105,20 @@ jobs:
node scripts/compose-product-site.mjs

test:
name: test (ubuntu-latest)
needs: changes
if: ${{ !cancelled() }}
permissions:
contents: read
actions: read
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
fail-fast: false
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
- name: Use repository Node.js version
uses: actions/setup-node@v7
- uses: ./.github/actions/setup-js
with:
node-version-file: .nvmrc
registry-url: https://registry.npmjs.org/
cache: pnpm

- run: pnpm install --frozen-lockfile
- run: pnpm run convert
- name: Verify managed AI services and trusted source contracts
run: |
Expand All @@ -167,10 +136,10 @@ jobs:
run: node --test --test-reporter=dot test/webBuildInfo.test.mjs test/productSiteBuild.test.mjs test/supportAgentHttp.test.mjs test/cookGithubChanges.test.mjs test/cookDeliverySync.test.mjs test/supportLedger.test.mjs test/supportArtifacts.test.mjs test/edgeoneRelease.test.mjs test/cookSupportRunner.test.mjs
- run: pnpm run test
- name: Install pinned artifact SDK for runtime contract verification
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && (needs.changes.result != 'success' || needs.changes.outputs.skip_artifact != 'true')
run: npm install --prefix "$RUNNER_TEMP/cook-artifact-contract" --ignore-scripts --no-audit --no-fund @actions/artifact@6.3.1 @azure/core-xml@1.6.0
- name: Verify finalized checkpoints with the real Actions artifact runtime
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && (needs.changes.result != 'success' || needs.changes.outputs.skip_artifact != 'true')
uses: actions/github-script@v9
env:
GH_TOKEN: ${{ github.token }}
Expand All @@ -187,7 +156,7 @@ jobs:
runs-on: ubuntu-latest
permissions: {}
steps:
- name: Require all Web jobs and every matrix entry to succeed
- name: Require all Web jobs to succeed
env:
RESULTS: ${{ toJSON(needs) }}
run: node -e 'if (Object.values(JSON.parse(process.env.RESULTS)).some(job => job.result !== "success")) process.exit(1)'
Expand All @@ -199,14 +168,7 @@ jobs:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
- name: Set node
uses: actions/setup-node@v7
with:
node-version-file: .nvmrc
cache: pnpm

- run: pnpm install --frozen-lockfile
- uses: ./.github/actions/setup-js
- run: pnpm run convert
- name: Import Swift release signing keys
run: gpg --batch --import .github/keys/swift-release-keys.asc
Expand Down
10 changes: 10 additions & 0 deletions docs/dev/ios-ci.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# iOS CI

## 2026-11-12 无关触发与重复配置精简

Node.js、pnpm、缓存和冻结依赖安装统一由 `.github/actions/setup-js` 定义,Web/Swift 任务和 iOS 环境共用;每个 runner 仍独立安装,Web build 继续从全新检出执行。去掉只有 Ubuntu 一项的 test 矩阵,保留 `test (ubuntu-latest)` 和现有汇总检查名称。

独立 Support 同步、账本、artifact 工具及已列出的测试不再触发模拟器/Swift;混入原生、共享协议、工程或未知输入仍按原计划执行。artifact 真实联网往返只对明确不相关的文档、浏览器 UI、原生 Swift/StoreKit/测试计划以及菜谱 CSV/JSON 免除;Support、artifact 脚本、依赖、CI 配置和未知文件仍执行。所有本地 artifact/账本单元测试始终运行。

两种免除都要求非空、完整的变更比较;push 还要求同分支精确前一提交的 CI 已成功,避免后续无关提交取消并掩盖前一项检查。比较失败、计划失败、手动运行均保留完整检查,fork PR 仍不访问需要权限的真实 artifact 运行时。原生核心/会员/full 的用例、StoreKit 断言、限时和结果复用条件不变。

[基线 PR CI](https://github.com/YunYouJun/cook/actions/runs/43047563706) 的 iPad 为 28.8 分钟、iPhone 17.1 分钟、StoreKit 15.7 分钟,Web 测试 1.4 分钟。这次主要减少无关修改的触发,不能据此宣称 iOS 功能改动自身会编译或执行得更快。

## 2026-11-08 原生检查启动开销

[PR #205 的成功 CI](https://github.com/YunYouJun/cook/actions/runs/42458399313) 中,iPhone core 任务耗时 18 分 04 秒,iPad core 耗时 22 分 35 秒,StoreKit 耗时 10 分 12 秒。日志显示原生构建同时编译 `arm64` 与 `x86_64`,但每台 runner 只使用宿主架构的模拟器;StoreKit 在服务已经运行时仍强制 `kickstart`,冷服务控制及等待可占数分钟。
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/support-delivery-automation.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ GitHub 中现有 `Production – cook` 部署记录来自 Vercel,不作为 Edg
node scripts/cook-support-sync.mjs --allow-initialize
```

GitHub 运行使用 Node action 获取官方 artifact 运行时;浏览器只在需要新的生产验收时安装,已验收版本的送达核对复用既有验收证明。CI 会用独立的合成加密数据执行真实 artifact 上传、下载与摘要验收,不访问 Support,不使用工单检查点命名空间。
GitHub 运行使用 Node action 获取官方 artifact 运行时;浏览器只在需要新的生产验收时安装,已验收版本的送达核对复用既有验收证明。CI 在 Support/artifact 工具、依赖、工作流或未知输入改变时,用独立的合成加密数据执行真实 artifact 上传、下载与摘要验收,不访问 Support,不使用工单检查点命名空间。明确无关的产品或文档改动可免除该联网步骤;本地账本与 artifact 测试始终执行。分类不可用或前一条 push 的 CI 未通过时保留联网检查,手动 CI 也执行该检查。

环境变量使用 `COOK_SUPPORT_AGENT_CONFIG`、`COOK_SUPPORT_BINDINGS_FILE` 指向仓库外 0600 JSON,`COOK_SUPPORT_STATE_DIR` 指向 0700 私密目录;另设置加密密钥、只读 GitHub token、EdgeOne token 和绝对路径 `COOK_PLAYWRIGHT_MODULE`。只有显式 `--apply` 才执行工单命令。不要在命令或公开日志中写入凭据值。

Expand Down
47 changes: 39 additions & 8 deletions scripts/ci-changes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,32 @@ function isWebOnly(path) {
|| webTestFiles.has(path)
}

// These standalone Support tools never generate native resources or contracts.
// Keep an explicit list so new automation inputs still get full coverage.
const supportOnlyFiles = new Set([
'.github/workflows/support-sync.yml',
'scripts/cook-support-sync.mjs',
'scripts/prepare-support-feedback.mjs',
'scripts/support-artifact-worker.mjs',
'scripts/test-support-artifact-runtime.mjs',
'scripts/lib/cook-support-runner.mjs',
'scripts/lib/support-agent-http.mjs',
'scripts/lib/support-artifacts.mjs',
'scripts/lib/support-ledger.mjs',
'test/cookSupportRunner.test.mjs',
'test/supportAgentHttp.test.mjs',
'test/supportArtifacts.test.mjs',
'test/supportLedger.test.mjs',
])

function needsNoArtifactRuntime(path) {
// The live contract uses synthetic ledger bytes, not App sources or recipes.
// Its scripts, dependencies, workflow and unknown inputs always run it.
return isDocumentation(path) || isWebOnly(path)
|| /^apps\/ios\/.+\.(?:swift|storekit|xctestplan)$/.test(path)
|| /^packages\/data\/.+\.(?:csv|json)$/.test(path)
}

function isMembershipInput(path) {
return /^apps\/ios\/(?:Cook\/(?:Model\/(?:NativeMembershipStoreKit|Membership\w*)|Views\/Membership\w*)|CookCore\/(?:Sources\/CookCore|Tests\/CookCoreTests)\/Membership\w*|Cook(?:UI)?Tests\/Membership\w*)\.swift$/.test(path)
|| path.startsWith('apps/ios/StoreKitValidation/')
Expand Down Expand Up @@ -125,15 +151,16 @@ export function detectNativeChanges(eventName, event, cwd = process.cwd()) {
})
const paths = diff.split('\0').filter(Boolean)
return {
skipNative: paths.length > 0 && paths.every(path => isDocumentation(path) || isWebOnly(path) || path === '.github/workflows/support-sync.yml'),
scope: paths.some(isMembershipInput) && paths.every(path => isMembershipInput(path) || isDocumentation(path) || isWebOnly(path)) ? 'membership' : 'core',
skipNative: paths.length > 0 && paths.every(path => isDocumentation(path) || isWebOnly(path) || supportOnlyFiles.has(path)),
skipArtifact: paths.length > 0 && paths.every(needsNoArtifactRuntime),
scope: paths.some(isMembershipInput) && paths.every(path => isMembershipInput(path) || isDocumentation(path) || isWebOnly(path) || supportOnlyFiles.has(path)) ? 'membership' : 'core',
changedFiles: paths.length,
comparison: `${base}${separator}${head}`,
}
}
catch {
// An unavailable base (including a force push/new branch) must never skip tests.
return { skipNative: false, changedFiles: null, comparison: 'unavailable' }
return { skipNative: false, skipArtifact: false, changedFiles: null, comparison: 'unavailable' }
}
}

Expand All @@ -144,8 +171,8 @@ function previousPushPassed(event) {

const branch = event.ref.slice('refs/heads/'.length)
try {
// A Web/docs/Support push can cancel the only run that covers the previous
// native change. Carry its coverage forward only from a successful push.
// A new push can cancel the only run that covers an earlier native or
// artifact change. Carry coverage forward only from a successful push.
const output = execFileSync('gh', [
'api',
`repos/${repo}/actions/workflows/ci.yml/runs`,
Expand Down Expand Up @@ -180,14 +207,18 @@ if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.ur
event = {}
}
const result = detectNativeChanges(process.env.GITHUB_EVENT_NAME, event)
if (result.skipNative && process.env.GITHUB_EVENT_NAME === 'push') {
if ((result.skipNative || result.skipArtifact) && process.env.GITHUB_EVENT_NAME === 'push') {
result.previousPushPassed = previousPushPassed(event)
result.skipNative = result.previousPushPassed
if (!result.previousPushPassed) {
result.skipNative = false
result.skipArtifact = false
}
}
const ios = planIosTests(process.env.GITHUB_EVENT_NAME, event?.inputs?.ios_coverage, result.scope)
if (process.env.GITHUB_OUTPUT) {
appendFileSync(process.env.GITHUB_OUTPUT, [
`skip_native=${result.skipNative}`,
`skip_artifact=${result.skipArtifact}`,
`ios_suites=${JSON.stringify(ios.suites)}`,
`ios_max_parallel=${ios.maxParallel}`,
`ios_storekit_devices=${JSON.stringify(ios.storekitDevices)}`,
Expand All @@ -196,7 +227,7 @@ if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.ur
}
if (process.env.GITHUB_STEP_SUMMARY) {
const reason = result.previousPushPassed === false ? ' Previous push did not have a verified successful CI run.' : ''
appendFileSync(process.env.GITHUB_STEP_SUMMARY, `Native CI: ${result.skipNative ? 'not required (only browser-owned inputs, documentation or the Support sync workflow changed)' : ios.suites.join(', ')}. StoreKit devices: ${ios.storekitDevices.join(', ')}.${reason} Changed paths: ${result.changedFiles ?? 'unknown'}. Comparison: ${result.comparison}.\n`)
appendFileSync(process.env.GITHUB_STEP_SUMMARY, `Native CI: ${result.skipNative ? 'not required (only browser-owned inputs, documentation or standalone Support tools changed)' : ios.suites.join(', ')}. StoreKit devices: ${ios.storekitDevices.join(', ')}. Live artifact contract: ${result.skipArtifact ? 'not required' : 'required'}.${reason} Changed paths: ${result.changedFiles ?? 'unknown'}. Comparison: ${result.comparison}.\n`)
}
console.log(JSON.stringify({ ...result, ios }))
}
Loading
Loading