Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Use build variants for configs #267

Open
juliocbcotta opened this issue Aug 4, 2021 · 5 comments
Open

[Feature request] Use build variants for configs #267

juliocbcotta opened this issue Aug 4, 2021 · 5 comments

Comments

@juliocbcotta
Copy link

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

@runningcode
Copy link
Owner

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

@juliocbcotta
Copy link
Author

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?

@runningcode
Copy link
Owner

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

@juliocbcotta
Copy link
Author

Could you share a sample?

@juliocbcotta
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants