chore: untrack generated Rust and iOS outputs, generate on demand - #551
chore: untrack generated Rust and iOS outputs, generate on demand#551pgherveou wants to merge 8 commits into
Conversation
f514787 to
7c5ac3a
Compare
…pi-server The untracking commits fixed only ci.yml's rust job. truapi-server declares `pub mod generated;` unconditionally, so every other job that builds it fails at parse time: ios-bindings, ios-swift, ci-android, release-android and release.yml's publish-ios. Also: - ios-swift never ran sync-bindings.sh or the js/container build, so the package had no Swift sources and no .copy resource to resolve. - the ios-changes filter keyed on an ios/ diff that generated bindings no longer produce; it now names the crates the bindings come from. - release.yml's post-rebuild `git diff --exit-code` could no longer fail. - .gitignore's truapi*.swift glob matched the hand-written TrUAPIHost.swift under core.ignorecase, which git sets by default on macOS. - check-generated is a prerequisite of every target that compiles the crate, names the missing file, and covers mod.rs and wire_table.rs. - sync-bindings.sh --check and provider-swift-check compared against files that are no longer committed.
SwiftPM resolves source targets from the git checkout, so a branch that ignores the generated bindings cannot be consumed. A release is now two artifacts: the xcframework as a release asset, and a plain semver tag whose commit carries the generated sources plus a manifest pointing at that asset. Consumers keep the same URL and the same exact() pin. publish-ios moves into release-ios.yml so it is callable from release.yml and dispatchable for a pre-release, matching release-android.yml. The tag is verified by cloning and building it before the push. tag-release.sh reads the required paths out of Package.swift so the file set cannot drift from what SwiftPM looks for. Also fixes the manifest guard: 9b708fb replaced 'let useLocalBinary = false' with the ProcessInfo form, but release.yml still grepped for the literal, so the follow-up commit step could never pass.
Also compiles the ios-swift CI gate from a clean clone of the tag rather than in place, so a generated file the tag does not carry fails the PR instead of the next consumer.
7c5ac3a to
317901b
Compare
| # A rerun of the release finds the tag already cut. Accept it when it records | ||
| # the same manifest, so the caller can push it again as a no-op. | ||
| if git rev-parse -q --verify "refs/tags/${VERSION}" >/dev/null 2>&1; then | ||
| if git diff --quiet "refs/tags/${VERSION}" -- Package.swift; then |
There was a problem hiding this comment.
The rerun check only diffs Package.swift, but the whole reason this tag exists is to carry the generated sources. If someone cuts the tag, then regenerates bindings and reruns the release at the same version, this exits zero and says nothing to do, and consumers stay pinned to the old bindings. Can we compare the manifest paths' contents against the tag too, and error when they differ?
| exit 65 | ||
| fi | ||
|
|
||
| git commit -q -m "release(ios): TrUAPIHost ${VERSION}" |
There was a problem hiding this comment.
This dies for anyone with commit signing on globally, it fails on my machine. CI is fine because there's no signing config there, but the manual fallback is the case that matters. Worth passing --no-gpg-sign, or -c commit.gpgsign=false.
TarikGul
left a comment
There was a problem hiding this comment.
Looks good, just two small nits
Generated outputs are not tracked. The Rust dispatcher, wire table and wasm bridge, the UniFFI Swift bindings, the FFI headers and modulemaps, and the lockdown container bundle are git-ignored build outputs produced from the Rust crates on demand.
Producing the outputs
scripts/codegen.shemits the Rust outputs, including themod.rsthattruapi-serverdeclares withpub mod generated;.make setupruns it,make codegenregenerates on its own. Every Make target that compilestruapi-serverdepends oncheck-generated, which names the missing file and points atmake codegeninstead of letting the failure surface aserror[E0583]: file not found for module 'generated'.In CI the
Codegenjob produces them once and uploads thecodegen-outputartifact; every job that compilestruapi-serverdepends on that job and downloads it.ci-android,release-androidandrelease-iosare separate workflows with no such job, so they runscripts/codegen.shin place withTRUAPI_SKIP_PACKAGE_BUILD=1.The
Codegenjob also gates that nothing generated is committed, withgit ls-files -ci --exclude-standardover the whole repo.How iOS consumers get the sources
SwiftPM resolves a package's source targets from the git checkout and has no way to fetch them from a release asset:
binaryTargetaccepts only.xcframeworkand.artifactbundle. So an iOS release is two artifacts.@parity/ios-host@<version>release assettruapi_server.xcframework.zippublishedBinaryURL+ checksum<version>Consumers pin the semver tag:
ios/truapi-host/scripts/tag-release.shbuilds that commit. It reads the required paths out ofPackage.swiftrather than repeating them, so the file set cannot drift from what SwiftPM looks for, and it refuses to tag an xcframework into git. When the tag already exists with an identical manifest it exits successfully, so a rerun of the release pushes the existing tag as a no-op; a tag with a different manifest is an error.release-ios.ymlpublishes the asset and the tag.release.ymlcalls it for arelease: @parity/ios-host <version>subject, and it is also dispatchable on its own, matchingrelease-android.yml. Dispatching it from a branch with a version like0.14.0-beta.1cuts an asset and a tag an app can pin, which is how an unmerged host change gets tested in the app. A dispatched run passes nomanifest_branchand touches no branch.When called from the release flow, the job opens a pull request on
release/ios-host-<version>that points the release branch'sPackage.swiftat the new asset, and dispatches CI for it explicitly because events created withGITHUB_TOKENdo not start another workflow.The job clones the tag and compiles it against the published asset before pushing, so a tag that cannot be resolved is never published.
What CI proves
iOS package (swift compile)builds the tag rather than the working tree: it runstag-release.sh, clones the result, diffs the cloned file set against the working tree under every declared path, and compiles the package and its test target from that clean clone. Compiling in place would pass on generated files the tag does not carry, which is the exact failure being guarded.iOS bindings (uniffi)regenerates the Swift and provider bindings. With nothing committed to diff against, what it gates is that bindgen still produces a binding for every UniFFI-exposed type.ios-swift's path filter names every crate the bindings are generated from (truapi,truapi-platform,truapi-server,truapi-provider) plusjs/container/, because a protocol change leaves noios/diff to key on.Notes
Package.swiftdeclaresTrUAPIProvideras a source target, so its bindings have to exist even for a consumer that only importsTrUAPIHost.ios/truapi-provider/scripts/sync-bindings.shproduces them without Xcode or the iOS targets, andrebuild.shdelegates to it..gitignorelists the three generated Swift filenames rather thantruapi*.swift. Undercore.ignorecase, which git sets by default on macOS, the glob also matches the hand-writtenTrUAPIHost.swift.mod.rsemitted alongsidedispatcher.rsandwire_table.rshas a golden fixture. It is the file that makestruapi-serverparse, so losing it fails a test rather than the next build.tag-release.shand the manifest step both assert thatPackage.swiftreadsTRUAPI_USE_LOCAL_BINARYfrom the environment, so a published manifest can never pin the local binary.Verifying the release path
GitHub only exposes
workflow_dispatchfor workflows present on the default branch, sorelease-ios.ymlcannot be dispatched from this branch. The tag's content and buildability are covered on the PR by theiOS package (swift compile)job above. Cutting a pre-release to exercise the publish half (asset upload, tag push, resolution from GitHub by the app) needs this merged first.