Loading...
Loading...
Use this skill to gate CI on Jetpack Compose stability — catch when a composable becomes unskippable/unrestartable or a parameter goes stable → unstable, before it ships and tanks recomposition. Covers the Compose Stability Analyzer Gradle plugin's `stabilityDump` (write a `.stability` baseline) and `stabilityCheck` (compare current compilation against it, fail on regression) tasks, the `composeStabilityAnalyzer { stabilityValidation { … } }` DSL (`failOnStabilityChange`, `ignoreNonRegressiveChanges`, `ignored*` lists, `allowMissingBaseline`, `stabilityConfigurationFiles`), the `@IgnoreStabilityReport` annotation, committing `app/stability/app.stability` as a team baseline, the deliberate baseline-update workflow, and GitHub Actions wiring (`needs: build`, since the analysis reads compiled output). Use when the user mentions "stabilityCheck", "stabilityDump", "compose stability analyzer", "stability baseline", "@IgnoreStabilityReport", "composeStabilityAnalyzer", or "fail the build on stability changes".
npx skill4agent add skydoves/android-testing-skills validating-compose-stability.stability@Immutable@Stablecompose-performance-skills./gradlew stabilityCheck.stabilityList@ImmutablestabilityDumpstabilityCheckcomposeStabilityAnalyzer@IgnoreStabilityReport@Immutable@Stablekotlinx.collections.immutablestability_config.confderivedStateOfcompose-performance-skillsRecomposer../../setup/choosing-test-rule-vs-runtest/SKILL.md../../preview/capturing-preview-screenshots-in-ci/SKILL.mdstabilityCheckstabilityDumpneeds: build:module:compileDebugKotlin<module>/stability/<module>.stabilitystabilityDumpbuild.gradle.ktscomposeStabilityAnalyzer {
stabilityValidation {
enabled.set(true)
outputDir.set(layout.projectDirectory.dir("stability")) // where the .stability baseline lives
includeTests.set(false)
ignoredPackages.set(listOf("com.example.internal"))
ignoredClasses.set(listOf("PreviewComposables"))
ignoredProjects.set(listOf("benchmarks", "examples"))
failOnStabilityChange.set(true) // build fails on stability changes; false => warning-only
ignoreNonRegressiveChanges.set(false) // true => only regressions count; new-stable / improvements ignored
allowMissingBaseline.set(false) // true => no baseline yet is not a failure (bootstrap only)
stabilityConfigurationFiles.add( // same format as the Compose compiler's stability config
rootProject.layout.projectDirectory.file("stability_config.conf")
)
}
}failOnStabilityChangeignoreNonRegressiveChangesstabilityConfigurationFilesignored*./gradlew :app:compileDebugKotlin
./gradlew :app:stabilityDump # writes app/stability/app.stability
git add app/stability/app.stability
git commit -m "Add Compose stability baseline".stabilitydebugStabilityDumpreleaseStabilityCheck.stability./gradlew stabilityDumpstabilityCheck~+-stabilityDump# .github/workflows/ci.yml
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with: { java-version: '21', distribution: 'zulu' }
- run: ./gradlew :app:compileDebugKotlin
stability_check:
name: Compose Stability Check
runs-on: ubuntu-latest
needs: build # MANDATORY — the analysis reads compiled output
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with: { java-version: '21', distribution: 'zulu' }
- run: ./gradlew stabilityCheckList./gradlew :app:compileDebugKotlin
./gradlew :app:stabilityDump
git add app/stability/app.stability
git commit -m "Update stability baseline: PokemonList now takes List<Pokemon> — justified by [reason]".stability@Preview@IgnoreStabilityReportignoredPackagesignoredClassesignoredProjects@IgnoreStabilityReport
@Preview
@Composable
fun UserCardPreview() { UserCard(user = User("John", 30)) }composeStabilityAnalyzer {
stabilityValidation { failOnStabilityChange.set(System.getenv("CI") == "true") }
}CI=truestabilityCheck# WRONG
stability_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: ./gradlew stabilityCheck # no compiled output yet
# WRONG because: the analyzer reads the Compose compiler's output. With nothing compiled it
# either fails or reports incorrect results. The check must depend on a build step.# RIGHT
stability_check:
runs-on: ubuntu-latest
needs: build # or: - run: ./gradlew :app:compileDebugKotlin stabilityCheck
steps:
- uses: actions/checkout@v4
- run: ./gradlew stabilityCheck# WRONG — CI failed on a stability regression, so:
./gradlew stabilityDump && git commit -am "fix stability check"
# WRONG because: stabilityDump rewrites the baseline to whatever the code currently produces, so
# the check trivially passes — the regression ships, undocumented. The dump is for *accepting* a
# change you understand, with a commit message that says why; it is not a way to silence the gate.# RIGHT — investigate the ~ entries first; only then, if the change is justified:
./gradlew :app:compileDebugKotlin :app:stabilityDump
git add app/stability/app.stability
git commit -m "Update stability baseline: <composable> <what changed> — justified by <reason>"@Preview// WRONG — preview functions in the .stability baseline, churning it on every preview edit
@Preview @Composable fun ProfilePreview() { Profile(sampleUser) }
// WRONG because: previews are tooling entry points, not API. Tracking them means the baseline
// diffs every time someone tweaks a preview, drowning real regressions.// RIGHT — annotate them out (or ignoredClasses = listOf("...Preview...") for a naming convention)
@IgnoreStabilityReport @Preview @Composable fun ProfilePreview() { Profile(sampleUser) }.stabilitystabilityCheckneeds:stabilityDump@Preview@IgnoreStabilityReportignoredClassesignoredPackagesfailOnStabilityChange = falseallowMissingBaseline = true@Immutable@Stablecompose-performance-skillsignoreNonRegressiveChanges = true+failOnStabilityChange.set(System.getenv("CI") == "true")./gradlew stabilityDump<module>/stability/<module>.stabilitygit status./gradlew stabilityCheckList<T>~needs: buildstabilityCheck@Preview@IgnoreStabilityReportignoredClasses.stabilityfailOnStabilityChangetrueCIallowMissingBaselinefalsestabilityDumpstabilityCheckcomposeStabilityAnalyzer { stabilityValidation { … } }.stability~+-@IgnoreStabilityReportneeds: buildfailOnStabilityChange.set(System.getenv("CI") == "true")@Immutable@Stablestability_configuration_path../../preview/capturing-preview-screenshots-in-ci/SKILL.mdneeds: build