fladle icon indicating copy to clipboard operation
fladle copied to clipboard

[Feature request] Use build variants for configs

Open juliocbcotta opened this issue 4 years ago • 5 comments

Hey, it would be amazing if we could just run stuff like ./gradlew runFlank$MY_VARIANT ./gradlew runFlank$MY_VARIANT$MY_CONFIG

It would free us from the need of setting variant.

This is a pain for me, as I have multiple apps from the same project, with just a few adjusts for each. If I want to run the UI tests for each app I need to pass the variant as argument in the command line... something like

./gradlew runFlank -Pvariation=$MY_VARIANT.

If we could receive in the lambda for the configs that variant it would also help as I keep one smartFlankGcsPath for each config as a way of not overriding the default one.

Thanks

juliocbcotta avatar Aug 04 '21 11:08 juliocbcotta

You can use configs and add an extra task/configuration for each variant. Does that work for you? See doc here: https://runningcode.github.io/fladle/configuration/#configs

runningcode avatar Aug 04 '21 14:08 runningcode

Hey, I am using that, but maybe because I am not very good with groovy/gradle I don't see how to do it without a lot of repetition or custom code.

Let me give you some context...

I am using the config to split the tests by feature team.. we have navigation, checkout, user-engagement, postsales and marketplace. With this I hope to run fewer tests when one of those teams create an MR.

but we have 4 product flavors : veepeeAll, privaliaEs, privaliaIt and vexAll, each becomes a separated app/apk.

So, if I need to run the tests for navigation team, I would need something like :

./gradlew app:assembleVeepeeAllDebug app:assembleVeepeeAllDebugAndroidTest
./gradlew runFlankNavigation -Pvariation=veepeeAll

./gradlew app:assemblePrivaliaEsDebug app:assemblePrivaliaEsDebugAndroidTest
./gradlew runFlankNavigation -Pvariation=privaliaEs

./gradlew app:assemblePrivaliaItDebug app:assemblePrivaliaItDebugAndroidTest
./gradlew runFlankNavigation -Pvariation=privaliaIt

./gradlew app:assembleVexAllDebug app:assemblePrivaliaVexAllAndroidTest
./gradlew runFlankNavigation -Pvariation=vexAll

If we could just compile and run flank with runFlank{config}{flavor}{buildType} command our life would be easier and less error prone.

./gradlew runFlankNavigationVeepeeAllDebug
./gradlew runFlankNavigationPrivaliaEsDebug
./gradlew runFlankNavigationPrivaliaItDebug
./gradlew runFlankNavigationVexAllDebug

I could create configs with all the possible combinations of teams and flavors, but (with my limited groovy knowledge) I would have a lot of repetition...

like

        veepeeAllNavigation {
            smartFlankGcsPath.set("${smartFlankRootPath}navigation/JUnitReport.xml")
            testTargets.set(project.provider {
                [
                        "package com.venteprivee.tests.navigation"
                ]
            })
        }
        
        privaliaEsNavigation {
            smartFlankGcsPath.set("${smartFlankRootPath}navigation/JUnitReport.xml")
            testTargets.set(project.provider {
                [
                        "package com.venteprivee.tests.navigation"
                ]
            })
        }
        
        privaliaItNavigation {
            smartFlankGcsPath.set("${smartFlankRootPath}navigation/JUnitReport.xml")
            testTargets.set(project.provider {
                [
                        "package com.venteprivee.tests.navigation"
                ]
            })
        }
        
        vexAllNavigation {
            smartFlankGcsPath.set("${smartFlankRootPath}navigation/JUnitReport.xml")
            testTargets.set(project.provider {
                [
                        "package com.venteprivee.tests.navigation"
                ]
            })
        }

Would it be possible to loop an array of flavors to generate it?

juliocbcotta avatar Aug 04 '21 17:08 juliocbcotta

You can also create a function to configure the extension and call that function.

runningcode avatar Aug 04 '21 17:08 runningcode

Could you share a sample?

juliocbcotta avatar Aug 04 '21 17:08 juliocbcotta

I was not able to create a method, but I created a for loop

configs {
        ["marketplace", "navigation", "checkout", "postsales", "userengagement"].forEach { team ->
            "${team}" {
                smartFlankGcsPath.set("${smartFlankRootPath}${team}/JUnitReport.xml")
                testTargets.set(project.provider {
                    [
                            "package com.venteprivee.tests.${team}"
                    ]
                })
            }
        }
    }

It kinda helped, but since I can't change the variant inside of the configs block, I will have to keep the parameter when building.

Thanks.

juliocbcotta avatar Aug 11 '21 13:08 juliocbcotta