Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(ci): Appetize iPhone-simulator previews on labelled PRs (#6359)

Wolf Mermelstein18794cce417c
diff --git a/.github/workflows/ios_preview.yml b/.github/workflows/ios_preview.yml
new file mode 100644
index 0000000000..4d90621f48
--- /dev/null
+++ b/.github/workflows/ios_preview.yml
@@ -0,0 +1,441 @@
+# DO NOT EDIT — regenerate with `cargo x workflows` (from the repository root).
+# Source: tooling/xtask/crates/xtask_workflows/src/workflows/ios_preview.rs
+name: iOS Preview
+'on':
+ pull_request:
+ types:
+ - labeled
+ - synchronize
+ - reopened
+ - closed
+ workflow_dispatch: {}
+jobs:
+ preview:
+ if: github.event_name == 'workflow_dispatch' || (github.event.action != 'closed' && contains(github.event.pull_request.labels.*.name, 'ios-preview') && github.event.pull_request.draft == false)
+ name: Build iOS simulator app and publish to Appetize
+ runs-on: nscloud-macos-sequoia-arm64-6x14
+ permissions:
+ contents: read
+ pull-requests: write
+ timeout-minutes: 40
+ steps:
+ - name: Checkout
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
+ with:
+ clean: 'false'
+ persist-credentials: 'false'
+ - name: Install Nix
+ run: |
+ set -euo pipefail
+ if ! command -v nix >/dev/null 2>&1; then
+ curl --http1.1 --retry 5 --retry-delay 5 --retry-all-errors \
+ --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | \
+ sh -s -- install macos --no-confirm \
+ --extra-conf "experimental-features = nix-command flakes" \
+ --extra-conf "sandbox = false" \
+ --extra-conf "trusted-users = root runner"
+ fi
+ echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
+ echo "NIX_REMOTE=daemon" >> "$GITHUB_ENV"
+ export PATH="/nix/var/nix/profiles/default/bin:$PATH"
+ export NIX_REMOTE=daemon
+ nix --version
+ shell: bash
+ - id: build
+ name: Build iOS simulator app
+ run: |
+ set -euo pipefail
+
+ # Appetize streams iOS *Simulator* builds only (a device .ipa cannot be run), so
+ # this produces an unsigned arm64 simulator .app rather than anything
+ # installable on hardware.
+
+ # Probe before the ~6 minutes of frontend build, so a runner missing its iOS
+ # bits fails in seconds instead of at the very last step.
+ #
+ # The SDK is the check that matters, and it is not implied by the others: since
+ # Xcode 16 platforms are downloaded separately, so `xcodebuild -version` and
+ # even `simctl` can look healthy on a runner with no iPhoneSimulator SDK. Tauri
+ # then dies reading SDKSettings.plist out of it.
+ xcodebuild -version
+ echo "Developer dir: $(xcode-select -p)"
+
+ SIMULATOR_SDK="$(xcrun --sdk iphonesimulator --show-sdk-path 2>/dev/null || true)"
+ if [ -z "$SIMULATOR_SDK" ] || [ ! -f "$SIMULATOR_SDK/SDKSettings.plist" ]; then
+ echo "No iPhoneSimulator SDK on this runner." >&2
+ echo "Install it with: xcodebuild -downloadPlatform iOS" >&2
+ echo "--- installed SDKs ---" >&2
+ xcodebuild -showsdks >&2 || true
+ echo "--- platforms ---" >&2
+ ls -1 "$(xcode-select -p)/Platforms" >&2 || true
+ exit 1
+ fi
+ echo "iPhoneSimulator SDK: $SIMULATOR_SDK"
+
+ if ! xcrun simctl list runtimes --json | grep -q '"isAvailable" : true'; then
+ echo "No available iOS simulator runtime on this runner." >&2
+ echo "Install one with: xcodebuild -downloadPlatform iOS" >&2
+ xcrun simctl list runtimes >&2
+ exit 1
+ fi
+
+ # cargo-mobile2 locates the SDK by shelling out to `xcode-select -p`, which
+ # returns $DEVELOPER_DIR whenever that is set — and nix's Darwin stdenv sets it
+ # to nix's own Apple SDK, which has no Platforms/iPhoneSimulator.platform. So
+ # the SDK is genuinely there for every command run out here, and genuinely
+ # absent for anything run inside `nix develop`, which is what made tauri report
+ # a bare NotFound for a file this script can see.
+ #
+ # Carry the real developer dir in under a name nix has no opinion about, and
+ # restore DEVELOPER_DIR once inside the shell.
+ MACRO_DEVELOPER_DIR="$(xcode-select -p)"
+ export MACRO_DEVELOPER_DIR
+
+ # cargo-tauri, bun, just, wasm-pack and the pinned toolchain (which carries
+ # aarch64-apple-ios-sim, see rust-toolchain.toml) all come from the dev shell.
+ # Phase 1 — the web and wasm build, in the dev shell exactly as it comes. It
+ # needs nix's bun, wasm-pack and cc wrapper, and must not see Apple's.
+ nix develop --command bash -euo pipefail -c '
+ bun install --frozen-lockfile
+ cd apps/web
+ just build-tauri-dev
+ '
+
+ # Phase 2 — everything Xcode drives, with Apple's toolchain in front.
+ #
+ # The dev shell ships its own: DEVELOPER_DIR points at nix's apple-sdk and
+ # `xcodebuild` is the xcbuild reimplementation, which rejects real flags. But
+ # swapping only those two desyncs nix's cc wrapper from its SDK and host
+ # proc-macro links then fail on -liconv, so the compiler and linker have to
+ # come from Apple too. Hence one dir at the front of PATH rather than a couple
+ # of overrides — and hence phase 1 being a separate shell, since the wasm build
+ # wants the nix cc it was configured against.
+ nix develop --command bash -euo pipefail -c '
+ echo "before: DEVELOPER_DIR=$(xcode-select -p 2>&1), xcodebuild=$(command -v xcodebuild || echo none)"
+
+ export DEVELOPER_DIR="$MACRO_DEVELOPER_DIR"
+ APPLE_TOOLS="$(mktemp -d)"
+ for tool in xcodebuild xcrun xcode-select simctl actool ibtool plutil ditto \
+ clang clang++ cc c++ ld ar ranlib libtool lipo strip nm \
+ install_name_tool codesign dsymutil; do
+ [ -x "/usr/bin/$tool" ] && ln -sf "/usr/bin/$tool" "$APPLE_TOOLS/$tool"
+ done
+ export PATH="$APPLE_TOOLS:$PATH"
+
+ # nix'"'"'s wrapper flags name its own sysroot; Apple'"'"'s clang would either
+ # ignore them or trip over them.
+ unset NIX_CFLAGS_COMPILE NIX_LDFLAGS SDKROOT || true
+
+ echo "after: DEVELOPER_DIR=$(xcode-select -p 2>&1), xcodebuild=$(command -v xcodebuild), cc=$(command -v cc)"
+ xcodebuild -version
+
+ cd apps/web
+ # Positional: `prebuilt=true` would be passed as the literal argument
+ # "prebuilt=true", silently rebuilding the frontend a second time here.
+ just ios-build-sim true
+ '
+
+ APP="apps/web/tauri/src-tauri/gen/apple/build/arm64-sim/macro.app"
+ if [ ! -d "$APP" ]; then
+ echo "Expected a simulator .app at $APP" >&2
+ find apps/web/tauri/src-tauri/gen/apple/build -maxdepth 3 -name '*.app' >&2 || true
+ exit 1
+ fi
+
+ # An iPhoneOS build would upload fine and then refuse to boot, so prove the SDK
+ # before handing it to Appetize.
+ if ! plutil -extract DTPlatformName raw "$APP/Info.plist" | grep -q iphonesimulator; then
+ echo "Built against the device SDK, not the simulator SDK:" >&2
+ plutil -extract DTPlatformName raw "$APP/Info.plist" >&2
+ exit 1
+ fi
+
+ # Everything above can pass on an app that launches to a black screen: the
+ # frontend is embedded in the binary by generate_context!(), so there is no
+ # file whose absence gives it away, and build/link/zip/upload all succeed
+ # regardless. The only honest check is to run it.
+ #
+ # Boot the same simulator Appetize would, launch the app, and photograph it.
+ # The screenshot is uploaded either way — it is the single most useful artifact
+ # when a preview misbehaves.
+ mkdir -p artifacts
+
+ # Zip first, then smoke-test what comes *back out* of the zip. Appetize never
+ # sees the build directory — it installs the archive — so testing $APP directly
+ # would leave the round-trip itself unverified, which is precisely where a
+ # preview can differ from a build that looked fine in CI.
+ ditto -c -k --sequesterRsrc --keepParent "$APP" artifacts/macro-sim.zip
+ rm -rf artifacts/roundtrip
+ ditto -x -k artifacts/macro-sim.zip artifacts/roundtrip
+ ROUNDTRIP_APP="artifacts/roundtrip/$(basename "$APP")"
+ test -d "$ROUNDTRIP_APP" || { echo "zip round-trip produced no .app" >&2; exit 1; }
+
+ DEVICE="$(xcrun simctl create ios-preview-smoke com.apple.CoreSimulator.SimDeviceType.iPhone-15-Pro)"
+ trap 'xcrun simctl delete "$DEVICE" >/dev/null 2>&1 || true' EXIT
+ xcrun simctl boot "$DEVICE"
+ xcrun simctl bootstatus "$DEVICE" -b
+
+ xcrun simctl install "$DEVICE" "$ROUNDTRIP_APP"
+ xcrun simctl launch "$DEVICE" com.macro.app.prod
+
+ # The webview needs a moment to load and paint before the shot is worth taking.
+ sleep 25
+ xcrun simctl io "$DEVICE" screenshot artifacts/launch.png
+
+ # The app's own log, filtered by process name as AGENTS.md prescribes for
+ # diagnosing iOS freezes. Kept whether or not the shot looks right — it is what
+ # says *why* a screen was blank.
+ xcrun simctl spawn "$DEVICE" log show --predicate 'process == "macro"' \
+ --last 3m --style compact >artifacts/launch.log 2>&1 || true
+ echo "--- last 40 app log lines ---"
+ tail -40 artifacts/launch.log || true
+
+ if [ ! -f artifacts/launch.png ]; then
+ echo "simctl produced no screenshot." >&2
+ exit 1
+ fi
+
+ # A blank screen compresses to almost nothing, while any real UI carries
+ # detail. This is a coarse signal deliberately: it cannot say the app is
+ # correct, only that it painted something other than a void.
+ SHOT_BYTES="$(stat -f%z artifacts/launch.png)"
+ echo "Launch screenshot: ${SHOT_BYTES} bytes"
+ if [ "$SHOT_BYTES" -lt 40000 ]; then
+ echo "The app launched to a blank screen (${SHOT_BYTES}-byte screenshot)." >&2
+ echo "See the launch.png artifact; the log archive is beside it." >&2
+ exit 1
+ fi
+
+ # The archive was built before the smoke test so the test could run against it;
+ # drop the unpacked copy so it does not bloat the artifact upload.
+ rm -rf artifacts/roundtrip
+ shell: bash
+ - name: Upload macro-ios-simulator-app artifact
+ if: always()
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
+ with:
+ name: macro-ios-simulator-app
+ path: artifacts/*
+ if-no-files-found: warn
+ retention-days: '30'
+ - name: Publish to Appetize and comment
+ if: github.event_name == 'pull_request'
+ run: |
+ set -euo pipefail
+
+ # Publish the simulator build to Appetize and post the preview comment.
+ #
+ # The comment is the only store of the Appetize key: recovering it from there
+ # is what lets a PR keep one app across pushes, and lets the cleanup job find
+ # it on close. `gh` and `jq` both ship in Namespace's runner image (see
+ # cancel_stuck_cloud_storage_deploys).
+
+ MARKER='<!-- appetize-ios-preview -->'
+ API='https://api.appetize.io/v1/apps'
+
+ bot_comments() {
+ gh api "repos/$REPO/issues/$PR_NUMBER/comments" --paginate \
+ --jq '.[] | select(.user.type == "Bot")'
+ }
+
+ # Only our comment carries an appetize.io link, so this cannot pick up the web
+ # preview's comment by accident.
+ existing_key() {
+ bot_comments | jq -r 'select(.body | contains("appetize.io/app/")) | .body' |
+ grep -oE 'appetize\.io/app/[A-Za-z0-9_-]+' | head -1 | sed 's|.*/||'
+ }
+
+ PUBLIC_KEY="$(existing_key || true)"
+
+ if [ "${CLEANUP:-0}" = "1" ]; then
+ if [ -z "$PUBLIC_KEY" ]; then
+ echo "No Appetize app recorded on this PR; nothing to clean."
+ exit 0
+ fi
+ # 404 means someone already removed it, which is the desired end state.
+ STATUS="$(curl -sS -o /dev/null -w '%{http_code}' -X DELETE "$API/$PUBLIC_KEY" \
+ -H "X-API-KEY: $APPETIZE_API_TOKEN")"
+ case "$STATUS" in
+ 2* | 404) echo "Deleted Appetize app $PUBLIC_KEY ($STATUS)" ;;
+ *) echo "Appetize delete failed with $STATUS" >&2; exit 1 ;;
+ esac
+ exit 0
+ fi
+
+ # Session caps, not access restrictions, are what keep a leaked link cheap: a
+ # 3-minute idle timeout, a 30-minute ceiling and two concurrent sessions, on an
+ # app that still needs a Macro login to show anything. `run=authenticated`
+ # would demand an Appetize account and `referrerHostnamesRestricted` would
+ # reject the click outright (GitHub sends no referrer on external links), so
+ # both would lock out the reviewer this exists for.
+ if [ -n "$PUBLIC_KEY" ]; then TARGET="$API/$PUBLIC_KEY"; else TARGET="$API"; fi
+ RESPONSE="$(curl -sS -X POST "$TARGET" \
+ -H "X-API-KEY: $APPETIZE_API_TOKEN" \
+ -F "file=@$ARCHIVE_PATH" -F 'platform=ios' -F 'fileType=zip' \
+ -F 'timeout=180' -F 'timeLimit=1800' -F 'maxConcurrent=2' \
+ -F "note=PR #$PR_NUMBER $SHA $BRANCH" \
+ -F 'appPermissions.run=public' -F 'appPermissions.debugLog=public' \
+ -F 'appPermissions.networkIntercept=public' \
+ -F 'appPermissions.networkProxy=public')"
+
+ PUBLIC_KEY="$(jq -er '.publicKey' <<<"$RESPONSE")" || {
+ echo "Appetize upload carried no publicKey: $RESPONSE" >&2
+ exit 1
+ }
+ echo "Appetize app $PUBLIC_KEY"
+
+ link() { printf '[%s](https://appetize.io/app/%s?device=%s&autoplay=false)' "$1" "$PUBLIC_KEY" "$2"; }
+
+ # `device` is a query parameter over one uploaded build, so extra sizes cost
+ # nothing: no rebuild, no second upload. osVersion is deliberately omitted so
+ # links keep working when Appetize retires a runtime.
+ BODY="$MARKER
+ **iOS preview** — \`$BRANCH\` @ \`${SHA:0:7}\`
+
+ $(link 'iPhone 15 Pro' iphone15pro) · $(link 'iPhone 16 Pro Max' iphone16promax) · $(link 'iPad Pro 12.9"' ipadpro129inch5thgeneration)
+
+ Boots on click; nothing streams until then. You will need to sign in inside the simulator."
+
+ # get-or-create-id.ts finds the *web* preview comment by this substring and
+ # scrapes the preview id out of its body, so our comment must never contain it.
+ case "$BODY" in
+ *preview.macro.com*)
+ echo "The iOS comment contains preview.macro.com, which would break web previews." >&2
+ exit 1
+ ;;
+ esac
+
+ COMMENT_ID="$(bot_comments | jq -r "select(.body | contains(\"$MARKER\")) | .id" | head -1)"
+ if [ -n "$COMMENT_ID" ]; then
+ gh api -X PATCH "repos/$REPO/issues/comments/$COMMENT_ID" -f "body=$BODY" >/dev/null
+ echo "Updated existing iOS preview comment"
+ else
+ gh api -X POST "repos/$REPO/issues/$PR_NUMBER/comments" -f "body=$BODY" >/dev/null
+ echo "Created iOS preview comment"
+ fi
+ shell: bash
+ env:
+ APPETIZE_API_TOKEN: ${{ secrets.APPETIZE_API_TOKEN }}
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ REPO: ${{ github.repository }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ ARCHIVE_PATH: artifacts/macro-sim.zip
+ BRANCH: ${{ github.head_ref }}
+ SHA: ${{ github.event.pull_request.head.sha }}
+ cleanup:
+ if: github.event_name == 'pull_request' && github.event.action == 'closed'
+ name: Delete the PR's Appetize app
+ runs-on: namespace-profile-linux-tiny-no-cache
+ permissions:
+ contents: read
+ pull-requests: read
+ steps:
+ - name: Checkout
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
+ with:
+ clean: 'false'
+ persist-credentials: 'false'
+ - name: Delete Appetize app
+ run: |
+ set -euo pipefail
+
+ # Publish the simulator build to Appetize and post the preview comment.
+ #
+ # The comment is the only store of the Appetize key: recovering it from there
+ # is what lets a PR keep one app across pushes, and lets the cleanup job find
+ # it on close. `gh` and `jq` both ship in Namespace's runner image (see
+ # cancel_stuck_cloud_storage_deploys).
+
+ MARKER='<!-- appetize-ios-preview -->'
+ API='https://api.appetize.io/v1/apps'
+
+ bot_comments() {
+ gh api "repos/$REPO/issues/$PR_NUMBER/comments" --paginate \
+ --jq '.[] | select(.user.type == "Bot")'
+ }
+
+ # Only our comment carries an appetize.io link, so this cannot pick up the web
+ # preview's comment by accident.
+ existing_key() {
+ bot_comments | jq -r 'select(.body | contains("appetize.io/app/")) | .body' |
+ grep -oE 'appetize\.io/app/[A-Za-z0-9_-]+' | head -1 | sed 's|.*/||'
+ }
+
+ PUBLIC_KEY="$(existing_key || true)"
+
+ if [ "${CLEANUP:-0}" = "1" ]; then
+ if [ -z "$PUBLIC_KEY" ]; then
+ echo "No Appetize app recorded on this PR; nothing to clean."
+ exit 0
+ fi
+ # 404 means someone already removed it, which is the desired end state.
+ STATUS="$(curl -sS -o /dev/null -w '%{http_code}' -X DELETE "$API/$PUBLIC_KEY" \
+ -H "X-API-KEY: $APPETIZE_API_TOKEN")"
+ case "$STATUS" in
+ 2* | 404) echo "Deleted Appetize app $PUBLIC_KEY ($STATUS)" ;;
+ *) echo "Appetize delete failed with $STATUS" >&2; exit 1 ;;
+ esac
+ exit 0
+ fi
+
+ # Session caps, not access restrictions, are what keep a leaked link cheap: a
+ # 3-minute idle timeout, a 30-minute ceiling and two concurrent sessions, on an
+ # app that still needs a Macro login to show anything. `run=authenticated`
+ # would demand an Appetize account and `referrerHostnamesRestricted` would
+ # reject the click outright (GitHub sends no referrer on external links), so
+ # both would lock out the reviewer this exists for.
+ if [ -n "$PUBLIC_KEY" ]; then TARGET="$API/$PUBLIC_KEY"; else TARGET="$API"; fi
+ RESPONSE="$(curl -sS -X POST "$TARGET" \
+ -H "X-API-KEY: $APPETIZE_API_TOKEN" \
+ -F "file=@$ARCHIVE_PATH" -F 'platform=ios' -F 'fileType=zip' \
+ -F 'timeout=180' -F 'timeLimit=1800' -F 'maxConcurrent=2' \
+ -F "note=PR #$PR_NUMBER $SHA $BRANCH" \
+ -F 'appPermissions.run=public' -F 'appPermissions.debugLog=public' \
+ -F 'appPermissions.networkIntercept=public' \
+ -F 'appPermissions.networkProxy=public')"
+
+ PUBLIC_KEY="$(jq -er '.publicKey' <<<"$RESPONSE")" || {
+ echo "Appetize upload carried no publicKey: $RESPONSE" >&2
+ exit 1
+ }
+ echo "Appetize app $PUBLIC_KEY"
+
+ link() { printf '[%s](https://appetize.io/app/%s?device=%s&autoplay=false)' "$1" "$PUBLIC_KEY" "$2"; }
+
+ # `device` is a query parameter over one uploaded build, so extra sizes cost
+ # nothing: no rebuild, no second upload. osVersion is deliberately omitted so
+ # links keep working when Appetize retires a runtime.
+ BODY="$MARKER
+ **iOS preview** — \`$BRANCH\` @ \`${SHA:0:7}\`
+
+ $(link 'iPhone 15 Pro' iphone15pro) · $(link 'iPhone 16 Pro Max' iphone16promax) · $(link 'iPad Pro 12.9"' ipadpro129inch5thgeneration)
+
+ Boots on click; nothing streams until then. You will need to sign in inside the simulator."
+
+ # get-or-create-id.ts finds the *web* preview comment by this substring and
+ # scrapes the preview id out of its body, so our comment must never contain it.
+ case "$BODY" in
+ *preview.macro.com*)
+ echo "The iOS comment contains preview.macro.com, which would break web previews." >&2
+ exit 1
+ ;;
+ esac
+
+ COMMENT_ID="$(bot_comments | jq -r "select(.body | contains(\"$MARKER\")) | .id" | head -1)"
+ if [ -n "$COMMENT_ID" ]; then
+ gh api -X PATCH "repos/$REPO/issues/comments/$COMMENT_ID" -f "body=$BODY" >/dev/null
+ echo "Updated existing iOS preview comment"
+ else
+ gh api -X POST "repos/$REPO/issues/$PR_NUMBER/comments" -f "body=$BODY" >/dev/null
+ echo "Created iOS preview comment"
+ fi
+ shell: bash
+ env:
+ APPETIZE_API_TOKEN: ${{ secrets.APPETIZE_API_TOKEN }}
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ REPO: ${{ github.repository }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ CLEANUP: '1'
+concurrency:
+ group: ios-preview-${{ github.event.pull_request.number || github.ref }}
+ cancel-in-progress: true
diff --git a/apps/web/justfile b/apps/web/justfile
index 2a7351808c..62c998f47c 100644
--- a/apps/web/justfile
+++ b/apps/web/justfile
@@ -27,6 +27,34 @@ ios-build-no-update: ios-prepare
ios-build: ios-prepare
cd tauri/src-tauri && cargo tauri ios build --open
+# iOS: arm64 Simulator .app for the Appetize PR preview (the `ios_preview`
+# workflow). Simulator builds need no signing, and --no-default-features keeps
+# the bundle auto-updater off so a preview cannot quietly replace itself with
+# the production bundle.
+#
+# The frontend is built as a separate step rather than through Tauri's
+# beforeBuildCommand hook: the web and wasm builds want the nix toolchain,
+# while everything Xcode drives wants Apple's, and running both under one set
+# of compiler flags breaks whichever one loses. CI builds the frontend in a
+# clean nix shell and then calls this with prebuilt=true.
+#
+# Output: tauri/src-tauri/gen/apple/build/arm64-sim/macro.app
+ios-build-sim prebuilt="false": ios-prepare
+ #!/usr/bin/env bash
+ set -euo pipefail
+ if [ "{{prebuilt}}" != "true" ]; then just build-tauri-dev; fi
+ # frontendDist is restated because this override replaces the build table:
+ # dropping it silently produces an app with an empty assets/ and no
+ # index.html, which installs and launches to a black screen.
+ # Release, like every other iOS recipe here. A debug build links a ~240MB
+ # unoptimised binary, which a real Mac starts fine but Appetize's
+ # virtualised device does not — the preview launched to a black screen
+ # while the identical debug build rendered in CI's simulator.
+ cd tauri/src-tauri && cargo tauri ios build \
+ --target aarch64-sim --ci --no-sign -v \
+ --config '{"build":{"beforeBuildCommand":"","frontendDist":"../../dist"}}' \
+ -- --no-default-features
+
# iOS generated project prep. Keep native bundle metadata in sync with
# tauri.ios.conf.json, then prepare ignored local Swift dependencies.
ios-prepare:
@@ -110,6 +138,15 @@ build-tauri: build-wasm
bun scripts/cache-wasm/cli.ts package-dist --dist dist
bun scripts/cache-wasm/cli.ts remove-sidecar --dist dist
+# As build-tauri, but MODE=development so the bundle talks to dev.macro.com.
+# Used by `ios-build-sim`: a PR preview must never be wired to production.
+[private]
+build-tauri-dev: build-cache-wasm build-agent-fold-wasm
+ printf development > tauri/src-tauri/.macro-tauri-env
+ MODE=development NODE_ENV=production NODE_OPTIONS="{{node_heap}}" bun run --bun build
+ bun scripts/cache-wasm/cli.ts package-dist --dist dist
+ bun scripts/cache-wasm/cli.ts remove-sidecar --dist dist
+
# Build the bundle, zip it, and install it at
# tooling/native_app_server/app-archive.zip for the bundle
# updater test server. The server hashes the archive at request time, so no
diff --git a/rust-toolchain.toml b/rust-toolchain.toml
index 6181559ea1..36e8e39bef 100644
--- a/rust-toolchain.toml
+++ b/rust-toolchain.toml
@@ -14,4 +14,10 @@ targets = [
# whatever distro they have, so it must not link a host libc.
"aarch64-unknown-linux-musl",
"x86_64-unknown-linux-musl",
+ # The arm64 iOS Simulator slice for the Appetize PR preview
+ # (see `ios_preview`). It has to live here rather than in the workflow: the
+ # Nix dev shell's `rustup` is a shim whose `target add` silently exits 0, so
+ # installing it from a CI step would appear to succeed and then fail at link
+ # time.
+ "aarch64-apple-ios-sim",
]
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows.rs b/tooling/xtask/crates/xtask_workflows/src/workflows.rs
index a2716a9226..99de29f4d6 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows.rs
@@ -35,6 +35,7 @@ mod deploy_sync_service;
mod deploy_web_app;
mod docs_check;
mod ensure_daytona_snapshot;
+mod ios_preview;
mod path_validation;
mod publish_sdk;
mod pulumi_preview_pr;
@@ -248,6 +249,11 @@ const WORKFLOWS: &[WorkflowFile] = &[
file_name: "ensure_daytona_snapshot.yml",
render_yaml: || render_gh_workflow(ensure_daytona_snapshot::ensure_daytona_snapshot)(),
},
+ WorkflowFile {
+ slug: "ios_preview",
+ file_name: "ios_preview.yml",
+ render_yaml: || render_gh_workflow(ios_preview::ios_preview)(),
+ },
WorkflowFile {
slug: "push_local_stack_binaries",
file_name: "push_local_stack_binaries.yml",
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/build_dmg_on_tag.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/build_dmg_on_tag.rs
index 13c8a7447d..9ab469e5ec 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/build_dmg_on_tag.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/build_dmg_on_tag.rs
@@ -33,7 +33,7 @@ pub fn build_dmg_job(ref_expr: &str) -> Job {
.runs_on("macos-15")
.add_step(steps::checkout_ref(ref_expr))
.add_step(assert_arm64())
- .add_step(install_nix_macos())
+ .add_step(steps::install_nix_macos())
.add_step(configure_signing_identity())
.add_step(steps::derive_artifact_metadata(ref_expr))
.add_step(nix_build_dmg())
@@ -61,12 +61,6 @@ fn assert_arm64() -> Step<Run> {
.shell("bash")
}
-fn install_nix_macos() -> Step<Run> {
- Step::new("Install Nix")
- .run(include_str!("scripts/install_nix_macos.sh"))
- .shell("bash")
-}
-
fn configure_signing_identity() -> Step<Run> {
Step::new("Configure signing identity")
.run(include_str!("scripts/configure_signing_identity.sh"))
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/ios_preview.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/ios_preview.rs
new file mode 100644
index 0000000000..687323c1fb
--- /dev/null
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/ios_preview.rs
@@ -0,0 +1,152 @@
+//! `iOS Preview` — opt-in Appetize iPhone-simulator preview for a PR.
+//! Generated into `ios_preview.yml`.
+//!
+//! Add the `ios-preview` label to a PR and this builds an arm64 iOS
+//! **Simulator** `.app` (Appetize cannot stream a device `.ipa`), publishes it
+//! to an Appetize app owned by that PR, and posts a comment with one link per
+//! device size. Appetize's `autoplay=false` means the simulator boots — and
+//! bills — only when a reviewer clicks, so an unopened preview is free.
+//!
+//! `workflow_dispatch` builds without touching Appetize and leaves the `.app`
+//! as an artifact; the iOS build has never run in CI, so that is the cheap way
+//! to iterate on it without a PR or an API token.
+//!
+//! NOTE: like `deploy_preview`, this must NOT be a required status check — a
+//! PR should stay mergeable regardless of whether its preview built.
+
+use gh_workflow::{
+ Concurrency, Env, Event, Expression, Job, Level, Permissions, PullRequest, PullRequestType,
+ Run, Step, Use, Workflow, WorkflowDispatch,
+};
+
+use crate::workflows::{runners, steps, vars};
+
+const LABEL: &str = "ios-preview";
+
+/// Where `build_ios_simulator_app.sh` leaves the zipped bundle. The CI artifact
+/// and the bytes handed to Appetize are the same archive, so a preview that
+/// misbehaves can be reproduced in a local simulator from the artifact.
+const ARCHIVE_PATH: &str = "artifacts/macro-sim.zip";
+
+/// Build the workflow.
+pub fn ios_preview() -> Workflow {
+ Workflow::new("iOS Preview")
+ .on(Event::default()
+ .pull_request(pull_request_event())
+ .workflow_dispatch(WorkflowDispatch::default()))
+ .concurrency(
+ // `github.ref` keeps manual dispatches from all sharing one group.
+ Concurrency::new(Expression::new(
+ "ios-preview-${{ github.event.pull_request.number || github.ref }}",
+ ))
+ .cancel_in_progress(true),
+ )
+ .add_job("preview", preview())
+ .add_job("cleanup", cleanup())
+}
+
+fn pull_request_event() -> PullRequest {
+ PullRequest::default()
+ .add_type(PullRequestType::Labeled)
+ .add_type(PullRequestType::Synchronize)
+ .add_type(PullRequestType::Reopened)
+ .add_type(PullRequestType::Closed)
+}
+
+/// `labeled` fires for *every* label and `synchronize` fires regardless of
+/// labels, so both need the same membership test: is `ios-preview` on the PR
+/// right now? Reading it off the event payload avoids an API call, and means
+/// removing the label stops later pushes from building.
+fn labelled_and_open() -> String {
+ format!(
+ "github.event_name == 'workflow_dispatch' || (github.event.action != 'closed' \
+ && contains(github.event.pull_request.labels.*.name, '{LABEL}') \
+ && github.event.pull_request.draft == false)"
+ )
+}
+
+fn preview() -> Job {
+ Job::default()
+ .name("Build iOS simulator app and publish to Appetize")
+ .runs_on(runners::Runner::MacOsArm.to_string())
+ .cond(Expression::new(labelled_and_open()))
+ // A cold run — fresh nix store, no cached aarch64-apple-ios-sim
+ // artifacts — measured 11m15s. This leaves room for a slower runner
+ // without letting a genuinely hung xcodebuild sit for an hour.
+ .timeout_minutes(40u32)
+ .permissions(
+ Permissions::default()
+ .contents(Level::Read)
+ .pull_requests(Level::Write),
+ )
+ .add_step(steps::checkout(false, false))
+ .add_step(steps::install_nix_macos())
+ .add_step(build_simulator_app())
+ .add_step(upload_app_artifact().if_condition(Expression::new("always()")))
+ .add_step(publish_preview())
+}
+
+fn build_simulator_app() -> Step<Run> {
+ Step::new("Build iOS simulator app")
+ .run(include_str!("scripts/build_ios_simulator_app.sh"))
+ .shell("bash")
+ .id("build")
+}
+
+/// Kept for every run, including `workflow_dispatch`: when a preview misbehaves
+/// the first question is whether the bundle or the streaming is at fault, and
+/// this lets you drop the same archive into a local simulator. The launch
+/// screenshot and log archive come along on failures too — `if: always()` —
+/// since a build that dies at the smoke test is exactly when they are wanted.
+fn upload_app_artifact() -> Step<Use> {
+ steps::upload_artifact(
+ "macro-ios-simulator-app",
+ xtask_paths::runtime_path!("artifacts/*"),
+ )
+ .add_with(("if-no-files-found", "warn"))
+}
+
+/// Uploads the archive and posts the comment. The PR number, branch and SHA
+/// are attacker-controlled, so they reach the script through the environment —
+/// an env expansion can never become script text. Same convention as
+/// `cleanup_preview::get_preview_id`.
+fn publish_preview() -> Step<Run> {
+ publish_step("Publish to Appetize and comment")
+ .if_condition(Expression::new("github.event_name == 'pull_request'"))
+ .add_env(Env::new("ARCHIVE_PATH", ARCHIVE_PATH))
+ .add_env(Env::new("BRANCH", "${{ github.head_ref }}"))
+ .add_env(Env::new("SHA", "${{ github.event.pull_request.head.sha }}"))
+}
+
+/// The publish and cleanup steps run the same script; `CLEANUP` picks the mode.
+fn publish_step(name: &str) -> Step<Run> {
+ Step::new(name)
+ .run(include_str!("scripts/publish_ios_preview.sh"))
+ .shell("bash")
+ .add_env(Env::new("APPETIZE_API_TOKEN", vars::APPETIZE_API_TOKEN))
+ .add_env(Env::new("GH_TOKEN", "${{ secrets.GITHUB_TOKEN }}"))
+ .add_env(Env::new("REPO", "${{ github.repository }}"))
+ .add_env(Env::new(
+ "PR_NUMBER",
+ "${{ github.event.pull_request.number }}",
+ ))
+}
+
+/// Appetize apps outlive their PR unless something deletes them, and the key
+/// only exists in the preview comment — so this has to run while the PR (and
+/// its comments) are still readable.
+fn cleanup() -> Job {
+ Job::default()
+ .name("Delete the PR's Appetize app")
+ .runs_on(runners::Runner::TinyNoCache.to_string())
+ .cond(Expression::new(
+ "github.event_name == 'pull_request' && github.event.action == 'closed'",
+ ))
+ .permissions(
+ Permissions::default()
+ .contents(Level::Read)
+ .pull_requests(Level::Read),
+ )
+ .add_step(steps::checkout(false, false))
+ .add_step(publish_step("Delete Appetize app").add_env(Env::new("CLEANUP", "1")))
+}
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/build_ios_simulator_app.sh b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/build_ios_simulator_app.sh
new file mode 100644
index 0000000000..5a29114b29
--- /dev/null
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/build_ios_simulator_app.sh
@@ -0,0 +1,165 @@
+set -euo pipefail
+
+# Appetize streams iOS *Simulator* builds only (a device .ipa cannot be run), so
+# this produces an unsigned arm64 simulator .app rather than anything
+# installable on hardware.
+
+# Probe before the ~6 minutes of frontend build, so a runner missing its iOS
+# bits fails in seconds instead of at the very last step.
+#
+# The SDK is the check that matters, and it is not implied by the others: since
+# Xcode 16 platforms are downloaded separately, so `xcodebuild -version` and
+# even `simctl` can look healthy on a runner with no iPhoneSimulator SDK. Tauri
+# then dies reading SDKSettings.plist out of it.
+xcodebuild -version
+echo "Developer dir: $(xcode-select -p)"
+
+SIMULATOR_SDK="$(xcrun --sdk iphonesimulator --show-sdk-path 2>/dev/null || true)"
+if [ -z "$SIMULATOR_SDK" ] || [ ! -f "$SIMULATOR_SDK/SDKSettings.plist" ]; then
+ echo "No iPhoneSimulator SDK on this runner." >&2
+ echo "Install it with: xcodebuild -downloadPlatform iOS" >&2
+ echo "--- installed SDKs ---" >&2
+ xcodebuild -showsdks >&2 || true
+ echo "--- platforms ---" >&2
+ ls -1 "$(xcode-select -p)/Platforms" >&2 || true
+ exit 1
+fi
+echo "iPhoneSimulator SDK: $SIMULATOR_SDK"
+
+if ! xcrun simctl list runtimes --json | grep -q '"isAvailable" : true'; then
+ echo "No available iOS simulator runtime on this runner." >&2
+ echo "Install one with: xcodebuild -downloadPlatform iOS" >&2
+ xcrun simctl list runtimes >&2
+ exit 1
+fi
+
+# cargo-mobile2 locates the SDK by shelling out to `xcode-select -p`, which
+# returns $DEVELOPER_DIR whenever that is set — and nix's Darwin stdenv sets it
+# to nix's own Apple SDK, which has no Platforms/iPhoneSimulator.platform. So
+# the SDK is genuinely there for every command run out here, and genuinely
+# absent for anything run inside `nix develop`, which is what made tauri report
+# a bare NotFound for a file this script can see.
+#
+# Carry the real developer dir in under a name nix has no opinion about, and
+# restore DEVELOPER_DIR once inside the shell.
+MACRO_DEVELOPER_DIR="$(xcode-select -p)"
+export MACRO_DEVELOPER_DIR
+
+# cargo-tauri, bun, just, wasm-pack and the pinned toolchain (which carries
+# aarch64-apple-ios-sim, see rust-toolchain.toml) all come from the dev shell.
+# Phase 1 — the web and wasm build, in the dev shell exactly as it comes. It
+# needs nix's bun, wasm-pack and cc wrapper, and must not see Apple's.
+nix develop --command bash -euo pipefail -c '
+ bun install --frozen-lockfile
+ cd apps/web
+ just build-tauri-dev
+'
+
+# Phase 2 — everything Xcode drives, with Apple's toolchain in front.
+#
+# The dev shell ships its own: DEVELOPER_DIR points at nix's apple-sdk and
+# `xcodebuild` is the xcbuild reimplementation, which rejects real flags. But
+# swapping only those two desyncs nix's cc wrapper from its SDK and host
+# proc-macro links then fail on -liconv, so the compiler and linker have to
+# come from Apple too. Hence one dir at the front of PATH rather than a couple
+# of overrides — and hence phase 1 being a separate shell, since the wasm build
+# wants the nix cc it was configured against.
+nix develop --command bash -euo pipefail -c '
+ echo "before: DEVELOPER_DIR=$(xcode-select -p 2>&1), xcodebuild=$(command -v xcodebuild || echo none)"
+
+ export DEVELOPER_DIR="$MACRO_DEVELOPER_DIR"
+ APPLE_TOOLS="$(mktemp -d)"
+ for tool in xcodebuild xcrun xcode-select simctl actool ibtool plutil ditto \
+ clang clang++ cc c++ ld ar ranlib libtool lipo strip nm \
+ install_name_tool codesign dsymutil; do
+ [ -x "/usr/bin/$tool" ] && ln -sf "/usr/bin/$tool" "$APPLE_TOOLS/$tool"
+ done
+ export PATH="$APPLE_TOOLS:$PATH"
+
+ # nix'"'"'s wrapper flags name its own sysroot; Apple'"'"'s clang would either
+ # ignore them or trip over them.
+ unset NIX_CFLAGS_COMPILE NIX_LDFLAGS SDKROOT || true
+
+ echo "after: DEVELOPER_DIR=$(xcode-select -p 2>&1), xcodebuild=$(command -v xcodebuild), cc=$(command -v cc)"
+ xcodebuild -version
+
+ cd apps/web
+ # Positional: `prebuilt=true` would be passed as the literal argument
+ # "prebuilt=true", silently rebuilding the frontend a second time here.
+ just ios-build-sim true
+'
+
+APP="apps/web/tauri/src-tauri/gen/apple/build/arm64-sim/macro.app"
+if [ ! -d "$APP" ]; then
+ echo "Expected a simulator .app at $APP" >&2
+ find apps/web/tauri/src-tauri/gen/apple/build -maxdepth 3 -name '*.app' >&2 || true
+ exit 1
+fi
+
+# An iPhoneOS build would upload fine and then refuse to boot, so prove the SDK
+# before handing it to Appetize.
+if ! plutil -extract DTPlatformName raw "$APP/Info.plist" | grep -q iphonesimulator; then
+ echo "Built against the device SDK, not the simulator SDK:" >&2
+ plutil -extract DTPlatformName raw "$APP/Info.plist" >&2
+ exit 1
+fi
+
+# Everything above can pass on an app that launches to a black screen: the
+# frontend is embedded in the binary by generate_context!(), so there is no
+# file whose absence gives it away, and build/link/zip/upload all succeed
+# regardless. The only honest check is to run it.
+#
+# Boot the same simulator Appetize would, launch the app, and photograph it.
+# The screenshot is uploaded either way — it is the single most useful artifact
+# when a preview misbehaves.
+mkdir -p artifacts
+
+# Zip first, then smoke-test what comes *back out* of the zip. Appetize never
+# sees the build directory — it installs the archive — so testing $APP directly
+# would leave the round-trip itself unverified, which is precisely where a
+# preview can differ from a build that looked fine in CI.
+ditto -c -k --sequesterRsrc --keepParent "$APP" artifacts/macro-sim.zip
+rm -rf artifacts/roundtrip
+ditto -x -k artifacts/macro-sim.zip artifacts/roundtrip
+ROUNDTRIP_APP="artifacts/roundtrip/$(basename "$APP")"
+test -d "$ROUNDTRIP_APP" || { echo "zip round-trip produced no .app" >&2; exit 1; }
+
+DEVICE="$(xcrun simctl create ios-preview-smoke com.apple.CoreSimulator.SimDeviceType.iPhone-15-Pro)"
+trap 'xcrun simctl delete "$DEVICE" >/dev/null 2>&1 || true' EXIT
+xcrun simctl boot "$DEVICE"
+xcrun simctl bootstatus "$DEVICE" -b
+
+xcrun simctl install "$DEVICE" "$ROUNDTRIP_APP"
+xcrun simctl launch "$DEVICE" com.macro.app.prod
+
+# The webview needs a moment to load and paint before the shot is worth taking.
+sleep 25
+xcrun simctl io "$DEVICE" screenshot artifacts/launch.png
+
+# The app's own log, filtered by process name as AGENTS.md prescribes for
+# diagnosing iOS freezes. Kept whether or not the shot looks right — it is what
+# says *why* a screen was blank.
+xcrun simctl spawn "$DEVICE" log show --predicate 'process == "macro"' \
+ --last 3m --style compact >artifacts/launch.log 2>&1 || true
+echo "--- last 40 app log lines ---"
+tail -40 artifacts/launch.log || true
+
+if [ ! -f artifacts/launch.png ]; then
+ echo "simctl produced no screenshot." >&2
+ exit 1
+fi
+
+# A blank screen compresses to almost nothing, while any real UI carries
+# detail. This is a coarse signal deliberately: it cannot say the app is
+# correct, only that it painted something other than a void.
+SHOT_BYTES="$(stat -f%z artifacts/launch.png)"
+echo "Launch screenshot: ${SHOT_BYTES} bytes"
+if [ "$SHOT_BYTES" -lt 40000 ]; then
+ echo "The app launched to a blank screen (${SHOT_BYTES}-byte screenshot)." >&2
+ echo "See the launch.png artifact; the log archive is beside it." >&2
+ exit 1
+fi
+
+# The archive was built before the smoke test so the test could run against it;
+# drop the unpacked copy so it does not bloat the artifact upload.
+rm -rf artifacts/roundtrip
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/publish_ios_preview.sh b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/publish_ios_preview.sh
new file mode 100644
index 0000000000..53a50957b9
--- /dev/null
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/publish_ios_preview.sh
@@ -0,0 +1,92 @@
+set -euo pipefail
+
+# Publish the simulator build to Appetize and post the preview comment.
+#
+# The comment is the only store of the Appetize key: recovering it from there
+# is what lets a PR keep one app across pushes, and lets the cleanup job find
+# it on close. `gh` and `jq` both ship in Namespace's runner image (see
+# cancel_stuck_cloud_storage_deploys).
+
+MARKER='<!-- appetize-ios-preview -->'
+API='https://api.appetize.io/v1/apps'
+
+bot_comments() {
+ gh api "repos/$REPO/issues/$PR_NUMBER/comments" --paginate \
+ --jq '.[] | select(.user.type == "Bot")'
+}
+
+# Only our comment carries an appetize.io link, so this cannot pick up the web
+# preview's comment by accident.
+existing_key() {
+ bot_comments | jq -r 'select(.body | contains("appetize.io/app/")) | .body' |
+ grep -oE 'appetize\.io/app/[A-Za-z0-9_-]+' | head -1 | sed 's|.*/||'
+}
+
+PUBLIC_KEY="$(existing_key || true)"
+
+if [ "${CLEANUP:-0}" = "1" ]; then
+ if [ -z "$PUBLIC_KEY" ]; then
+ echo "No Appetize app recorded on this PR; nothing to clean."
+ exit 0
+ fi
+ # 404 means someone already removed it, which is the desired end state.
+ STATUS="$(curl -sS -o /dev/null -w '%{http_code}' -X DELETE "$API/$PUBLIC_KEY" \
+ -H "X-API-KEY: $APPETIZE_API_TOKEN")"
+ case "$STATUS" in
+ 2* | 404) echo "Deleted Appetize app $PUBLIC_KEY ($STATUS)" ;;
+ *) echo "Appetize delete failed with $STATUS" >&2; exit 1 ;;
+ esac
+ exit 0
+fi
+
+# Session caps, not access restrictions, are what keep a leaked link cheap: a
+# 3-minute idle timeout, a 30-minute ceiling and two concurrent sessions, on an
+# app that still needs a Macro login to show anything. `run=authenticated`
+# would demand an Appetize account and `referrerHostnamesRestricted` would
+# reject the click outright (GitHub sends no referrer on external links), so
+# both would lock out the reviewer this exists for.
+if [ -n "$PUBLIC_KEY" ]; then TARGET="$API/$PUBLIC_KEY"; else TARGET="$API"; fi
+RESPONSE="$(curl -sS -X POST "$TARGET" \
+ -H "X-API-KEY: $APPETIZE_API_TOKEN" \
+ -F "file=@$ARCHIVE_PATH" -F 'platform=ios' -F 'fileType=zip' \
+ -F 'timeout=180' -F 'timeLimit=1800' -F 'maxConcurrent=2' \
+ -F "note=PR #$PR_NUMBER $SHA $BRANCH" \
+ -F 'appPermissions.run=public' -F 'appPermissions.debugLog=public' \
+ -F 'appPermissions.networkIntercept=public' \
+ -F 'appPermissions.networkProxy=public')"
+
+PUBLIC_KEY="$(jq -er '.publicKey' <<<"$RESPONSE")" || {
+ echo "Appetize upload carried no publicKey: $RESPONSE" >&2
+ exit 1
+}
+echo "Appetize app $PUBLIC_KEY"
+
+link() { printf '[%s](https://appetize.io/app/%s?device=%s&autoplay=false)' "$1" "$PUBLIC_KEY" "$2"; }
+
+# `device` is a query parameter over one uploaded build, so extra sizes cost
+# nothing: no rebuild, no second upload. osVersion is deliberately omitted so
+# links keep working when Appetize retires a runtime.
+BODY="$MARKER
+**iOS preview** — \`$BRANCH\` @ \`${SHA:0:7}\`
+
+$(link 'iPhone 15 Pro' iphone15pro) · $(link 'iPhone 16 Pro Max' iphone16promax) · $(link 'iPad Pro 12.9"' ipadpro129inch5thgeneration)
+
+Boots on click; nothing streams until then. You will need to sign in inside the simulator."
+
+# get-or-create-id.ts finds the *web* preview comment by this substring and
+# scrapes the preview id out of its body, so our comment must never contain it.
+case "$BODY" in
+ *preview.macro.com*)
+ echo "The iOS comment contains preview.macro.com, which would break web previews." >&2
+ exit 1
+ ;;
+esac
+
+COMMENT_ID="$(bot_comments | jq -r "select(.body | contains(\"$MARKER\")) | .id" | head -1)"
+if [ -n "$COMMENT_ID" ]; then
+ gh api -X PATCH "repos/$REPO/issues/comments/$COMMENT_ID" -f "body=$BODY" >/dev/null
+ echo "Updated existing iOS preview comment"
+else
+ gh api -X POST "repos/$REPO/issues/$PR_NUMBER/comments" -f "body=$BODY" >/dev/null
+ echo "Created iOS preview comment"
+fi
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs
index 25744b386c..71af6b04ee 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/steps.rs
@@ -105,6 +105,15 @@ pub fn setup_rust_sccache() -> Step<Use> {
.add_with(("rust-cache", "false"))
}
+/// Install Nix on a macOS runner. The Linux [`setup_nix`] action doesn't apply
+/// there, so Apple jobs (DMG signing, the iOS simulator preview) install it
+/// with the same script instead.
+pub fn install_nix_macos() -> Step<Run> {
+ Step::new("Install Nix")
+ .run(include_str!("scripts/install_nix_macos.sh"))
+ .shell("bash")
+}
+
/// Install + initialise Nix on the runner. Namespace profiles don't ship Nix,
/// so this must run before [`setup_dev_shell`] (which shells out to `nix`). The
/// `/nix` cache volume mounted by [`mount_cache_volume`] keeps the store warm,
diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/vars.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/vars.rs
index 49fa63c6bf..49bf188de3 100644
--- a/tooling/xtask/crates/xtask_workflows/src/workflows/vars.rs
+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/vars.rs
@@ -11,6 +11,7 @@ macro_rules! secret {
};
}
+secret!(APPETIZE_API_TOKEN);
secret!(AWS_ACCESS_KEY);
secret!(AWS_SECRET_ACCESS_KEY);
secret!(CLOUDFLARE_API_TOKEN);