From ee3e57633391be0abc09c2cd2648a05faa421331 Mon Sep 17 00:00:00 2001 From: m96-chan Date: Mon, 14 Sep 2026 23:04:04 +0900 Subject: [PATCH 1/5] ci: stop spending 45 minutes proving a typo in a README is safe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every pull request runs the whole job: build libghostty-vt, three package test suites, an app build, the notices check, and a full UI pass on an iPhone and an iPad. The last of those alone is 31 minutes. A change to a Markdown file cannot affect any of it. It is gated per step rather than with `paths-ignore`, which is the obvious way and is wrong here. `ios` is a required status check on main and `enforce_admins` is on, so a workflow that never runs leaves that check pending forever — and a documentation-only pull request would become unmergeable by anybody, including the repository owner. A job that runs and skips its steps still reports `ios`, so branch protection is satisfied. What counts as unable to reach the build is deliberately narrow: Markdown anywhere, and `LICENSE` at the root. The app's sources are `App/`, its only extra bundled resource is the shortcut, and the notice generator reads `Package.resolved`, `project.yml`, `scripts/build_ghostty_vt.sh` and `scripts/third_party_licenses` — none of them Markdown. `LICENSE` at the root is not the file the app bundles; that is `App/Resources/ThirdPartyNotices.txt`, which is not Markdown and so still builds. A pull request touching one Markdown file and one source file builds, and so does an unexpectedly empty file list. The condition tests `grep -v`'s output rather than its exit status. On the machine this was written on, `/usr/bin/grep` is ugrep, where `grep -qv` returns 1 on input that `grep -v` reports with 0 — the `-q` form would have skipped a pull request that changed a README *and* a Swift file. The runner's own grep does not behave that way, so this would have been invisible in CI and wrong only for whoever ran it locally. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a003cf9..fe56790 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,23 +9,57 @@ concurrency: permissions: contents: read + pull-requests: read jobs: ios: runs-on: macos-latest steps: - uses: actions/checkout@v7 + # A documentation-only pull request cannot change what the app builds or how it behaves, + # and everything below takes about 45 minutes. + # + # Gated per step rather than with `paths-ignore` on purpose. `ios` is a required status + # check on main and `enforce_admins` is on, so a workflow that never runs leaves that + # check pending forever and the pull request becomes unmergeable by anybody, including an + # administrator. A job that runs and skips its steps still reports `ios` as successful. + - name: Decide whether this change can reach the build + id: scope + env: + GH_TOKEN: ${{ github.token }} + run: | + files=$(gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" \ + --paginate --jq '.[].filename') + printf 'Changed files:\n%s\n' "$files" + # Markdown and the licence at the repository root are not compiled, not bundled and + # not read by anything here: the app's sources are App/, its only extra resource is + # the shortcut, and the notice generator reads Package.resolved, project.yml, + # scripts/build_ghostty_vt.sh and scripts/third_party_licenses. Everything else + # builds, including an unexpectedly empty list. + # `grep -v` and not `grep -qv`: the two disagree on their exit status under at least + # one drop-in grep in the wild, so this tests the output rather than the status. + other=$(printf '%s\n' "$files" | grep -vE '\.md$|^LICENSE$' || true) + if [ -n "$files" ] && [ -z "$other" ]; then + echo "Documentation only. Skipping the build and tests." + echo "build=false" >> "$GITHUB_OUTPUT" + else + echo "build=true" >> "$GITHUB_OUTPUT" + fi - name: Show toolchain + if: steps.scope.outputs.build == 'true' run: | xcodebuild -version swift --version # Reading two JSON files, so it costs nothing and is worth failing on before a build. - name: Check package pins agree + if: steps.scope.outputs.build == 'true' run: make check-pins - name: Install Metal compiler component + if: steps.scope.outputs.build == 'true' run: xcodebuild -downloadComponent MetalToolchain - name: Restore libghostty-vt id: ghostty + if: steps.scope.outputs.build == 'true' uses: actions/cache@v4 with: path: build/vendor/ghostty-vt.xcframework @@ -34,24 +68,28 @@ jobs: # cache key is the build script, which carries the pinned commit, so this runs again only # when the pin moves. - name: Build libghostty-vt - if: steps.ghostty.outputs.cache-hit != 'true' + if: steps.scope.outputs.build == 'true' && steps.ghostty.outputs.cache-hit != 'true' run: | brew install zig scripts/build_ghostty_vt.sh # After the xcframework exists, because GhosttyEngine's tests link against it. - name: Test SSH, terminal and Ghostty packages + if: steps.scope.outputs.build == 'true' run: make test - name: Build iPhone and iPad app + if: steps.scope.outputs.build == 'true' run: make build # The bundled notices are what the store submission ships, and nothing else compares them # against the dependencies the app actually links. The checkouts are the ones make build # just resolved. - name: Check bundled third-party notices + if: steps.scope.outputs.build == 'true' run: python3 scripts/generate_third_party_notices.py --checkouts build/DerivedData/SourcePackages/checkouts --check # The iPad workspace tests are idiom-gated and skip on an iPhone, so they need a second # destination. A second test invocation rather than a job matrix: the app and its test # bundles are already built in this job, and the matrix would rebuild both from scratch. - name: Test app lifecycle and UI on iPhone and iPad + if: steps.scope.outputs.build == 'true' run: | # Both destinations boot a device, and a failing xcodebuild would otherwise leave them # running for the rest of the job, so the trap covers the failure path too. @@ -61,7 +99,7 @@ jobs: xcodebuild -project iOSSH.xcodeproj -scheme iOSSH -destination "platform=iOS Simulator,id=$udid" -derivedDataPath build/DerivedData -resultBundlePath "build/CI-$family.xcresult" -skipPackagePluginValidation -parallel-testing-enabled NO test done - name: Upload test results and screenshots - if: always() + if: always() && steps.scope.outputs.build == 'true' uses: actions/upload-artifact@v7 with: name: ios-test-results From 9959d9703e2dc94661472afd0356a9b4473a3f4a Mon Sep 17 00:00:00 2001 From: m96-chan Date: Mon, 14 Sep 2026 23:15:35 +0900 Subject: [PATCH 2/5] ci: build once instead of three times, and let the ghostty cache be reachable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Measured on #34's run — 44 minutes, of which the two test destinations were 31. Splitting that 31 by log timestamps says half of it never ran a test: iPhone prepare simulator 3m31s, build and install ~5m, tests 5m03s iPad prepare simulator 3m31s, build and install 3m45s, tests 9m53s The rebuild before the iPad's first test is the part worth explaining. A destination change gives Xcode a different build description, so `generic/platform=iOS Simulator` for `make build`, then the iPhone, then the iPad each built from scratch into the same derived data — three builds of the same sources, two of which produced nothing the previous one had not. So the app and its test bundles are built once, for both destinations, with `build-for-testing`, and each idiom runs `test-without-building` against it. `make build`'s generic destination goes with it: the two concrete simulators cover the same compilation, and what they do not cover is a simulator architecture no runner has. The iPad step now runs even when the iPhone step failed. The build is already paid for by then, and one run that reports both idioms is one round trip rather than two, which is the thing that actually costs time when a pull request is waiting. Separately, every pull request was spending about four minutes installing Zig and compiling libghostty-vt at a pin that has not moved in weeks. Not a key problem — a scoping one. `ci.yml` only runs on `pull_request`, so the only caches it ever wrote were under `refs/pull/N/merge`, which no sibling pull request can read: five entries existed, under five different pull requests, all under the same key, none of them reachable by anyone. cache-ghostty.yml writes one from a push to main, where every pull request opened against main can restore it. Untouched on purpose: the two `scripts/prepare_simulator.sh` calls are 3m31s each and still sequential. Preparing them concurrently means two processes writing `com.apple.iphonesimulator DevicePreferences` at once, and that preference is the one keeping the hardware keyboard away from the test that #32 added. Seven minutes is not worth reintroducing that. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/cache-ghostty.yml | 39 +++++++++++++++++++ .github/workflows/ci.yml | 60 ++++++++++++++++++++++------- 2 files changed, 85 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/cache-ghostty.yml diff --git a/.github/workflows/cache-ghostty.yml b/.github/workflows/cache-ghostty.yml new file mode 100644 index 0000000..44aab68 --- /dev/null +++ b/.github/workflows/cache-ghostty.yml @@ -0,0 +1,39 @@ +name: Cache libghostty-vt + +# Every pull request was rebuilding libghostty-vt from source — installing Zig and compiling +# the pinned revision, about four minutes — even though the pin had not moved in weeks. +# +# The reason is cache scoping, not the cache key. `ci.yml` only runs on `pull_request`, so the +# only caches it ever wrote were in `refs/pull/N/merge` scopes, which no sibling pull request +# can read. Five entries existed under five different pull requests, all under the same key, +# none of them reachable. A cache written from a push to main is readable by every pull request +# opened against it, which is what this exists to produce. +# +# It runs on every push to main rather than only when the build script changes, because the +# first one has to happen before there is anything to hit. Once the cache is warm this job is +# a checkout and a cache lookup. + +on: + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + +jobs: + xcframework: + runs-on: macos-latest + steps: + - uses: actions/checkout@v7 + - name: Restore libghostty-vt + id: ghostty + uses: actions/cache@v4 + with: + path: build/vendor/ghostty-vt.xcframework + key: ghostty-vt-${{ hashFiles('scripts/build_ghostty_vt.sh') }} + - name: Build libghostty-vt + if: steps.ghostty.outputs.cache-hit != 'true' + run: | + brew install zig + scripts/build_ghostty_vt.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe56790..584210a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,28 +76,60 @@ jobs: - name: Test SSH, terminal and Ghostty packages if: steps.scope.outputs.build == 'true' run: make test - - name: Build iPhone and iPad app + # Built once for both destinations. Splitting it was costing two extra builds: a + # destination change gives Xcode a different build description, so `generic/platform=iOS + # Simulator` and then each concrete simulator each rebuilt from scratch. On the last full + # run that was 3m56s for the app and another 3m45s before the iPad ran its first test, + # neither of which produced anything the previous build had not. + # + # The `generic` destination is gone with it. These two cover the same compilation; what + # they do not cover is a simulator architecture no runner has, which is not a thing this + # project ships to. + - name: Prepare the iPhone and iPad simulators + id: simulators + if: steps.scope.outputs.build == 'true' + run: | + for family in iPhone iPad; do + udid=$(scripts/prepare_simulator.sh "$family") + echo "$family=$udid" >> "$GITHUB_OUTPUT" + done + - name: Build the app and its test bundles for both idioms if: steps.scope.outputs.build == 'true' - run: make build + run: | + xcodebuild -project iOSSH.xcodeproj -scheme iOSSH \ + -destination "platform=iOS Simulator,id=${{ steps.simulators.outputs.iPhone }}" \ + -destination "platform=iOS Simulator,id=${{ steps.simulators.outputs.iPad }}" \ + -derivedDataPath build/DerivedData -skipPackagePluginValidation build-for-testing # The bundled notices are what the store submission ships, and nothing else compares them - # against the dependencies the app actually links. The checkouts are the ones make build - # just resolved. + # against the dependencies the app actually links. The checkouts are the ones the build + # above just resolved, and this runs before the tests so a stale notice is not thirty + # minutes away from being reported. - name: Check bundled third-party notices if: steps.scope.outputs.build == 'true' run: python3 scripts/generate_third_party_notices.py --checkouts build/DerivedData/SourcePackages/checkouts --check # The iPad workspace tests are idiom-gated and skip on an iPhone, so they need a second - # destination. A second test invocation rather than a job matrix: the app and its test - # bundles are already built in this job, and the matrix would rebuild both from scratch. - - name: Test app lifecycle and UI on iPhone and iPad + # destination. Both reuse the build above rather than making their own. + - name: Test app lifecycle and UI on iPhone if: steps.scope.outputs.build == 'true' run: | - # Both destinations boot a device, and a failing xcodebuild would otherwise leave them - # running for the rest of the job, so the trap covers the failure path too. - trap 'xcrun simctl shutdown all >/dev/null 2>&1 || true' EXIT - for family in iPhone iPad; do - udid=$(scripts/prepare_simulator.sh "$family") - xcodebuild -project iOSSH.xcodeproj -scheme iOSSH -destination "platform=iOS Simulator,id=$udid" -derivedDataPath build/DerivedData -resultBundlePath "build/CI-$family.xcresult" -skipPackagePluginValidation -parallel-testing-enabled NO test - done + xcodebuild -project iOSSH.xcodeproj -scheme iOSSH \ + -destination "platform=iOS Simulator,id=${{ steps.simulators.outputs.iPhone }}" \ + -derivedDataPath build/DerivedData -resultBundlePath build/CI-iPhone.xcresult \ + -skipPackagePluginValidation -parallel-testing-enabled NO test-without-building + # Runs even when the iPhone failed: the build is already paid for, and one run that + # reports both idioms is one round trip instead of two. + - name: Test app lifecycle and UI on iPad + if: always() && steps.scope.outputs.build == 'true' + run: | + xcodebuild -project iOSSH.xcodeproj -scheme iOSSH \ + -destination "platform=iOS Simulator,id=${{ steps.simulators.outputs.iPad }}" \ + -derivedDataPath build/DerivedData -resultBundlePath build/CI-iPad.xcresult \ + -skipPackagePluginValidation -parallel-testing-enabled NO test-without-building + # Both destinations stay booted across the steps above, so this is what shuts them down — + # including when a step above failed and left them running. + - name: Shut the simulators down + if: always() + run: xcrun simctl shutdown all >/dev/null 2>&1 || true - name: Upload test results and screenshots if: always() && steps.scope.outputs.build == 'true' uses: actions/upload-artifact@v7 From 92cf50a8b7e379e4734ae2a16bd468a8c2d8f3e1 Mon Sep 17 00:00:00 2001 From: m96-chan Date: Mon, 14 Sep 2026 23:22:32 +0900 Subject: [PATCH 3/5] ci: run the two idioms at the same time instead of one after the other MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The iPhone and iPad passes were sequential and were half the run on their own. They share nothing except the build, so they are now a matrix of two jobs, with `fail-fast: false` so one idiom failing still reports the other — one round trip rather than two, which is what actually costs time when a pull request is waiting. Four jobs now: scope the docs-only decision, on Linux, seconds packages the three package suites, which never needed the app build build-for-testing once, the notices check, and the bundles test iPhone and iPad in parallel, test-without-building `packages` no longer waits behind an app build it does not use, so a package failure surfaces in about six minutes rather than ten. The build is `generic/platform=iOS Simulator` again, which is right for this shape: `build-for-testing` produces one .xctestrun both idioms consume, and the test jobs never build, so no destination gives Xcode a reason to rebuild. Both runners use the same working directory, so the .xctestrun's paths resolve on the machine that downloads it. `ios` is kept as a job whose only purpose is to carry the verdict. It is the required status check on main and `enforce_admins` is on, so exactly one check has to report under that name however the work is arranged — and it has to report on a documentation-only pull request too, where every other job is skipped. A required check that never reports leaves the pull request unmergeable by anybody, including an administrator. Simulator preparation starts in the background before the artifact download rather than after it, because it is mostly waiting for a boot. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/ci.yml | 198 +++++++++++++++++++++++++-------------- 1 file changed, 126 insertions(+), 72 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 584210a..f0ba7e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,17 +12,14 @@ permissions: pull-requests: read jobs: - ios: - runs-on: macos-latest + # A documentation-only pull request cannot change what the app builds or how it behaves, and + # everything below is half an hour. This is its own job so the expensive ones can name it in + # `if:`, and it runs on Linux because it only reads the pull request's file list. + scope: + runs-on: ubuntu-latest + outputs: + build: ${{ steps.scope.outputs.build }} steps: - - uses: actions/checkout@v7 - # A documentation-only pull request cannot change what the app builds or how it behaves, - # and everything below takes about 45 minutes. - # - # Gated per step rather than with `paths-ignore` on purpose. `ios` is a required status - # check on main and `enforce_admins` is on, so a workflow that never runs leaves that - # check pending forever and the pull request becomes unmergeable by anybody, including an - # administrator. A job that runs and skips its steps still reports `ios` as successful. - name: Decide whether this change can reach the build id: scope env: @@ -32,10 +29,13 @@ jobs: --paginate --jq '.[].filename') printf 'Changed files:\n%s\n' "$files" # Markdown and the licence at the repository root are not compiled, not bundled and - # not read by anything here: the app's sources are App/, its only extra resource is - # the shortcut, and the notice generator reads Package.resolved, project.yml, - # scripts/build_ghostty_vt.sh and scripts/third_party_licenses. Everything else - # builds, including an unexpectedly empty list. + # not read by anything here: the app's sources are App/, its only extra bundled + # resource is the shortcut, and the notice generator reads Package.resolved, + # project.yml, scripts/build_ghostty_vt.sh and scripts/third_party_licenses. The file + # the app actually ships its notices in is App/Resources/ThirdPartyNotices.txt, which + # is not Markdown and so still builds. Everything else builds, including an + # unexpectedly empty list. + # # `grep -v` and not `grep -qv`: the two disagree on their exit status under at least # one drop-in grep in the wild, so this tests the output rather than the status. other=$(printf '%s\n' "$files" | grep -vE '\.md$|^LICENSE$' || true) @@ -45,96 +45,150 @@ jobs: else echo "build=true" >> "$GITHUB_OUTPUT" fi + + # The three package suites do not need the app, so they do not wait behind its build. + packages: + needs: scope + if: needs.scope.outputs.build == 'true' + runs-on: macos-latest + steps: + - uses: actions/checkout@v7 - name: Show toolchain - if: steps.scope.outputs.build == 'true' run: | xcodebuild -version swift --version # Reading two JSON files, so it costs nothing and is worth failing on before a build. - name: Check package pins agree - if: steps.scope.outputs.build == 'true' run: make check-pins - - name: Install Metal compiler component - if: steps.scope.outputs.build == 'true' - run: xcodebuild -downloadComponent MetalToolchain - name: Restore libghostty-vt id: ghostty - if: steps.scope.outputs.build == 'true' uses: actions/cache@v4 with: path: build/vendor/ghostty-vt.xcframework key: ghostty-vt-${{ hashFiles('scripts/build_ghostty_vt.sh') }} - # The app links the #10 trial engine, whose xcframework is not in the repository. The - # cache key is the build script, which carries the pinned commit, so this runs again only - # when the pin moves. + # The app links the #10 trial engine, whose xcframework is not in the repository. See + # cache-ghostty.yml for why a pull request can now expect to restore rather than build it. - name: Build libghostty-vt - if: steps.scope.outputs.build == 'true' && steps.ghostty.outputs.cache-hit != 'true' + if: steps.ghostty.outputs.cache-hit != 'true' run: | brew install zig scripts/build_ghostty_vt.sh # After the xcframework exists, because GhosttyEngine's tests link against it. - name: Test SSH, terminal and Ghostty packages - if: steps.scope.outputs.build == 'true' run: make test - # Built once for both destinations. Splitting it was costing two extra builds: a - # destination change gives Xcode a different build description, so `generic/platform=iOS - # Simulator` and then each concrete simulator each rebuilt from scratch. On the last full - # run that was 3m56s for the app and another 3m45s before the iPad ran its first test, - # neither of which produced anything the previous build had not. - # - # The `generic` destination is gone with it. These two cover the same compilation; what - # they do not cover is a simulator architecture no runner has, which is not a thing this - # project ships to. - - name: Prepare the iPhone and iPad simulators - id: simulators - if: steps.scope.outputs.build == 'true' + + # Built once, for the generic simulator, and handed to both idioms. Building per destination + # was the expensive mistake: a destination change gives Xcode a different build description, + # so the app build and each idiom's test run each rebuilt the same sources from scratch. + build: + needs: scope + if: needs.scope.outputs.build == 'true' + runs-on: macos-latest + steps: + - uses: actions/checkout@v7 + - name: Install Metal compiler component + run: xcodebuild -downloadComponent MetalToolchain + - name: Restore libghostty-vt + id: ghostty + uses: actions/cache@v4 + with: + path: build/vendor/ghostty-vt.xcframework + key: ghostty-vt-${{ hashFiles('scripts/build_ghostty_vt.sh') }} + - name: Build libghostty-vt + if: steps.ghostty.outputs.cache-hit != 'true' run: | - for family in iPhone iPad; do - udid=$(scripts/prepare_simulator.sh "$family") - echo "$family=$udid" >> "$GITHUB_OUTPUT" - done - - name: Build the app and its test bundles for both idioms - if: steps.scope.outputs.build == 'true' + brew install zig + scripts/build_ghostty_vt.sh + - name: Build the app and its test bundles run: | xcodebuild -project iOSSH.xcodeproj -scheme iOSSH \ - -destination "platform=iOS Simulator,id=${{ steps.simulators.outputs.iPhone }}" \ - -destination "platform=iOS Simulator,id=${{ steps.simulators.outputs.iPad }}" \ + -destination 'generic/platform=iOS Simulator' \ -derivedDataPath build/DerivedData -skipPackagePluginValidation build-for-testing # The bundled notices are what the store submission ships, and nothing else compares them # against the dependencies the app actually links. The checkouts are the ones the build - # above just resolved, and this runs before the tests so a stale notice is not thirty - # minutes away from being reported. + # above just resolved, and reporting a stale notice here rather than after the tests keeps + # it fifteen minutes closer to the person who caused it. - name: Check bundled third-party notices - if: steps.scope.outputs.build == 'true' run: python3 scripts/generate_third_party_notices.py --checkouts build/DerivedData/SourcePackages/checkouts --check - # The iPad workspace tests are idiom-gated and skip on an iPhone, so they need a second - # destination. Both reuse the build above rather than making their own. - - name: Test app lifecycle and UI on iPhone - if: steps.scope.outputs.build == 'true' + # Both runners use the same working directory, so the .xctestrun's paths resolve on the + # machine that downloads this. + - name: Upload the built test bundles + uses: actions/upload-artifact@v7 + with: + name: test-bundles + path: | + build/DerivedData/Build/Products/*.xctestrun + build/DerivedData/Build/Products/Debug-iphonesimulator + retention-days: 1 + compression-level: 1 + + # The iPad workspace tests are idiom-gated and skip on an iPhone, so both idioms have to run. + # In parallel: they share nothing but the build above, and run sequentially they were half an + # hour on their own. `fail-fast: false` so one idiom failing still reports the other, which is + # the difference between one round trip and two. + test: + needs: [scope, build] + if: needs.scope.outputs.build == 'true' + runs-on: macos-latest + strategy: + fail-fast: false + matrix: + family: [iPhone, iPad] + steps: + - uses: actions/checkout@v7 + # Preparing a simulator is mostly waiting for it to boot, so it starts before the download + # rather than after it. An iPad left with a hardware keyboard attached, or with AutoFill + # on, fails the keyboard test and adds a 60s wait to every later interaction. + - name: Start preparing the ${{ matrix.family }} simulator run: | - xcodebuild -project iOSSH.xcodeproj -scheme iOSSH \ - -destination "platform=iOS Simulator,id=${{ steps.simulators.outputs.iPhone }}" \ - -derivedDataPath build/DerivedData -resultBundlePath build/CI-iPhone.xcresult \ - -skipPackagePluginValidation -parallel-testing-enabled NO test-without-building - # Runs even when the iPhone failed: the build is already paid for, and one run that - # reports both idioms is one round trip instead of two. - - name: Test app lifecycle and UI on iPad - if: always() && steps.scope.outputs.build == 'true' + scripts/prepare_simulator.sh '${{ matrix.family }}' > simulator-udid.txt & + echo $! > simulator-prepare.pid + - name: Download the built test bundles + uses: actions/download-artifact@v7 + with: + name: test-bundles + path: build/DerivedData/Build/Products + - name: Wait for the simulator + id: simulator run: | - xcodebuild -project iOSSH.xcodeproj -scheme iOSSH \ - -destination "platform=iOS Simulator,id=${{ steps.simulators.outputs.iPad }}" \ - -derivedDataPath build/DerivedData -resultBundlePath build/CI-iPad.xcresult \ - -skipPackagePluginValidation -parallel-testing-enabled NO test-without-building - # Both destinations stay booted across the steps above, so this is what shuts them down — - # including when a step above failed and left them running. - - name: Shut the simulators down - if: always() - run: xcrun simctl shutdown all >/dev/null 2>&1 || true + wait "$(cat simulator-prepare.pid)" + udid=$(cat simulator-udid.txt) + test -n "$udid" + echo "udid=$udid" >> "$GITHUB_OUTPUT" + - name: Test app lifecycle and UI on the ${{ matrix.family }} + run: | + trap 'xcrun simctl shutdown all >/dev/null 2>&1 || true' EXIT + xctestrun=$(echo build/DerivedData/Build/Products/*.xctestrun) + xcodebuild -xctestrun "$xctestrun" \ + -destination "platform=iOS Simulator,id=${{ steps.simulator.outputs.udid }}" \ + -resultBundlePath "build/CI-${{ matrix.family }}.xcresult" \ + -parallel-testing-enabled NO test-without-building - name: Upload test results and screenshots - if: always() && steps.scope.outputs.build == 'true' + if: always() uses: actions/upload-artifact@v7 with: - name: ios-test-results - path: build/CI-*.xcresult + name: ios-test-results-${{ matrix.family }} + path: build/CI-${{ matrix.family }}.xcresult if-no-files-found: ignore retention-days: 7 + + # `ios` is the required status check on main and `enforce_admins` is on, so one check has to + # carry the whole workflow's verdict under that name however the jobs above are arranged. It + # also has to report on a documentation-only pull request, where everything above is skipped: + # a required check that never reports leaves the pull request unmergeable by anybody. + ios: + needs: [scope, packages, build, test] + if: always() + runs-on: ubuntu-latest + steps: + - name: Report the verdict + run: | + for result in '${{ needs.scope.result }}' '${{ needs.packages.result }}' \ + '${{ needs.build.result }}' '${{ needs.test.result }}'; do + echo "$result" + case "$result" in + success|skipped) ;; + *) echo "A job this check stands for did not pass."; exit 1 ;; + esac + done + echo "All jobs passed or were skipped." From 02a1a21f0b268e28ea4682662257ad4f6d15ab50 Mon Sep 17 00:00:00 2001 From: m96-chan Date: Mon, 14 Sep 2026 23:39:21 +0900 Subject: [PATCH 4/5] fix(ci): build the test bundles against a concrete simulator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `generic/platform=iOS Simulator` cannot build AppTests: it reaches into the app with `@testable import iOSSH`, and the generic destination builds for more than one architecture, which leaves the test host's module unresolvable — "unable to resolve module dependency: 'iOSSH'". The simulator picked here is neither booted nor the device the tests run on. Every simulator on a runner is the same architecture, so the one .xctestrun this produces still runs on both idioms. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/ci.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0ba7e8..3a9a749 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -99,10 +99,22 @@ jobs: run: | brew install zig scripts/build_ghostty_vt.sh + # A concrete simulator, not `generic/platform=iOS Simulator`. AppTests reaches into the + # app with `@testable import iOSSH`, and against the generic destination that fails with + # "unable to resolve module dependency: 'iOSSH'" — the generic destination builds for more + # than one architecture and leaves the test host's module unresolvable. + # + # It is not booted and it is not the device the tests run on: every simulator on a runner + # is the same architecture, so one .xctestrun built here runs on both idioms. + - name: Pick a simulator to build against + id: destination + run: | + udid=$(xcrun simctl list devices available --json | python3 -c 'import json,sys; devices=json.load(sys.stdin)["devices"]; print(next(d["udid"] for runtime in sorted(devices, reverse=True) if "iOS" in runtime for d in devices[runtime] if d["isAvailable"] and d["name"].startswith("iPhone")))') + echo "udid=$udid" >> "$GITHUB_OUTPUT" - name: Build the app and its test bundles run: | xcodebuild -project iOSSH.xcodeproj -scheme iOSSH \ - -destination 'generic/platform=iOS Simulator' \ + -destination "platform=iOS Simulator,id=${{ steps.destination.outputs.udid }}" \ -derivedDataPath build/DerivedData -skipPackagePluginValidation build-for-testing # The bundled notices are what the store submission ships, and nothing else compares them # against the dependencies the app actually links. The checkouts are the ones the build From ff4797f612b31eaaee5eaec7ab141b42e2bf56d2 Mon Sep 17 00:00:00 2001 From: m96-chan Date: Tue, 15 Sep 2026 00:01:28 +0900 Subject: [PATCH 5/5] fix(ci): prepare the simulator in its own step instead of across two Each `run:` step is a separate process, so backgrounding the preparation in one step and waiting for it in the next hands `wait` a pid that is not its child: "wait: pid 1666 is not a child of this shell", exit 127, on both idioms. The overlap it was buying was a minute or two of boot against the artifact download. Not worth carrying a process across steps for, so it runs in order. Co-Authored-By: Claude Opus 5 (1M context) --- .github/workflows/ci.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a9a749..d96fe50 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -148,23 +148,22 @@ jobs: family: [iPhone, iPad] steps: - uses: actions/checkout@v7 - # Preparing a simulator is mostly waiting for it to boot, so it starts before the download - # rather than after it. An iPad left with a hardware keyboard attached, or with AutoFill - # on, fails the keyboard test and adds a 60s wait to every later interaction. - - name: Start preparing the ${{ matrix.family }} simulator - run: | - scripts/prepare_simulator.sh '${{ matrix.family }}' > simulator-udid.txt & - echo $! > simulator-prepare.pid - name: Download the built test bundles uses: actions/download-artifact@v7 with: name: test-bundles path: build/DerivedData/Build/Products - - name: Wait for the simulator + # Synchronously, in its own step. Backgrounding this to overlap it with the download above + # cannot work: each `run:` is a separate process, so the later step's `wait` is handed a + # pid that is not its child. The overlap was worth a minute or two and is not worth + # carrying a process across steps for. + # + # An iPad left with a hardware keyboard attached, or with AutoFill on, fails the keyboard + # test and adds a 60s wait to every later interaction, which is what this sets. + - name: Prepare the ${{ matrix.family }} simulator id: simulator run: | - wait "$(cat simulator-prepare.pid)" - udid=$(cat simulator-udid.txt) + udid=$(scripts/prepare_simulator.sh '${{ matrix.family }}') test -n "$udid" echo "udid=$udid" >> "$GITHUB_OUTPUT" - name: Test app lifecycle and UI on the ${{ matrix.family }}