Skip to content

Commit

Permalink
Migrate to the baseline profile plugin. (#2059)
Browse files Browse the repository at this point in the history
* Migrate to the baseline profile plugin.

* Move baseline file output.
  • Loading branch information
colinrtwhite authored Jan 21, 2024
1 parent 66bc58e commit 3e50907
Show file tree
Hide file tree
Showing 15 changed files with 520 additions and 3,394 deletions.
30 changes: 14 additions & 16 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,40 @@

2. Add release notes for the new version to `CHANGELOG.md`.

3. Run `./assemble_baseline_profile.sh` to ensure the baseline profiles are up to date.
3. Find and replace the previous version in the docs with the new version.

4. Find and replace the previous version in the docs with the new version.

5. Commit
4. Publish

```
$ git commit -m "Prepare version X.Y.Z."
$ ./publish_remote.sh
```

6. Publish
5. Commit

```
$ ./publish_remote.sh
$ git commit -m "Prepare version X.Y.Z."
```

7. Tag
6. Tag

```
$ git tag X.Y.Z
```

8. Update the `POM_VERSION` in `gradle.properties` to the next "SNAPSHOT" version.
7. Update the `POM_VERSION` in `gradle.properties` to the next "SNAPSHOT" version.

9. Commit
8. Commit

```
$ git commit -m "Prepare next development version."
```

10. Push!
9. Push!

```
$ git push && git push --tags
```
```
$ git push && git push --tags
```

11. Visit [Sonatype Nexus](https://oss.sonatype.org/) and promote the artifact.
10. Visit [Sonatype Nexus](https://oss.sonatype.org/) and promote the artifact.

12. Create a [new Github release](https://github.com/coil-kt/coil/releases/new) that points to the new version's tag and entry in the `CHANGELOG.md`.
11. Create a [new Github release](https://github.com/coil-kt/coil/releases/new) that points to the new version's tag and entry in the `CHANGELOG.md`.
8 changes: 0 additions & 8 deletions assemble_baseline_profile.sh

This file was deleted.

1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ buildscript {
}

plugins {
alias(libs.plugins.baselineProfile) apply false
alias(libs.plugins.binaryCompatibility)
alias(libs.plugins.dokka)
alias(libs.plugins.poko) apply false
Expand Down
14 changes: 14 additions & 0 deletions coil-compose-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ plugins {
id("kotlinx-atomicfu")
id("dev.drewhamilton.poko")
id("org.jetbrains.compose")
id("androidx.baselineprofile")
}

addAllMultiplatformTargets()
Expand Down Expand Up @@ -42,3 +43,16 @@ kotlin {
}
}
}

baselineProfile {
mergeIntoMain = true
saveInSrc = true
baselineProfileOutputDir = ""
filter {
include("coil3.compose.**")
}
}

dependencies {
baselineProfile(projects.internal.benchmark)
}
345 changes: 98 additions & 247 deletions coil-compose-core/src/androidMain/baseline-prof.txt

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions coil-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
id("kotlin-multiplatform")
id("kotlinx-atomicfu")
id("dev.drewhamilton.poko")
id("androidx.baselineprofile")
}

addAllMultiplatformTargets()
Expand Down Expand Up @@ -58,3 +59,20 @@ kotlin {
}
}
}

baselineProfile {
mergeIntoMain = true
saveInSrc = true
baselineProfileOutputDir = ""
filter {
include("coil3.**")
exclude("coil3.network.**")
exclude("coil3.gif.**")
exclude("coil3.svg.**")
exclude("coil3.video.**")
}
}

dependencies {
baselineProfile(projects.internal.benchmark)
}
3,389 changes: 329 additions & 3,060 deletions coil-core/src/androidMain/baseline-prof.txt

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[versions]
androidx-activity = "1.8.2"
androidx-lifecycle = "2.7.0"
androidx-benchmark = "1.2.2"
androidx-compose = "1.5.4"
androidx-lifecycle = "2.7.0"
coroutines = "1.8.0-RC2"
jetbrains-compose = "1.6.0-alpha01"
jetbrains-compose-compiler = "1.5.7"
Expand All @@ -16,6 +17,7 @@ roborazzi = "1.7.0"
skiko = "0.7.90"

[plugins]
baselineProfile = { id = "androidx.baselineprofile", version.ref = "androidx-benchmark"}
binaryCompatibility = "org.jetbrains.kotlinx.binary-compatibility-validator:0.13.2"
dokka = "org.jetbrains.dokka:1.9.10"
poko = "dev.drewhamilton.poko:0.15.2"
Expand All @@ -34,7 +36,7 @@ androidx-activity = { module = "androidx.activity:activity-ktx", version.ref = "
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }
androidx-appcompat-resources = "androidx.appcompat:appcompat-resources:1.6.1"
androidx-annotation = "androidx.annotation:annotation:1.7.1"
androidx-benchmark-macro = "androidx.benchmark:benchmark-macro-junit4:1.2.2"
androidx-benchmark-macro = { module = "androidx.benchmark:benchmark-macro-junit4", version.ref = "androidx-benchmark" }
androidx-constraintlayout = "androidx.constraintlayout:constraintlayout:2.1.4"
androidx-core = "androidx.core:core-ktx:1.12.0"
androidx-exifinterface = "androidx.exifinterface:exifinterface:1.3.7"
Expand Down
20 changes: 10 additions & 10 deletions internal/benchmark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import com.android.build.api.dsl.ManagedVirtualDevice
plugins {
id("com.android.test")
id("kotlin-android")
id("androidx.baselineprofile")
}

androidTest(name = "coil3.benchmark", config = true) {
val targetProject = System.getProperty("project", "view")
val targetProject = System.getProperty("project", "compose")
defaultConfig {
minSdk = 28
buildConfigField("String", "PROJECT", "\"$targetProject\"")
testInstrumentationRunnerArguments["androidx.benchmark.suppressErrors"] = "EMULATOR"
}
buildTypes {
create("benchmark") {
isDebuggable = true
signingConfig = getByName("debug").signingConfig
matchingFallbacks += listOf("release")
signingConfig = signingConfigs["debug"]
matchingFallbacks += "release"
}
}
testOptions {
Expand All @@ -35,15 +35,15 @@ androidTest(name = "coil3.benchmark", config = true) {
experimentalProperties["android.experimental.self-instrumenting"] = true
}

baselineProfile {
managedDevices += "pixel7Api34"
useConnectedDevices = false
enableEmulatorDisplay = false
}

dependencies {
implementation(libs.androidx.benchmark.macro)
implementation(libs.androidx.test.espresso)
implementation(libs.androidx.test.junit)
implementation(libs.androidx.test.uiautomator)
}

androidComponents {
beforeVariants(selector().all()) {
it.enable = it.buildType == "benchmark"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class BaselineProfileGenerator {
@Test
fun generate() = baselineProfileRule.collect(
packageName = "sample.$PROJECT",
filterPredicate = newFilterPredicate(),
) {
pressHome()
startActivityAndWait()
Expand All @@ -36,38 +35,4 @@ class BaselineProfileGenerator {
.fling(Direction.DOWN, 3000)
device.waitForIdle()
}

private fun newFilterPredicate(): (String) -> Boolean {
val packageNames = if (PROJECT == "compose") {
composePackageNames
} else {
basePackageNames
}
return filter@{ line ->
val endIndex = line.indexOf(';')
if (endIndex == -1) {
return@filter false
}

if (line.indexOf("sample/") != -1) {
return@filter false
}

packageNames.any { packageName ->
val index = line.indexOf(packageName)
index != -1 && index < endIndex
}
}
}
}

// Only include Compose-specific rules in the coil-compose module.
private val composePackageNames = listOf(
"coil3/compose/",
)

private val basePackageNames = listOf(
"coil3/",
"kotlinx/coroutines/",
"okio/",
)
5 changes: 4 additions & 1 deletion publish_local.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash
set -e

# Regenerate the baseline profile.
./gradlew generateBaselineProfile

# Build and install the artifacts locally to 'mavenLocal'.
./gradlew publishToMavenLocal
./gradlew publishToMavenLocal -PenableWasm=false
5 changes: 4 additions & 1 deletion publish_remote.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash
set -e

# Regenerate the baseline profile.
./gradlew generateBaselineProfile

# Build and upload the artifacts to 'mavenCentral'.
./gradlew publish
./gradlew publish -PenableWasm=false
15 changes: 8 additions & 7 deletions samples/compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@ plugins {
androidApplication(name = "sample.compose") {
buildTypes {
release {
isDebuggable = false
isMinifyEnabled = false
isShrinkResources = false
signingConfig = signingConfigs["debug"]
}
create("minifiedRelease") {
isDebuggable = false
isMinifyEnabled = true
isShrinkResources = true
matchingFallbacks += "release"
proguardFiles(
"../shared/shrinker-rules.pro",
"../shared/shrinker-rules-android.pro",
)
signingConfig = signingConfigs["debug"]
}
create("benchmark") {
isDebuggable = false
isMinifyEnabled = false
isShrinkResources = false
matchingFallbacks += listOf("release")
signingConfig = signingConfigs.getByName("debug")
}
}
}

Expand Down
15 changes: 8 additions & 7 deletions samples/view/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@ plugins {
androidApplication(name = "sample.view") {
buildTypes {
release {
isDebuggable = false
isMinifyEnabled = false
isShrinkResources = false
signingConfig = signingConfigs["debug"]
}
create("minifiedRelease") {
isDebuggable = false
isMinifyEnabled = true
isShrinkResources = true
matchingFallbacks += "release"
proguardFiles(
"../shared/shrinker-rules.pro",
"../shared/shrinker-rules-android.pro",
)
signingConfig = signingConfigs["debug"]
}
create("benchmark") {
isDebuggable = false
isMinifyEnabled = false
isShrinkResources = false
matchingFallbacks += listOf("release")
signingConfig = signingConfigs.getByName("debug")
}
}
buildFeatures {
viewBinding = true
Expand Down
8 changes: 8 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}

rootProject.name = "coil-root"

// https://docs.gradle.org/7.4/userguide/declaring_dependencies.html#sec:type-safe-project-accessors
Expand Down

0 comments on commit 3e50907

Please # to comment.