03 - Testing and CI
1. Why
Sinew's tests run in commonTest wherever possible, and on each platform where behavior differs: secure storage, crypto, biometrics, the network checker, engine errors. CI has to run all of them, enforce the dependency graph and the ABI, and prove that production builds carry no devtools.
2. Shape
| Job | Runner | Runs |
|---|---|---|
jvm-android | ubuntu | ./gradlew check for android (host tests) and jvm: unit tests, checkKotlinAbi, checkSinewGraph, Detekt, Kover (80% floor) |
android-device | ubuntu + emulator (android-emulator-runner, API 35 google_apis, KVM) | instrumented tests: FieldCipher on the Keystore and a lost master key, SecureStore and Android's SQLite errors, the network checker switching Wi-Fi and data. The biometric tests skip themselves there and run through tool/android-biometric-test.sh |
ios | macos | ./gradlew iosSimulatorArm64Test, plus the Keychain, CryptoKit and biometric tests on a simulator, plus (from S5) an xcodebuild of the iOS sample |
web | ubuntu | ./gradlew wasmJsBrowserTest in headless Chrome |
devtools-gating | ubuntu (Android, desktop, web) + macos (iOS) | checkDevToolsGating builds the sample's production outputs (the Android production release APK, the desktop uber jar, the wasm production bundle, the iosArm64 release framework) and fails if any holds a com.srctool.sinew.devtools declaration the no-op doesn't declare. The real-devtools outputs (the Android staging release, and the rest with -Psinew.devtools=true) are checked the opposite way. The ABI parity of the no-op is checkDevtoolsNoopAbi, in jvm-android |
publish | macos, on tags | see Publishing |
| Rule | Why |
|---|---|
| Test first by default. A test written after the code must be seen failing once. Bug fixes are always test-first. | The base testing rules |
| 80% line coverage per module, measured by Kover on the JVM run | The floor from the base note |
| Every job uses the Gradle build cache and the configuration cache | Four targets make the build slow otherwise |
| The web job is required, unlike Camouflage's | Sinew's web code is mostly plain Kotlin/Wasm. The Compose modules (-l10n, -viewmodel, -camouflage, -devtools-ui) are tested on web too, but their web screenshots aren't tested |
3. API
Gradle tasks CI calls: check, checkKotlinAbi, checkSinewGraph, koverVerify, iosSimulatorArm64Test, wasmJsBrowserTest, checkDevtoolsNoopAbi, checkDevToolsGating (wrapping checkDevToolsGatingAndroid, …Desktop, …Web, and on macOS …Ios), publishAndReleaseToMavenCentral.
4. Build steps
- The
jvm-androidjob at S0, with everything that runs on the JVM. iosandwebjobs at S0, on placeholder tests.android-deviceat S4, when secure storage and biometrics exist.devtools-gatingat S6.
Done when
- All jobs are green on
main, and the gating job fails on a branch that adds the real devtools to the production variant.
5. Edge cases
| Case | Decided behavior |
|---|---|
| A flaky emulator biometric test | It's retried once by the job. Twice flaky in a week means it's fixed or quarantined, never ignored. |
| Coverage drops below 80% on a module | koverVerify fails the job. |
Decided by default (revisit during implementation)
- The web job is required for Sinew. Unlike Camouflage, Sinew's web code doesn't depend on Compose web's Beta status.