takahirom / roborazzi

Make JVM Android integration test visible 🤖📸
https://takahirom.github.io/roborazzi/
Apache License 2.0
654 stars 25 forks source link

Generate Images by Invoking Gradle Tasks Using the Roborazzi IntelliJ Plugin #424

Closed takahirom closed 1 day ago

takahirom commented 1 week ago

I think it would be great to have a button to generate and refresh images in the plugin.

We can get Gradle module information and tasks.

plugins.set(listOf(
    "java",
    "Kotlin",
    "com.intellij.gradle", // add this
  ))
  private fun setUpGradleData(psiFile: KtFile) {
    val module = psiFile.module
    if (module == null) {
      println("module is null")
      return
    }
    val findGradleModuleData = GradleUtil.findGradleModuleData(module)
    println("findGradleModuleData:" + findGradleModuleData)
    findGradleModuleData?.let {
      println("findGradleModuleData:${it.data}")
      println("it.getDirectoryToRunTask():" + it.data.getDirectoryToRunTask())
      val taskNodeData = ExternalSystemApiUtil.findAll(it, ProjectKeys.TASK)
      taskNodeData.forEach {
        println("taskNodeData:" + it)
      }
    }
  }

./gradlew :roborazzi-idea-plugin:runIde

virtualFilePath/.../git/roborazzi/sample-android/src/test/java/com/github/takahirom/roborazzi/sample/ManualTest.kt
findGradleModuleData:ModuleData: :sample-android
findGradleModuleData::sample-android
it.getDirectoryToRunTask():/.../git/roborazzi/sample-android
taskNodeData:TaskData: projects
taskNodeData:TaskData: lintReportRelease
taskNodeData:TaskData: packageReleaseResources
taskNodeData:TaskData: restoreOutputDirRoborazzi
taskNodeData:TaskData: bundleLibResDebug

And it seems that we can run the task using the plugin: https://intellij-support.jetbrains.com/hc/en-us/community/posts/4414033579922-Run-Gradle-task-from-plugin-action

I think we can filter the tasks by recordRoborazzi, compareRoborazzi, and verifyRoborazzi, and show a drop-down menu to allow the user to select and run the task.

eyedol commented 6 days ago

@takahirom happy to pick this up. Few clarifications if you get the chance 🙏🏿

I think we can filter the tasks by recordRoborazzi, compareRoborazzi, and verifyRoborazzi, and show a drop-down menu to allow the user to select and run the task.

I was wondering what you meant by filtering recordRoborazzi, compareRoborazzi, and verifyRoborazzi You mean we dynamically get all the tasks associated with roborazzi then filter out for these three tasks to be ran by the drop-down selection?

Also in terms of UI this is what I envision:

Screenshot 2024-07-09 at 5 28 37 PM

wdyt?

takahirom commented 6 days ago

Ah, I see you already have a dropdown menu! We'll have at least recordRoborazziDebug and recordRoborazziRelease, and possibly options like recordRoborazziProductionDebug. I'd like to include these as options in the dropdown menu. Ideally, it would be great to have a task dropdown menu specifically for the user's Gradle module. The menu content could be something like 'listOf(recordRoborazziDevelopDebug, recordRoborazziProductionDebug, recordRoborazziProductionRelease,..., compareRoborazziDevelopDebug, ..., verifyRoborazziDevelopDebug,...)'. However, starting with a minimum viable product is also a good approach.

eyedol commented 6 days ago

Yes, I have something rough done :-)

Okay I understood. You want to be able to run all the variants of the roborazzi tasks