From 84068156f7df11ad98c32d761dea3777ceba42a8 Mon Sep 17 00:00:00 2001 From: Cristian Garcia Date: Thu, 5 May 2022 16:57:36 +0200 Subject: [PATCH] Allow to write custom FlankRun tasks (#11) --- README.md | 40 +++++++++++-------- docs/manual_tasks_creation.md | 25 ++++++++++++ .../flank/gradle/tasks/FlankDoctorTask.kt | 4 +- .../github/flank/gradle/tasks/FlankRunTask.kt | 5 +-- 4 files changed, 52 insertions(+), 22 deletions(-) create mode 100644 docs/manual_tasks_creation.md diff --git a/README.md b/README.md index c33afa1..4592227 100644 --- a/README.md +++ b/README.md @@ -15,23 +15,12 @@ plugins { } ``` -add your firebase credentials to the rootroject as `ftl-credentials.json` +add your firebase credentials to the rootproject as `ftl-credentials.json` That's it, run `./gradlew runFlank` and get the results. # Optional configuration -## Changing the buildType to run - -Android already provides a way for you to do it: -``` -android { - ... - testBuildType = "beta" - ... -} -``` - ## Changing the credentials file ``` @@ -50,11 +39,6 @@ simpleFlank { } ``` -## debugging shards - -`./gradlew runFlank -PdumpShards=true` - - ## changing Flank version ``` @@ -66,3 +50,25 @@ dependencies { ## Orchestrator `simple-flank` will configure it automatically if you are using "ANDROIDX_TEST_ORCHESTRATOR" + + +# FAQ + +## Can I change the buildType to run? + +Android already provides a way for you to do it: +``` +android { + ... + testBuildType = "beta" + ... +} +``` + +## How to debug shards? + +`./gradlew runFlank -PdumpShards=true` + +## What if I want to use a different flank config? + +Feel free to [create your own task](docs/manual_tasks_creation.md) and provide the config yaml you want. diff --git a/docs/manual_tasks_creation.md b/docs/manual_tasks_creation.md new file mode 100644 index 0000000..6cc79c5 --- /dev/null +++ b/docs/manual_tasks_creation.md @@ -0,0 +1,25 @@ +# Creating test tasks manually + + tasks.register("myFlankRunTask") { + // `flankExecutable` is the configuration cotaining flank dependency + flankJarClasspath.from(flankExecutable) + + // Set the credentials file + serviceAccountCredentials.set(...) + + // Any string you want to use, usually the variant we are testing + // It will be used in the path to store the results in your build: "build/flank/$variant" + variant.set(...) + + // The flank yaml file, it can be the output of a task or a file you created manually for example. + // It's important that you use relative paths to your apks if you wan't it to be cacheable + flankYaml.set(...) + + // Do you want your task to be cacheable? defaults to false + hermeticTests.set(true) + + // Set any Provider that will provide the APKs + // Must be the same you used for the yaml + appApk(...) + testApk(...) + } diff --git a/src/main/kotlin/io/github/flank/gradle/tasks/FlankDoctorTask.kt b/src/main/kotlin/io/github/flank/gradle/tasks/FlankDoctorTask.kt index 3f9dd16..743bffe 100644 --- a/src/main/kotlin/io/github/flank/gradle/tasks/FlankDoctorTask.kt +++ b/src/main/kotlin/io/github/flank/gradle/tasks/FlankDoctorTask.kt @@ -31,8 +31,8 @@ abstract class FlankDoctorTask : BaseFlankApkTask() { .javaexec { classpath = flankJarClasspath mainClass.set("ftl.Main") - args = listOf("firebase", "test", "android", "doctor") - workingDir(projectLayout.buildDirectory.dir("flank/${variant.get()}").get().asFile) + args = listOf("firebase", "test", "android", "doctor", "-c=${flankYaml.get()}") + workingDir(projectLayout.buildDirectory.dir("flank/${variant.get()}").get()) } .assertNormalExitValue() } diff --git a/src/main/kotlin/io/github/flank/gradle/tasks/FlankRunTask.kt b/src/main/kotlin/io/github/flank/gradle/tasks/FlankRunTask.kt index d780b40..e62d2d1 100644 --- a/src/main/kotlin/io/github/flank/gradle/tasks/FlankRunTask.kt +++ b/src/main/kotlin/io/github/flank/gradle/tasks/FlankRunTask.kt @@ -68,9 +68,8 @@ abstract class FlankRunTask : BaseFlankApkTask() { .javaexec { classpath = flankJarClasspath mainClass.set("ftl.Main") - environment( - mapOf("GOOGLE_APPLICATION_CREDENTIALS" to serviceAccountCredentials.get().asFile)) - args = listOf("firebase", "test", "android", "run") + environment(mapOf("GOOGLE_APPLICATION_CREDENTIALS" to serviceAccountCredentials.get())) + args = listOf("firebase", "test", "android", "run", "-c=${flankYaml.get()}") if (dumpShards.get()) args("--dump-shards") if (dry.get()) args("--dry")