Skip to content

fix(ci): hash the library sources in the native build tasks - #2

Merged
giaBaoJS merged 1 commit into
mainfrom
fix/turbo-native-build-inputs
Sep 1, 2026
Merged

fix(ci): hash the library sources in the native build tasks#2
giaBaoJS merged 1 commit into
mainfrom
fix/turbo-native-build-inputs

Conversation

@giaBaoJS

@giaBaoJS giaBaoJS commented Sep 1, 2026

Copy link
Copy Markdown
Owner

The bug

build:android and build:ios only exist as scripts in example/package.json, so Turborepo runs them in the example package and resolves every bare input glob relative to example/. That makes the whole inputs list in turbo.json point at the wrong tree:

  • "src/*.ts", "src/*.tsx" resolved to example/src/*.ts(x) and matched exactly one file, example/src/App.tsx
  • "android", "ios", "*.podspec", "package.json" resolved inside example/
  • "example/package.json", "example/android", "example/ios" resolved to example/example/..., which does not exist

So the library's own sources were never hashed: not src/, not the Nitro spec, not the Kotlin or Swift files, not nitro.json, not the podspec.

turbo run build:* --dry=json on main listed 28 inputs for Android, all of them under example/. Appending a line to each of these files and re-reading the task hash left both hashes untouched:

touched file build:android build:ios
src/specs/SharedTransitionModule.nitro.ts 2890f3fd0ac0a842 250f38a614ae0559
src/native/NativeModule.ts 2890f3fd0ac0a842 250f38a614ae0559
src/TransitionCoordinator.ts 2890f3fd0ac0a842 250f38a614ae0559
android/.../HybridSharedTransitionModule.kt 2890f3fd0ac0a842 250f38a614ae0559
ios/HybridSharedTransitionModule.swift 2890f3fd0ac0a842 250f38a614ae0559
nitro.json 2890f3fd0ac0a842 250f38a614ae0559

Those are the unchanged baseline hashes in every row.

.github/workflows/ci.yml gates the expensive work on that hash: a HIT sets turbo_cache_hit=1, which skips the JDK install, the Android SDK licence step, the Xcode selection and pod install, and lets turbo run build:* replay from cache. A pull request that rewrites the Nitro spec or the native Kotlin/Swift module therefore reports both native builds green without compiling anything.

The fix

Root files are reached with the $TURBO_ROOT$ prefix (Turborepo 2.1+, this repo is on 2.7.2), and the example globs widened from src/*.ts(x) to src/** so the nested screens, components and navigation files count too. Build output directories stay excluded.

Verification

Same probe after the change, against the new baselines ab47d59fc30531e0 (Android) and 99ce437c92e23cd5 (iOS):

touched file build:android build:ios
src/specs/SharedTransitionModule.nitro.ts changed changed
src/native/NativeModule.ts changed changed
src/TransitionCoordinator.ts changed changed
android/.../HybridSharedTransitionModule.kt changed unchanged
ios/HybridSharedTransitionModule.swift unchanged changed
nitro.json changed changed
SharedTransition.podspec unchanged changed
example/src/screens/DetailScreen.tsx changed changed

Platform-specific native sources now invalidate only their own build, shared TypeScript and Nitro config invalidate both. The resolved iOS input list grew from 28 to 57 entries and includes ../src/specs/SharedTransitionModule.nitro.ts, ../ios/HybridSharedTransitionModule.swift, ../nitro.json and ../SharedTransition.podspec.

yarn test, yarn lint and yarn typecheck are clean.

Both build:android and build:ios only exist as scripts in the example
package, so every bare input glob resolved inside example/. The library's
own src/, android/, ios/, podspec and nitro.json were not hashed at all,
and the example/* entries pointed at example/example/*. Editing the Nitro
spec or the Kotlin and Swift sources left both task hashes untouched, so
CI reported a cache HIT and skipped the JDK, CocoaPods and build steps.
Reach the root files through $TURBO_ROOT$ and widen the example globs to
the whole source tree.
@giaBaoJS
giaBaoJS merged commit e457fd9 into main Sep 1, 2026
5 checks passed
@giaBaoJS
giaBaoJS deleted the fix/turbo-native-build-inputs branch September 1, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant