Coder Social home page Coder Social logo

emergetools / emerge-android Goto Github PK

View Code? Open in Web Editor NEW
14.0 14.0 2.0 2.65 MB

Emerge Android tooling & Gradle plugin for using Emerge's size analysis, performance testing and end-to-end snapshotting

Home Page: https://docs.emergetools.com/docs/quickstart

License: Apache License 2.0

Kotlin 100.00%
android performance-testing size-analyzer snapshot-testing

emerge-android's People

Contributors

chromy avatar rbro112 avatar trevor-e avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

emerge-android's Issues

Configuration cache state could not be cached

Running a task with configuration cache enabled results in a violation:

Command:

./gradlew :app:emergeUploadSnapshotBundleGooglePlayDebug

Output:

Configuration cache state could not be cached: field `artifactMetadata$delegate` of task `:app:emergeUploadSnapshotBundleGooglePlayDebug` of type `com.emergetools.android.gradle.tasks.snapshots.UploadSnapshotBundle`: error writing value of type 'kotlin.SynchronizedLazyImpl'
> Expected file collection to contain exactly one file, however, it contains no files.

Configuration Cache Build issues when getting git information.

I tested the plug-in in version 2.1.3 and found a configuration cache issue remaining when no baseSha is specified and the plug-in tries to get the values, this is the configuration cache report:

10 problems were found storing the configuration cache, 6 of which seem unique.
- Class `com.emergetools.android.gradle.util.ProcessKt`: external process started 'git config --get remote.origin.url'
  See https://docs.gradle.org/8.4/userguide/configuration_cache.html#config_cache:requirements:external_processes
- Class `com.emergetools.android.gradle.util.ProcessKt`: external process started 'git merge-base main branchName'
  See https://docs.gradle.org/8.4/userguide/configuration_cache.html#config_cache:requirements:external_processes
- Class `com.emergetools.android.gradle.util.ProcessKt`: external process started 'git remote show origin'
  See https://docs.gradle.org/8.4/userguide/configuration_cache.html#config_cache:requirements:external_processes
- Class `com.emergetools.android.gradle.util.ProcessKt`: external process started 'git remote'
  See https://docs.gradle.org/8.4/userguide/configuration_cache.html#config_cache:requirements:external_processes
- Class `com.emergetools.android.gradle.util.ProcessKt`: external process started 'git rev-parse --abbrev-ref HEAD'
  See https://docs.gradle.org/8.4/userguide/configuration_cache.html#config_cache:requirements:external_processes
- Class `com.emergetools.android.gradle.util.ProcessKt`: external process started 'git rev-parse HEAD'
  See https://docs.gradle.org/8.4/userguide/configuration_cache.html#config_cache:requirements:external_processes

__

See the complete report at file:///Users/userName/build/project/build/reports/configuration-cache/78yzm92aj43twznla79fa5kxu/sprul2r5/configuration-cache-report.html
> Starting an external process 'git remote' during configuration time is unsupported.
> Starting an external process 'git remote show origin' during configuration time is unsupported.
> Starting an external process 'git rev-parse --abbrev-ref HEAD' during configuration time is unsupported.
> Starting an external process 'git merge-base main branchName' during configuration time is unsupported.
> Starting an external process 'git config --get remote.origin.url' during configuration time is unsupported.

emerge.outputDir breaks cacheability for com.google.devtools.ksp.gradle.KspTaskJvm

Plugin version
2.1.6 (latest)

Gradle version
8.0.2

JDK version
17

(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version
1.9.20

(Optional) Android Gradle Plugin (AGP) version
8.1.1

Describe the bug
We have a weekly job that runs Gradle's Cache Validation Scripts to verify our project is not executing any cacheable tasks during incremental builds with no changes.

One of the scripts, 03-validate-local-build-caching-different-locations.sh, verifies that caching does not break if a project is built from different locations (i.e. different directories).

For example, say we've cloned the same project, Example-App, in two different directories:

path/to/project/first/Example-App
path/to/project/second/Example-App

If we run a build from path/to/project/first/Example-App, and then we run a second build from path/to/project/second/Example-App with no changes on the same branch, the second build should reuse the cached output for cacheable tasks from the first build because the cached output for both builds is hosted in ~/.gradle/caches/build-cache-1/.

The experiment reported numerous, 41, cacheable tasks executed in the second build. If everything is working properly, this number should be 0. We examined the executed cacheable tasks and found, all of them were of type com.google.devtools.ksp.gradle.KspTaskJvm.

To help diagnose the issue, we compared build scans for these two builds to determine what changed in the second build:
Screen Shot 2024-01-24 at 1 46 04 PM

input 'pluginOptions.$0.asTaskInputArgs' is in both builds but the values are different.

In order to determine what changed, we added the following to our root build.gradle:

tasks.withType(com.google.devtools.ksp.gradle.KspTaskJvm).configureEach {
    doLast {
      pluginOptions.get().forEach { compilerPluginConfig ->
        compilerPluginConfig.getAsTaskInputArgs().findAll { entry ->
          rootProject.buildScan.value(
                  "${entry.key}", entry.value,
          )
        }
      }
    }
  }

We reran the experiment and found that the inputs for com.google.devtools.ksp.gradle.KspTaskJvm changed from:

- [1] emerge.outputDir=/opt/workdir/gradle-enterprise-gradle-build-validation/.data/03-validate-local-build-caching-different-locations/20240124T184213-65b15a05/first-build_workdir/Example-App/build/emergetools/ksp/debugAndroidTest/kotlin
- [2] emerge.outputDir=/opt/workdir/gradle-enterprise-gradle-build-validation/.data/03-validate-local-build-caching-different-locations/20240124T184213-65b15a05/second-build_workdir/Example-App/build/emergetools/ksp/debugAndroidTest/kotlin

Essentially, the value of emerge.outputDir is different in both builds.

The implications of this is that we can't reuse the output of :<project>:kspDebugKotlin, leading to slower builds.

We suspect this line to be the culprit:

val emergeSrcDir = "${project.buildDir}/$BUILD_OUTPUT_DIR_NAME/ksp/debugAndroidTest/kotlin"

To Reproduce
Steps to reproduce the behavior:

  1. Clone a project in different locations
  2. Run a build in one project
  3. Run a build, on the same branch, no code change, from the different project location with build scan
  4. Observe if any cacheable tasks were executed in the second build

Expected behavior
The outputs of the first build should be reused in the second build. The inputs to the plugin should be the same.

Error when snapshotting preview with Dialog

There's a crash upon snapshotting a preview that contains a dialog. As a minimal repro:

@Preview
@Composable
fun ConfirmationAlertDialogPreview() {
  SnapshotsSampleTheme {
    Box(
      modifier = Modifier
        .fillMaxSize()
        .background(color = MaterialTheme.colorScheme.background)
    ) {
      // Other UI
      ConfirmationAlertDialog(...)
    }
  }
}

@Composable
fun ConfirmationAlertDialog(
  onDismiss: () -> Unit,
  onConfirm: () -> Unit,
  message: String,
  title: String,
  confirmButtonLabel: String,
  confirmButtonColor: Color = Color.Unspecified,
) {
  AlertDialog(
    onDismissRequest = onDismiss,
    confirmButton = { ... },
    dismissButton = { ... },
    title = { Text(title) },
    text = { Text(message) },
  )
}

Running this with ./gradlew emergeLocalSnapshotsDebug results in a crash with the following stacktrace. The same crash occurs when running on Emerge's cloud snapshotting system.

There was 1 failure:
1) MaterialThemedComponentWithDialog_GenSnapshot(com.emergetools.snapshots.sample.ui.MaterialThemedComponentWithDialog_-1316455265_GenSnapshot)
java.lang.AssertionError: Failed to capture a node to bitmap.
Reason: Expected exactly '1' node but found '2' nodes that satisfy: (isRoot)
Nodes found:
1) Node #11 at (l=0.0, t=77.0, r=1080.0, b=2028.0)px
Has 1 child
2) Node #12 at (l=0.0, t=0.0, r=770.0, b=382.0)px
Has 1 child

        at androidx.compose.ui.test.SemanticsNodeInteraction.fetchOneOrDie(SemanticsNodeInteraction.kt:145)
        at androidx.compose.ui.test.SemanticsNodeInteraction.fetchSemanticsNode(SemanticsNodeInteraction.kt:79)
        at androidx.compose.ui.test.AndroidImageHelpers_androidKt.captureToImage(AndroidImageHelpers.android.kt:51)
        at com.emergetools.snapshots.EmergeSnapshots.take(EmergeSnapshots.kt:72)
        at com.emergetools.snapshots.sample.ui.MaterialThemedComponentWithDialog_-1316455265_GenSnapshot.MaterialThemedComponentWithDialog_GenSnapshot(MaterialThemedComponentWithDialog_-1316455265_GenSnapshot.kt:34)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.