Repository navigation
AI-3583: swift CI builds swift_demo in its own DerivedData - #2225
Conversation
The core build and swift_demo shared one DerivedData. When the SPM cache
lacks the repositories, the core build resolves StreamWebRTC 156.0.7
while swift_demo pins 145.17.0, and swift_demo then fails on modules
built from the other version's headers ("has been modified since the
module file").
The SPM cache is no longer saved from a cancelled run or a failed core
build: run 45192193934 was cancelled mid-fetch and saved a partial cache
that every later main run restored as an exact hit. The key prefix
changes so main stops restoring that entry.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kanat
left a comment
There was a problem hiding this comment.
Reviewed #2225 at 30bb4eb merged onto main 1c87c73 (the base had not moved). CI: all 10 checks pass (swift attempt 1 cold cache, attempt 2 warm).
The cause checks out in the logs. Image and Xcode are the same in every job (xcode-27-arm64 20261104.0337.1). Run 45192193934 got a cache miss and was cancelled while fetching stream-core-swift. Its if: always() save then stored 363578892 B under spm-…2fb668. After that, the core build resolved StreamWebRTC 156.0.7 and swift_demo 145.17.0 into one DerivedData (job 137754895692, lines 432, 9553, 11942). Head attempt 1 passed with that same mix on a cold cache.
Nit R1.2 (PR body, "How it works"): "every later run: exact cache hit on that entry" holds only for runs keyed 2fb668 (45192548920). Runs 45201408392 and 45198669130 had key a531d6 and restored it by restore-key. Run 45201408392 then saved a new full spm-…a531d6 entry from a red run (job 137785661541, line 12031). Suggest "restored (exactly or by restore-key)".
Checked and sound:
- Separate DerivedData costs no extra compile work. The swift_demo build compiles the same 4158 units with shared and with separate DerivedData (jobs 137657996167 and 137810817020). It took 339 s before and 367-374 s now, against a 600 s limit.
- The builds run one after another, so nothing races on the shared checkouts folder. swift_demo switches to its pins only after
Test corehas finished. cache-hitis false on a restore-key hit (actions/cache v4 README), so the new primary key gets saved. That is what we want.- The
>-scalar parses: the save ran in attempt 1 and was skipped on the exact hit in attempt 2. - No
swiftpm-restore key can match anspm-entry. The partial2fb668entry has already been evicted, and the twospm-entries left are full ones (1.15 GB). actionlintreports only the existingxcode-27label.- Author's Q1 (core resolves whatever Package.swift allows) is not made worse by this PR. It goes to a ticket.
Verdict: request changes, for R1.1.
| - uses: actions/cache/save@v4 | ||
| if: always() && steps.packages.outcome == 'success' && steps.packages.outputs.cache-hit != 'true' | ||
| if: >- | ||
| !cancelled() && steps.packages.outcome == 'success' && steps.build-core.outcome == 'success' |
There was a problem hiding this comment.
[Should fix] R1.1 The save still runs after a failed or timed-out Build swift_demo. build-core succeeded and the run was not cancelled, so the condition is true.
That step does network work inside the cached $RUNNER_TEMP/spm on every cold or restore-key run. In job 137795720232 it runs Updating from on all six repos, then checks out 145.17.0 of stream-video-swift-webrtc, develop (2cdca0c) of stream-chat-swift and 1.54.0 of stream-video-swift (lines ~9483-9516). If it stops there (network error or the 10-min timeout), a half-updated tree is saved under the primary key. Later runs get an exact hit on it and never save over it. That is the same class as run 45192193934.
Today this costs a re-fetch on each run, not a red build, now that DerivedData is split. Still, the comment above claims a half-way fetch is never saved.
Fix: add id: build-demo to Build swift_demo and && steps.build-demo.outcome != 'failure' to this if. The save still happens when Test core failed and swift_demo was skipped after a complete core fetch. Extend the comment to match.
There was a problem hiding this comment.
Fixed in 156dd4c: Build swift_demo has id: build-demo, and the save if now requires steps.build-demo.outcome != 'failure' (comment extended). Check: actionlint clean on the changed lines; swift job green on this head. The failing-swift_demo path was not run (unverified).
Build swift_demo fetches and checks out its pins in the cached folder, so a failure there can leave it half updated under the primary key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kanat
left a comment
There was a problem hiding this comment.
Delta review of 156dd4c (previous 30bb4eb): GO. No new findings.
- R1.1 fixed.
id: build-demoand&& steps.build-demo.outcome != 'failure'in the saveif(client-sdks.yml:237, :244-251). A failed swift_demo build gives outcomefailure, so no save. A timed-out step isfailuretoo: actions/runner StepsRunner.cs setsTaskResult.Failedwhen the step's own timeout fires andCanceledonly for a job cancel, which!cancelled()already covers. After aTest corefailure the demo build isskipped(implicit success()), so the save still runs with a complete core fetch, as the comment says. No step uses continue-on-error, so outcome equals conclusion. Dropping the new term brings back the half-updated cache (checked by reading, not runnable). - R1.2 fixed. PR body now reads "restored (exactly or by restore-key)" and "the swift_demo build did not fail".
Unexercised paths: both branch runs (45204272824, 45213885637) were exact cache hits, so the save step was skipped and neither the save-on-miss path nor the failure path ran. The expression parsed, so the step id is wired. I accept this without another run: each term compares documented string values, the worst case is a missed or extra save and never a red job, and a rerun on the PR ref cannot reach a cache miss. The first main run after merge uses the new swiftpm- key prefix, so it is cold and exercises the save.
Checked on 156dd4c merged onto origin/main 108539d: clean merge, only client-sdks.yml differs, actionlint reports only the known xcode-27 label warning. gh pr checks: swift, dart, kotlin, changes, CodeQL and GitGuardian pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kanat
left a comment
There was a problem hiding this comment.
VERDICT: GO (delta round 3, head 5d4f12d, a merge of the previous head 156dd4c with main 284349e, which contains #2235)
R3.1 (conflict with #2235): fixed. The save step in .github/workflows/client-sdks.yml (lines 246-256) now reads:
!cancelled() && github.event_name == 'push' && steps.packages.outcome == 'success' && steps.build-core.outcome == 'success' && steps.build-demo.outcome != 'failure' && steps.packages.outputs.cache-hit != 'true'.
- #2235's push-only term and its comment lines are kept.
- This PR's terms are kept:
!cancelled(), build-core success, build-demo not failure,id: build-coreandid: build-demo, theswiftpm-key and restore-key, and the separateSwiftDemoDerivedData. - One comment gives both reasons. I checked the condition with a truth table: each of the six terms alone turns the save off, and a skipped swift_demo after a failed
Test corestill saves. - The PR body names the push-only term. The only difference from main is
client-sdks.yml. actionlint reports only the knownxcode-27runner-label warning.
Earlier findings: R1.1 and R1.2 stay fixed. The two PR commits are unchanged in range-diff.
CI on this head (read once, not waited): the swift job passed in 21m12s (run 45222728586). Core build, core tests and swift_demo build succeeded, and the cache save step was skipped. That skip has two reasons: the event was pull_request, and the restore was an exact hit. So this run does not show the push-only term by itself.
First push to main after merge: the swiftpm-...a531d6 entry exists only on refs/pull/2225/merge, which main cannot read. The old spm- entry on main has a different prefix. So the run is cold: no restore, cache-hit is not 'true'. If core builds and swift_demo does not fail, Run actions/cache/save@v4 runs and saves swiftpm-macOS-xcode27-a531d6... on refs/heads/main. Expect a run as long as the PR's cold attempt, with swift_demo about 6 minutes of its 10-minute limit. The next main run should show an exact hit and a skipped save. If the first run fails, nothing is saved and the next run is cold again.
Details: reviewer-3.md in the ledger.
kanat
left a comment
There was a problem hiding this comment.
[security R1] GO at 5d4f12d, no findings.
Checked for the swift job of client-sdks.yml:
- Cache scope. A
pull_requestrun, a fork's included, writes only to its ownrefs/pull/N/mergescope, and apull_request_targetrun gets read-only access to the default branch's scope (GitHub docs, "Restrictions for accessing a cache" and "Cache access for low-trust workflow triggers"). So a push to main restores only entries that main-scoped runs saved. The onlyswiftpm-entry is this PR's own, scoped to its merge ref, so main cannot restore it. Main's first run after the merge starts cold and saves the first main entry. - Rename.
spm-andswiftpm-are not prefixes of each other, so the new restore-key matches no old entry. No other workflow saves aswiftpm-key, and none setscache-mode. - Push-only save. It limits how much cache storage pull requests use. It is not a trust boundary: a pull request runs the workflow file from its own merge commit, and GitHub's ref scoping is what keeps PR entries away from main. Nothing here depends on it as a guard.
- Cached folder. It holds public package checkouts only.
actions/checkoutwrites its token into the workspace repo's local git config, outside$RUNNER_TEMP/spm. The job uses nosecrets.*, and its permissions arecontents: readandpull-requests: read. - Expressions. Every
${{ }}in the job is in awith:block, and each value comes fromrunner.*,hashFilesor a step output. Norun:step expands one.
## Why `client-sdks.yml` cancelled in-progress runs on every ref, main included. Since #2235 only a push to main saves the Swift package cache, and since #2225 a cancelled run saves nothing. An empty-cache swift job takes about 21 minutes, so when main gets a push faster than that, no run finishes and the cache is never saved. After #2225 merged, main runs 45229507749 (17:36 UTC) and 45232221644 (17:51 UTC) were cancelled by the next push; run 45233683223 finished and saved `swiftpm-…` on `refs/heads/main` (`gh api repos/GetStream/Agents/actions/caches?key=swiftpm-`). AI-3639. ## How it works `cancel-in-progress` is an expression, which GitHub allows ([docs](https://docs.github.com/en/actions/using-jobs/using-concurrency): "can specify `cancel-in-progress` as an expression", example `${{ !contains(github.ref, 'release/')}}`). It is now `github.event_name == 'pull_request'`. | Event | group | cancel-in-progress | Result | |---|---|---|---| | push to main | `…-push-main` | `false` | the running run finishes and saves the cache; a newer push waits as pending; a still newer push replaces the pending one (docs: "any existing `pending` job or workflow in the same concurrency group will be canceled") | | pull_request from branch X | `…-pull_request-X` | `true` | a new push cancels the older run of the same PR, as before | | pull_request from a fork's `main` | `…-pull_request-main` | `true` | its own group: it never cancels or replaces a run of main's push group (the event is in the key for this) | The workflow has only `push` and `pull_request` triggers (`client-sdks.yml:3-30`), so no other event reaches the expression. ## Validation - `actionlint .github/workflows/client-sdks.yml`: only the known `xcode-27` runner-label warning. - Other workflows: `run_tests.yml:68` saves a mypy cache only on push, and `ci-go`, `ci-python`, `ci-sdks`, `integration`, `python-versions`, `run_tests` cancel on main too. Not changed here; a cancelled mypy-cache run only costs a cold mypy cache, not 21 minutes. - Unverified until merge: that main runs now queue and the cache is saved. Watch the first pushes to main that touch the paths of this workflow: no run of `CI (client SDKs)` on main should end `cancelled`, and `gh api repos/GetStream/Agents/actions/caches?key=swiftpm-` should list an entry on `refs/heads/main`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Why
The
swiftjob of CI (client SDKs) fails at "Build swift_demo" onmainand on unrelated PRs since 14:17 today:StreamWebRTC.framework/Headers/RTCPeerConnection.h has been modified since the module file. Runner image and Xcode are the same in the last pass and the failures (xcode-27-arm64 20261104.0337.1, Xcode 27.0). What changed is the SPM cache.How it works
The last pass (run 45164527848) restored a 1.15 GB cache, and the core build reused the checkouts swift_demo had left (StreamWebRTC 145.17.0), so both builds agreed by luck.
$RUNNER_TEMP/SwiftDemoDerivedData!cancelled(), the core build succeeded and the swift_demo build did not fail, in place ofalways(); kept with #2235's push-only term (github.event_name == 'push')spm-->swiftpm-Sharing DerivedData saved no compile work: in the passing run swift_demo recompiled stream-core-swift, swift-protobuf, stream-video-swift and stream-chat-swift anyway, because it pins stream-chat-swift
develop(examples/voice_agents/swift_demo/app/SwiftDemo.xcodeproj/project.pbxproj:305-308). Both builds still share the checkout directory. Every build and test step stays.Validation
The swift_demo build took 6m14s and 6m07s of its 10-minute limit; it took 5m39s with the shared DerivedData in the last pass.
actionlintreports only the existingruns-on: xcode-27label it does not know.AI-3583
🤖 Generated with Claude Code