Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Add Compose stability baseline support
Browse files Browse the repository at this point in the history
  • Loading branch information
ILIYANGERMANOV committed Feb 6, 2024
1 parent 9da3675 commit 6ba630a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ import arrow.core.raise.catch
import arrow.core.raise.either
import arrow.core.right
import ivy.automate.compose.stability.model.ComposableArgument
import ivy.automate.compose.stability.model.FullyQualifiedName
import ivy.automate.compose.stability.model.UnstableComposable
import java.io.File
import kotlin.system.exitProcess

const val OutputReportFileName = "ivy-compose-stability-report.txt"
const val ComposeReportFolderName = "compose_compiler"
const val BaselineArg = "generateBaseline"
const val BaselineFileName = "ivy-compose-stability-baseline.txt"

fun main() {
fun main(args: Array<String>) {
val shouldGenerateBaseline = BaselineArg in args
val baselineComposables = readBaseline()
val unstableComposables = findComposeReportFolders()
.flatMap { reportFolder ->
unstableComposables(reportFolder).fold(
Expand All @@ -23,9 +29,16 @@ fun main() {
}
)
}.toList()
.filter {
shouldGenerateBaseline || it.fullyQualifiedName !in baselineComposables
}
val ivyReportTxt = buildIvyReport(unstableComposables)
createReportFile(ivyReportTxt)
println(ivyReportTxt)
if(!shouldGenerateBaseline && unstableComposables.isNotEmpty()) {
println("ERROR: ${unstableComposables.size} unstable composables found. Fix them!")
exitProcess(1)
}
}

private fun findComposeReportFolders(): Sequence<File> {
Expand Down Expand Up @@ -137,4 +150,21 @@ private fun buildIvyReport(
private fun createReportFile(report: String) {
val reportFile = File(OutputReportFileName)
reportFile.writeText(report)
}
}

private fun generateBaseline(unstableComposables: List<UnstableComposable>) {
val baselineContent = unstableComposables.joinToString(separator = "\n") {
it.fullyQualifiedName
}
val baselineFile = File(BaselineFileName)
baselineFile.writeText(baselineContent)
}

private fun readBaseline(): Set<FullyQualifiedName> {
return try {
val baselineFile = File(BaselineFileName)
baselineFile.readText().split("\n").toSet()
} catch (e: Exception) {
emptySet()
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package ivy.automate.compose.stability.model

typealias FullyQualifiedName = String

data class UnstableComposable(
val fullyQualifiedName: String,
val fullyQualifiedName: FullyQualifiedName,
val name: String,
val skippable: Boolean,
val restartable: Boolean,
Expand Down

0 comments on commit 6ba630a

Please sign in to comment.