Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(ios): explain release gate status on pull requests (#8117)
Peter Chinmanb79d0f2ba9fa
diff --git a/.github/workflows/web-app-check-main.yml b/.github/workflows/web-app-check-main.ymlindex dc480a699e..ad123bfa08 100644--- a/.github/workflows/web-app-check-main.yml+++ b/.github/workflows/web-app-check-main.yml@@ -501,9 +501,10 @@ jobs:runs-on: namespace-profile-linux-tiny-no-cachepermissions:contents: read- pull-requests: read+ pull-requests: writesteps:- - name: Checkout Repo+ - id: checkout+ name: Checkout Repouses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10- id: native-filtername: Detect native iOS changes@@ -559,18 +560,21 @@ jobs:GH_TOKEN: ${{ github.token }}GH_REPO: ${{ github.repository }}PR_NUMBER: ${{ github.event.pull_request.number }}- - name: Setup Bun+ - id: bun+ name: Setup Bunif: (steps.native-filter.outputs.ios_native == 'true' || steps.cache-wasm.outputs.bumped == 'true') && steps.labels.outputs.skip != 'true'uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6with:bun-version: '1.3.13'- - name: Verify iOS release numbers were bumped+ - id: bump+ name: Verify iOS release numbers were bumpedif: (steps.native-filter.outputs.ios_native == 'true' || steps.cache-wasm.outputs.bumped == 'true') && steps.labels.outputs.skip != 'true'run: bun scripts/ios-verify-native-bump.mjsenv:BASE_REF: ${{ steps.cache-wasm.outputs.base_sha }}working-directory: apps/web- - name: Fetch App Store Connect credentials from Doppler+ - id: credentials+ name: Fetch App Store Connect credentials from Dopplerif: (steps.native-filter.outputs.ios_native == 'true' || steps.cache-wasm.outputs.bumped == 'true') && steps.labels.outputs.skip != 'true'run: |set -euo pipefail@@ -635,7 +639,8 @@ jobs:shell: bashenv:DOPPLER_TOKEN: ${{ secrets.IOS_RELEASE_DOPPLER_TOKEN }}- - name: Require the App Store release to be live+ - id: live+ name: Require the App Store release to be liveif: (steps.native-filter.outputs.ios_native == 'true' || steps.cache-wasm.outputs.bumped == 'true') && steps.labels.outputs.skip != 'true'run: |# --- native tree ------------------------------------------------------------@@ -738,6 +743,99 @@ jobs:- name: Skipped via labelif: (steps.native-filter.outputs.ios_native == 'true' || steps.cache-wasm.outputs.bumped == 'true') && steps.labels.outputs.skip == 'true'run: echo "Native iOS changes detected, but the skip-ios-update label says they don't break the native/web contract — skipping the App Store release gate."+ - name: Update iOS gate status on the PR+ if: '!cancelled() && github.event.pull_request.head.repo.full_name == github.repository'+ uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b+ with:+ script: |+ const marker = '<!-- ios-native-check-status -->';+ const steps = JSON.parse(process.env.IOS_GATE_STEPS);+ const { owner, repo } = context.repo;+ const issue_number = context.issue.number;+ const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: issue_number });+ // A rerun uses the original event. Never replace the current head's status+ // with an older commit's result, or create comments after the PR has closed.+ if (pr.state !== 'open' || pr.head.sha !== context.payload.pull_request.head.sha) return;++ const comments = await github.paginate(github.rest.issues.listComments, {+ owner, repo, issue_number, per_page: 100,+ });+ const existing = comments.find((comment) =>+ comment.user?.login === 'github-actions[bot]' && comment.body?.startsWith(marker));+ const native = steps['native-filter']?.outputs?.ios_native === 'true'+ || steps['cache-wasm']?.outputs?.bumped === 'true';+ const detectionComplete = steps['native-filter']?.outcome === 'success'+ && steps['cache-wasm']?.outcome === 'success';+ const failed = Object.entries(steps).filter(([, step]) => step.outcome === 'failure');+ if (!native && failed.length === 0 && !existing) return;++ const runUrl = `${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}/attempts/${process.env.GITHUB_RUN_ATTEMPT ?? "1"}`;+ const guideUrl = `${context.serverUrl}/${owner}/${repo}/blob/${pr.head.sha}/apps/web/docs/ios-releases.md`;+ const release = steps.live?.outputs?.gate_result+ ? JSON.parse(steps.live.outputs.gate_result) : null;+ const labels = pr.labels.map((label) => label.name);+ const lines = [marker];+ if (failed.length && !release) {+ const names = {+ checkout: 'Checkout Repo',+ bun: 'Setup Bun',+ 'native-filter': 'Detect native iOS changes',+ 'cache-wasm': 'Detect a client cache wasm version bump',+ labels: "Read the PR's labels",+ bump: 'Verify iOS release numbers were bumped',+ credentials: 'Fetch App Store Connect credentials',+ live: 'Fetch the merge result and check App Store status',+ };+ lines.push('### iOS release check could not complete', '',+ `Failed step: **${failed.map(([id]) => names[id] ?? id).join(', ')}**.`, '',+ `See the [workflow logs](${runUrl}) for the error, fix it, then rerun the check.`,+ 'This failure does not establish whether the App Store release is live.');+ } else if (!native && detectionComplete) {+ lines.push('### iOS release not required', '', 'This PR no longer changes native iOS code.');+ } else if (steps.labels?.outputs?.skip === 'true') {+ lines.push('### iOS release gate bypassed', '',+ 'The `skip-ios-update` label bypasses this check. App Store availability has not been verified.');+ } else if (release) {+ const name = `iOS ${release.version} (build ${release.build})`;+ if (release.kind === 'live') {+ lines.push(`### ${name} is live and verified`, '',+ 'The App Store build matches this PR’s current merge result. The iOS release requirement is satisfied; other checks and approvals still apply.');+ } else {+ lines.push(`### ${name} must be live before this PR can merge`, '', release.reason);+ if (release.state) lines.push('', `App Store state: \`${release.state}\`.`);+ if (release.kind === 'waiting') {+ lines.push('', release.state === 'PENDING_DEVELOPER_RELEASE'+ ? 'Release the approved version in App Store Connect.'+ : 'Wait for Apple to approve and make the release available.');+ } else if (release.kind === 'mismatch') {+ lines.push('', 'Bump the release numbers, commit, push, then remove and re-add `ios-update` to release the current native code. Use `--no-min` for a release that does not need a higher native build floor.');+ } else {+ lines.push('', labels.includes('ios-update')+ ? 'The `ios-update` label is already present. Follow the **iOS App Store Release** run; if it failed, fix the reported problem, then remove and re-add the label to retry. Resolve any rejection or metadata issue in App Store Connect first.'+ : 'Once the other checks pass and the PR is ready, add **`ios-update`** to build, upload, and submit it for App Review.');+ }+ lines.push('', 'After release, **iOS Release Watch** reruns this check within 30 minutes. You can also rerun it manually. Optionally enable **auto-merge** to merge once all requirements pass.');+ }+ lines.push('', `The next prod web deploy will use minimum supported iOS build **${release.floor}**, as committed in this PR.`,+ '', `[App Store Connect](${release.distributionUrl})`);+ } else {+ // No structured result means verification never completed; never infer an+ // Apple state from an exit code or unstructured log text.+ lines.push('### iOS release status unavailable', '',+ `The check produced no App Store result. Inspect the [workflow logs](${runUrl}) and rerun it.`);+ }+ lines.push('', `[Workflow run](${runUrl}) · [Release guide](${guideUrl})`);+ const body = lines.join('\n');+ await core.summary.addRaw(body.replace(`${marker}\n`, '')).write();+ if (existing) {+ if (existing.body !== body) {+ await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body });+ }+ } else {+ await github.rest.issues.createComment({ owner, repo, issue_number, body });+ }+ env:+ IOS_GATE_STEPS: ${{ toJSON(steps) }}status-check:needs:- path-checkdiff --git a/apps/web/docs/ios-releases.md b/apps/web/docs/ios-releases.mdindex 3e97a5dc91..300c0a7461 100644--- a/apps/web/docs/ios-releases.md+++ b/apps/web/docs/ios-releases.md@@ -27,7 +27,14 @@ icon and app-name branding are Android-only.- the iOS release numbers to be bumped relative to `main`, and- that exact version + build to be **live on the App Store**.- Until both hold, the check fails and the PR cannot merge.+ Until both hold, the check fails and the PR cannot merge. On same-repo+ PRs, the gate maintains one status comment with the version/build, current+ App Store state, next steps, and a workflow link. Infrastructure failures,+ including an unavailable native-tree hash, are reported as an inability+ to verify the release without instructions to release again, separately from a+ confirmed release requirement. Each gate run refreshes the comment; a+ successful watcher-triggered recheck marks the release verified. Fork PRs+ retain the check logs because their token cannot write PR comments.2. You bump the numbers locally and commit the result:```bashdiff --git a/apps/web/scripts/ios-app-store.mjs b/apps/web/scripts/ios-app-store.mjsindex 5071ed55c1..bfa8f736c6 100644--- a/apps/web/scripts/ios-app-store.mjs+++ b/apps/web/scripts/ios-app-store.mjs@@ -19,7 +19,8 @@// it exits non-zero unless exactly this version+build is live// on the App Store, built from --native-tree (or this checkout's// native code) — the gate the `iOS Native Check` job runs on-// PRs with native iOS changes.+// PRs with native iOS changes. Writes a JSON gate_result to+// GITHUB_OUTPUT only after evaluating the App Store response.//// Auth (same values as ios-release.sh):// APPLE_API_KEY App Store Connect API Key ID@@ -1046,7 +1047,14 @@ async function status() {}const versionRecord = await findAppStoreVersion();- const fail = (reason) => {+ const report = (kind, reason, state = null) => {+ setGitHubOutput("gate_result", JSON.stringify({+ kind, reason, state, version, build, distributionUrl,+ floor: readJson("min-native-build.json").ios,+ }));+ };+ const fail = (reason, kind = "release-required", state = null) => {+ report(kind, reason, state);console.error(`${reason}This PR changes native iOS code, so iOS ${version} (build ${build}) must be@@ -1088,23 +1096,37 @@ ${distributionUrl}`);`App Store version ${version} was live but has been superseded (state ${state}), ` +"so the store build may lack this PR's native code. Bump (`just ios-bump` moves " +"the version), commit, and re-add the ios-update label to release again.",+ "mismatch", state,);}if (!LIVE_STATES.has(state)) {- fail(`App Store version ${version} is not live yet (state ${state}).`);+ fail(+ `App Store version ${version} is not live yet (state ${state}).`,+ SUBMITTED_STATES.has(state) ? "waiting" : "release-required",+ state,+ );}if (attachedBuildNumber !== build) {fail(`App Store version ${version} is live but was built from build ` +`${attachedBuildNumber ?? "unknown"}, not this PR's build ${build}.`,+ "mismatch", state,);}const stamp = (await buildStamp(attachedBuild.data.id))?.tree ?? null;const ours = nativeTreeHash();- if (!ours || stamp !== ours) {+ if (!ours) {+ console.error(+ "Could not compute this checkout's native tree; the live build could not be verified. " ++ "Check the Git checkout and rerun the check.",+ );+ exit(1);+ }+ if (stamp !== ours) {+ report("mismatch", "The live build does not match this PR's current merge result.", state);console.error(`App Store version ${version} (${build}) is live, but that build was not built fromthe native code this merge would produce: its stamp is ${stamp ?? "missing (uploaded outside the release flow)"},-the merge result's native tree (${NATIVE_TREE_PATH}) is ${ours ?? "unknown"}.+the merge result's native tree (${NATIVE_TREE_PATH}) is ${ours}.Either native commits were pushed to this PR after the release, native code landedon main since the release (so the merge would contain code the shipped build lacks),or another PR / a hand release shipped the same version + build number. Merging main@@ -1114,6 +1136,7 @@ actually be merged gets released:${distributionUrl}`);exit(1);}+ report("live", "The exact version, build, and native code are live and verified.", state);console.log(`App Store version ${version} (${build}) is live, built from this native tree.`);}diff --git a/apps/web/scripts/ios-app-store.test.mjs b/apps/web/scripts/ios-app-store.test.mjsnew file mode 100644index 0000000000..3ca07bc8ba--- /dev/null+++ b/apps/web/scripts/ios-app-store.test.mjs@@ -0,0 +1,87 @@+import assert from 'node:assert/strict';+import { spawnSync } from 'node:child_process';+import { generateKeyPairSync } from 'node:crypto';+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import path from 'node:path';+import { test } from 'node:test';+import { fileURLToPath, pathToFileURL } from 'node:url';++const script = fileURLToPath(new URL('./ios-app-store.mjs', import.meta.url));+const tree = 'a'.repeat(40);+const { privateKey } = generateKeyPairSync('ec', { namedCurve: 'prime256v1' });++// Preload replaces fetch before the actual CLI runs; no Apple request or real+// credential is used. Unknown endpoints fail immediately instead of networking.+const preload = `+globalThis.fetch = async (url) => {+ const path = new URL(url).pathname;+ const state = process.env.TEST_STATE;+ if (state === 'API_ERROR') return new Response('fixture error', { status: 403 });+ let data;+ if (path === '/v1/apps') data = [{ id: 'app' }];+ else if (path === '/v1/apps/app/appStoreVersions') data = state === 'MISSING' ? []+ : [{ id: 'version', attributes: { appVersionState: state } }];+ else if (path === '/v1/appStoreVersions/version/build') data = {+ id: 'build', attributes: { version: process.env.TEST_BUILD ?? '188' },+ };+ else if (path === '/v1/builds/build/betaBuildLocalizations') data = [{ attributes: {+ whatsNew: 'native tree ' + process.env.TEST_TREE + ' for PR #123',+ } }];+ else throw new Error('Unexpected endpoint: ' + url);+ return Response.json({ data });+};+`;++for (const [state, expected, attachedBuild, stamp, nativeTree = tree] of [+ ['MISSING', 'release-required', '188', tree],+ ['IN_REVIEW', 'waiting', '188', tree],+ ['PENDING_DEVELOPER_RELEASE', 'waiting', '188', tree],+ ['REJECTED', 'release-required', '188', tree],+ ['REPLACED_WITH_NEW_VERSION', 'mismatch', '188', tree],+ ['READY_FOR_DISTRIBUTION', 'live', '188', tree],+ ['READY_FOR_DISTRIBUTION', 'mismatch', '187', tree],+ ['READY_FOR_DISTRIBUTION', 'mismatch', '188', 'b'.repeat(40)],+ ['READY_FOR_DISTRIBUTION', null, '188', tree, null],+ ['API_ERROR', null, '188', tree],+]) {+ await test(`status reports ${expected} for ${state}, build ${attachedBuild}, tree ${stamp[0]}`, () => {+ const dir = mkdtempSync(path.join(tmpdir(), 'ios-gate-status-'));+ try {+ const fixture = path.join(dir, 'fetch.mjs');+ const output = path.join(dir, 'outputs');+ writeFileSync(fixture, preload);+ writeFileSync(output, '');+ const child = spawnSync(process.execPath, [+ '--import', pathToFileURL(fixture).href, script, 'status', '--require-live',+ '--version', '2.0.10', '--build', '188',+ ...(nativeTree ? ['--native-tree', nativeTree] : []),+ ], {+ env: {+ ...process.env, GITHUB_OUTPUT: output,+ APPLE_API_KEY: 'fixture', APPLE_API_ISSUER: 'fixture',+ APPLE_API_KEY_P8: privateKey.export({ type: 'pkcs8', format: 'pem' }),+ TEST_STATE: state, TEST_BUILD: attachedBuild, TEST_TREE: stamp,+ ...(!nativeTree ? { GIT_DIR: path.join(dir, 'missing.git') } : {}),+ }, encoding: 'utf8', timeout: 10000,+ });+ assert.equal(child.status, expected === 'live' ? 0 : 1, child.stderr);+ const text = readFileSync(output, 'utf8');+ if (!expected) {+ assert.equal(text, '', 'failed verification must not emit an App Store conclusion');+ if (!nativeTree) {+ assert.match(child.stderr, /Could not compute.*native tree/);+ assert.doesNotMatch(child.stderr, /bump|ios-update|release again/i);+ }+ } else {+ const result = JSON.parse(text.trim().slice('gate_result='.length));+ assert.equal(result.kind, expected);+ assert.equal(result.version, '2.0.10');+ assert.equal(result.build, '188');+ assert.equal(result.floor, JSON.parse(readFileSync(new URL('../min-native-build.json', import.meta.url))).ios);+ }+ } finally {+ rmSync(dir, { recursive: true, force: true });+ }+ });+}diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/ios_native_check_comment.js b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/ios_native_check_comment.jsnew file mode 100644index 0000000000..f20b18d804--- /dev/null+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/ios_native_check_comment.js@@ -0,0 +1,86 @@+const marker = '<!-- ios-native-check-status -->';+const steps = JSON.parse(process.env.IOS_GATE_STEPS);+const { owner, repo } = context.repo;+const issue_number = context.issue.number;+const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: issue_number });+// A rerun uses the original event. Never replace the current head's status+// with an older commit's result, or create comments after the PR has closed.+if (pr.state !== 'open' || pr.head.sha !== context.payload.pull_request.head.sha) return;++const comments = await github.paginate(github.rest.issues.listComments, {+ owner, repo, issue_number, per_page: 100,+});+const existing = comments.find((comment) =>+ comment.user?.login === 'github-actions[bot]' && comment.body?.startsWith(marker));+const native = steps['native-filter']?.outputs?.ios_native === 'true'+ || steps['cache-wasm']?.outputs?.bumped === 'true';+const detectionComplete = steps['native-filter']?.outcome === 'success'+ && steps['cache-wasm']?.outcome === 'success';+const failed = Object.entries(steps).filter(([, step]) => step.outcome === 'failure');+if (!native && failed.length === 0 && !existing) return;++const runUrl = `${context.serverUrl}/${owner}/${repo}/actions/runs/${context.runId}/attempts/${process.env.GITHUB_RUN_ATTEMPT ?? "1"}`;+const guideUrl = `${context.serverUrl}/${owner}/${repo}/blob/${pr.head.sha}/apps/web/docs/ios-releases.md`;+const release = steps.live?.outputs?.gate_result+ ? JSON.parse(steps.live.outputs.gate_result) : null;+const labels = pr.labels.map((label) => label.name);+const lines = [marker];+if (failed.length && !release) {+ const names = {+ checkout: 'Checkout Repo',+ bun: 'Setup Bun',+ 'native-filter': 'Detect native iOS changes',+ 'cache-wasm': 'Detect a client cache wasm version bump',+ labels: "Read the PR's labels",+ bump: 'Verify iOS release numbers were bumped',+ credentials: 'Fetch App Store Connect credentials',+ live: 'Fetch the merge result and check App Store status',+ };+ lines.push('### iOS release check could not complete', '',+ `Failed step: **${failed.map(([id]) => names[id] ?? id).join(', ')}**.`, '',+ `See the [workflow logs](${runUrl}) for the error, fix it, then rerun the check.`,+ 'This failure does not establish whether the App Store release is live.');+} else if (!native && detectionComplete) {+ lines.push('### iOS release not required', '', 'This PR no longer changes native iOS code.');+} else if (steps.labels?.outputs?.skip === 'true') {+ lines.push('### iOS release gate bypassed', '',+ 'The `skip-ios-update` label bypasses this check. App Store availability has not been verified.');+} else if (release) {+ const name = `iOS ${release.version} (build ${release.build})`;+ if (release.kind === 'live') {+ lines.push(`### ${name} is live and verified`, '',+ 'The App Store build matches this PR’s current merge result. The iOS release requirement is satisfied; other checks and approvals still apply.');+ } else {+ lines.push(`### ${name} must be live before this PR can merge`, '', release.reason);+ if (release.state) lines.push('', `App Store state: \`${release.state}\`.`);+ if (release.kind === 'waiting') {+ lines.push('', release.state === 'PENDING_DEVELOPER_RELEASE'+ ? 'Release the approved version in App Store Connect.'+ : 'Wait for Apple to approve and make the release available.');+ } else if (release.kind === 'mismatch') {+ lines.push('', 'Bump the release numbers, commit, push, then remove and re-add `ios-update` to release the current native code. Use `--no-min` for a release that does not need a higher native build floor.');+ } else {+ lines.push('', labels.includes('ios-update')+ ? 'The `ios-update` label is already present. Follow the **iOS App Store Release** run; if it failed, fix the reported problem, then remove and re-add the label to retry. Resolve any rejection or metadata issue in App Store Connect first.'+ : 'Once the other checks pass and the PR is ready, add **`ios-update`** to build, upload, and submit it for App Review.');+ }+ lines.push('', 'After release, **iOS Release Watch** reruns this check within 30 minutes. You can also rerun it manually. Optionally enable **auto-merge** to merge once all requirements pass.');+ }+ lines.push('', `The next prod web deploy will use minimum supported iOS build **${release.floor}**, as committed in this PR.`,+ '', `[App Store Connect](${release.distributionUrl})`);+} else {+ // No structured result means verification never completed; never infer an+ // Apple state from an exit code or unstructured log text.+ lines.push('### iOS release status unavailable', '',+ `The check produced no App Store result. Inspect the [workflow logs](${runUrl}) and rerun it.`);+}+lines.push('', `[Workflow run](${runUrl}) · [Release guide](${guideUrl})`);+const body = lines.join('\n');+await core.summary.addRaw(body.replace(`${marker}\n`, '')).write();+if (existing) {+ if (existing.body !== body) {+ await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body });+ }+} else {+ await github.rest.issues.createComment({ owner, repo, issue_number, body });+}diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/ios_native_check_comment.test.cjs b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/ios_native_check_comment.test.cjsnew file mode 100644index 0000000000..bbce116887--- /dev/null+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/ios_native_check_comment.test.cjs@@ -0,0 +1,118 @@+const assert = require('node:assert/strict');+const { readFileSync } = require('node:fs');+const { test } = require('node:test');+const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;+const script = new AsyncFunction('github', 'context', 'core', 'process',+ readFileSync(`${__dirname}/ios_native_check_comment.js`, 'utf8'));+const marker = '<!-- ios-native-check-status -->';++async function run({ steps, comments = [], head = 'current', state = 'open', labels = [] }) {+ const writes = [];+ const summaries = [];+ const github = {+ rest: {+ pulls: { get: async () => ({ data: { state, head: { sha: head }, labels } }) },+ issues: {+ listComments() {},+ createComment: async (value) => writes.push({ type: 'create', ...value }),+ updateComment: async (value) => writes.push({ type: 'update', ...value }),+ },+ },+ paginate: async () => comments,+ };+ const core = { summary: { addRaw(body) { summaries.push(body); return this; }, async write() {} } };+ await script(github, {+ repo: { owner: 'macro-inc', repo: 'macro' }, issue: { number: 123 },+ payload: { pull_request: { head: { sha: 'current' } } },+ serverUrl: 'https://github.com', runId: 456,+ }, core, { env: { IOS_GATE_STEPS: JSON.stringify(steps), GITHUB_RUN_ATTEMPT: '2' } });+ return { writes, summaries };+}+const native = { 'native-filter': { outputs: { ios_native: 'true' } } };+const release = { version: '2.0.10', build: '188', floor: 185, distributionUrl: 'https://example.test/app' };++test('expected release requirement includes instructions and the committed floor', async () => {+ const { writes, summaries } = await run({ steps: { ...native,+ live: { outcome: 'failure', outputs: { gate_result: JSON.stringify({ ...release,+ kind: 'release-required', reason: 'Version has not been created.' }) } },+ } });+ assert.equal(writes.length, 1);+ assert.equal(writes[0].type, 'create');+ assert.match(writes[0].body, /2\.0\.10 \(build 188\) must be live/);+ assert.match(writes[0].body, /add \*\*`ios-update`\*\*/);+ assert.match(writes[0].body, /build \*\*185\*\*/);+ assert.match(writes[0].body, /runs\/456\/attempts\/2/);+ assert.equal(summaries.length, 1);+});++test('infrastructure failures never claim that the release is missing', async () => {+ for (const id of ['checkout', 'bun', 'credentials', 'live', 'bump']) {+ const { writes } = await run({ steps: { ...native, [id]: { outcome: 'failure' } } });+ assert.match(writes[0].body, /could not complete/);+ assert.match(writes[0].body, /does not establish whether/);+ assert.doesNotMatch(writes[0].body, /must be live before/);+ }+});++test('waiting and live results update the existing bot comment', async () => {+ for (const kind of ['waiting', 'live']) {+ const { writes } = await run({ comments: [{ id: 99, user: { login: 'github-actions[bot]' }, body: marker }],+ steps: { ...native, live: { outcome: kind === 'live' ? 'success' : 'failure', outputs: {+ gate_result: JSON.stringify({ ...release, kind, reason: 'In review.', state: 'IN_REVIEW' }),+ } } },+ });+ assert.equal(writes[0].type, 'update');+ assert.equal(writes[0].comment_id, 99);+ assert.match(writes[0].body, kind === 'live' ? /live and verified/ : /Wait for Apple/);+ }+});++test('manual release and mismatched build need action rather than waiting', async () => {+ const waiting = await run({ steps: { ...native, live: { outputs: { gate_result: JSON.stringify({+ ...release, kind: 'waiting', state: 'PENDING_DEVELOPER_RELEASE', reason: 'Approved.',+ }) } } } });+ assert.match(waiting.writes[0].body, /Release the approved version in App Store Connect/);+ const mismatch = await run({ steps: { ...native, live: { outputs: { gate_result: JSON.stringify({+ ...release, kind: 'mismatch', reason: 'Wrong native tree.',+ }) } } } });+ assert.match(mismatch.writes[0].body, /Bump the release numbers/);+ assert.match(mismatch.writes[0].body, /--no-min/);+});++test('ignore stale runs and closed PRs', async () => {+ for (const options of [{ head: 'newer' }, { state: 'closed' }]) {+ assert.equal((await run({ steps: native, ...options })).writes.length, 0);+ }+});++test('web-only PRs stay quiet and resolved native changes update old comments', async () => {+ assert.equal((await run({ steps: {} })).writes.length, 0);+ const { writes } = await run({ steps: {+ 'native-filter': { outcome: 'success', outputs: { ios_native: 'false' } },+ 'cache-wasm': { outcome: 'success', outputs: { bumped: 'false' } },+ }, comments: [{ id: 99,+ user: { login: 'github-actions[bot]' }, body: marker }] });+ assert.equal(writes[0].type, 'update');+ assert.match(writes[0].body, /no longer changes native/);+});++test('never edit a human comment that copies the marker', async () => {+ const { writes } = await run({ steps: { ...native, live: { outcome: 'failure' } },+ comments: [{ id: 77, user: { login: 'human' }, body: marker }] });+ assert.equal(writes[0].type, 'create');+});++test('skip label reports a bypass without claiming verification', async () => {+ const { writes } = await run({ steps: { ...native, labels: { outputs: { skip: 'true' } } } });+ assert.match(writes[0].body, /gate bypassed/);+ assert.match(writes[0].body, /has not been verified/);+});++test('failed checkout cannot overwrite an existing comment with a non-native conclusion', async () => {+ const comments = [{ id: 99, user: { login: 'github-actions[bot]' }, body: marker }];+ const { writes } = await run({ steps: { checkout: { outcome: 'failure' } }, comments });+ assert.match(writes[0].body, /could not complete/);+ assert.doesNotMatch(writes[0].body, /no longer changes native/);+ const unknown = await run({ steps: {}, comments });+ assert.match(unknown.writes[0].body, /status unavailable/);+});diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/ios_native_check.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/ios_native_check.rsindex 8e856162a8..3cc2d5afd3 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/ios_native_check.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/ios_native_check.rs@@ -61,15 +61,15 @@ pub(super) fn job() -> Job {Job::default().name(JOB_NAME).runs_on(runners::Runner::TinyNoCache.to_string())- // Reads only: the PR's labels and merge commit, and a base-branch fetch.+ // Reads the PR and base branch; updates one gate-status comment on same-repo PRs..permissions(Permissions::default().contents(Level::Read)- .pull_requests(Level::Read),+ .pull_requests(Level::Write),)// Shallow: the path filter uses the API, and the bump check fetches// the base branch itself, only when it runs.- .add_step(super::checkout("Checkout Repo", false))+ .add_step(super::checkout("Checkout Repo", false).id("checkout")).add_step(paths_filter()).add_step(cache_wasm_version_bump()).add_step(read_labels())@@ -78,6 +78,7 @@ pub(super) fn job() -> Job {.add_step(fetch_credentials()).add_step(require_live_version()).add_step(skip_notice())+ .add_step(pr_comment())}fn gated() -> Expression {@@ -168,6 +169,7 @@ fn setup_bun() -> Step<Use> {"setup-bun","0c5077e51419868618aeaa5fe8019c62421857d6",) // v2.2.0+ .id("bun").if_condition(gated()).add_with(("bun-version", "1.3.13"))}@@ -176,6 +178,7 @@ fn verify_bump() -> Step<Run> {Step::new("Verify iOS release numbers were bumped").run("bun scripts/ios-verify-native-bump.mjs").if_condition(gated())+ .id("bump").working_directory(xtask_paths::repo_dir!("apps/web"))// The base the merge result was built on (fetched by the cache-wasm step)..add_env(("BASE_REF", "${{ steps.cache-wasm.outputs.base_sha }}"))@@ -189,6 +192,7 @@ fn fetch_credentials() -> Step<Run> {"../scripts/ios_app_store_connect_credentials.sh")).shell("bash")+ .id("credentials").if_condition(gated()).add_env(("DOPPLER_TOKEN", vars::IOS_RELEASE_DOPPLER_TOKEN))}@@ -208,6 +212,7 @@ fn require_live_version() -> Step<Run> {)).if_condition(gated()).shell("bash")+ .id("live").working_directory(xtask_paths::repo_dir!("apps/web")).add_env(("GH_TOKEN", "${{ github.token }}")).add_env(("GH_REPO", "${{ github.repository }}"))@@ -222,3 +227,21 @@ fn skip_notice() -> Step<Run> {).if_condition(Expression::new(format!("{NATIVE_CHANGED} && {SKIP_LABEL}")))}++/// Keep release instructions visible on the PR even when an earlier step fails.+fn pr_comment() -> Step<Use> {+ Step::new("Update iOS gate status on the PR")+ .uses(+ "actions",+ "github-script",+ "f28e40c7f34bde8b3046d885e986cb6290c5673b",+ )+ .if_condition(Expression::new(+ "!cancelled() && github.event.pull_request.head.repo.full_name == github.repository",+ ))+ .add_env(("IOS_GATE_STEPS", "${{ toJSON(steps) }}"))+ .add_with((+ "script",+ include_str!("../scripts/ios_native_check_comment.js"),+ ))+}diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/test.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/test.rsindex 601c254305..4749ddba9c 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/test.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/web_app_check_main/test.rs@@ -442,3 +442,39 @@ native_tree_fetch HEAD);}}++#[test]+fn ios_gate_comment_runs_after_failures_and_only_for_same_repo_prs() {+ let yaml = web_app_check_main().to_string().expect("workflow yaml");+ let gate = job(&yaml, "ios-native-check", "status-check");+ assert!(gate.contains("pull-requests: write"));+ assert!(gate.contains(+ "!cancelled() && github.event.pull_request.head.repo.full_name == github.repository"+ ));+ assert!(gate.contains("IOS_GATE_STEPS: ${{ toJSON(steps) }}"));+ for id in ["checkout", "bun", "bump", "credentials", "live"] {+ assert!(gate.contains(&format!("id: {id}")), "missing step id: {id}");+ }+}++#[test]+fn ios_gate_status_and_comment_scenarios() {+ let output = std::process::Command::new("node")+ .arg("--test")+ .arg(concat!(+ env!("CARGO_MANIFEST_DIR"),+ "/../../../../apps/web/scripts/ios-app-store.test.mjs"+ ))+ .arg(concat!(+ env!("CARGO_MANIFEST_DIR"),+ "/src/workflows/scripts/ios_native_check_comment.test.cjs"+ ))+ .output()+ .expect("run iOS gate scenarios with Node");+ assert!(+ output.status.success(),+ "iOS gate scenarios failed:\n{}\n{}",+ String::from_utf8_lossy(&output.stdout),+ String::from_utf8_lossy(&output.stderr)+ );+}