simple-flank is a Gradle plugin to use Flank in Android projects with no configuration needed

Overview

simple-flank

simple-flank is a new gradle plugin with a clear focus: make the setup as simple as possible.

Applied to any application or library module it creates a task called flankRun that will run all the android tests (all flavors, debug buildType by default)

Tests will be executed using NexusLowRes emulators, and the lower sdk possible (between minSdk and available SDKs at Firebase)

Setup

Apply the plugin on the application/library modules you want to run tests:

plugins {
  ...
  id("io.github.flank.gradle.simple-flank")
}

add your firebase credentials to the rootproject as ftl-credentials.json

That's it, run ./gradlew flankRun and get the results.

Optional configuration

simpleFlank {
  // Changing the credentials file, default: rootProject.file("ftl-credentials.json")
  credentialsFile.set(file("some-credentials.json"))
  
  // Making the tests cacheable
  hermeticTests.set(true)
  // if all modules have hermetic tests, add `simple-flank.hermeticTests=true` to your `gradle.properties`

  // Choosing the devices manually
  // default is NexusLowRes, and the minSdk from the project
  devices.set(listOf(
    io.github.flank.gradle.NexusLowRes(23),
    io.github.flank.gradle.NexusLowRes(30, "es_ES", io.github.flank.gradle.Device.Orientation.landscape),
    io.github.flank.gradle.Device("oriole", 31, "Google", "Pixel 6")
  ))

  // Filtering tests
  testTargets {
    inClass("io.flank.sample.TestClass")
    notInClass("io.flank.sample.NotATestClass", "io.flank.sample.NotATestClassEither")

    small() // or medium() or large()

    annotation("io.flank.test.InstrumentationTest")
    notAnnotation("io.flank.test.Flaky")

    inPackage("io.flank.sample")
    notInPackage("io.flank.external")

    testFile("/sdcard/tmp/testFile.txt")
    notTestFile("/sdcard/tmp/notTestFile.txt")

    regex("BarTest.*")

    filter("com.android.foo.MyCustomFilter", "com.android.foo.AnotherCustomFilter")

    runnerBuilder("com.android.foo.MyCustomBuilder", "com.android.foo.AnotherCustomBuilder")
  }

  // EnvironmentVariables
  // default 
  environmentVariables.set(mapOf("clearPackageData" to "true", "something" to "1", "whatever" to "I don't know"))

  // default extracted from credentials
  projectId.set("my-GCP-project")

  // Downloading files
  directoriesToPull.set(listOf("/sdcard/"))
  filesToDownload.set(listOf("a.txt","b.txt"))
  keepFilePath.set(true)


  // other options
  testTimeout.set("15m")
  recordVideo.set(true)
  numFlakyTestAttempts.set(3)
  failFast.set(true)
  performanceMetrics.set(true)
}

changing Flank version

dependencies {
  flankExecutable("com.github.flank:flank:21.11.0")
}

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"
  ...
}

What happens if I don't have android tests for a project?

Maybe you are applying simple-flank from a convention plugin to all your subprojects. That approach has some issues because you will run tasks you don't need, but it won't fail, Flank does validate it and abort the execution and simple-flank just ignores that error.

AGP by default considers that all projects have androidTest enabled, but you could fix that with something like:

variant.enableAndroidTest = false }">
  androidComponents.beforeVariants(selector().withName("MY_NO_TESTS_VARIANT")) { variant ->
    variant.enableAndroidTest = false
  }

or check if the androidTest folders exist:

  androidComponents.beforeVariants { variant ->
    val basePath = "$projectDir/src/androidTest"
    val buildTypedPath = basePath + variant.buildType?.capitalize()
    val flavoredPath = basePath + variant.flavorName?.capitalize()
    val variantPath = flavoredPath + variant.buildType?.capitalize()
    variant.enableAndroidTest = (
      file(basePath).exists() ||
      file(buildTypedPath).exists() ||
      file(flavoredPath).exists() ||
      file(variantPath).exists()
    )
  }

disabling androidTest will save a lot of build time because you won't need to compile, package and run flank for those project.

How to debug shards?

./gradlew flankRun -PdumpShards=true

What if I want to use a different flank config?

Feel free to create your own task and provide the config yaml you want.

Comments
  • Security Policy violation Binary Artifacts

    Security Policy violation Binary Artifacts

    This issue was automatically created by Allstar.

    Security Policy Violation Project is out of compliance with Binary Artifacts policy: binaries present in source code

    Rule Description Binary Artifacts are an increased security risk in your repository. Binary artifacts cannot be reviewed, allowing the introduction of possibly obsolete or maliciously subverted executables. For more information see the Security Scorecards Documentation for Binary Artifacts.

    Remediation Steps To remediate, remove the generated executable artifacts from the repository.

    Artifacts Found

    • gradle/wrapper/gradle-wrapper.jar

    Additional Information This policy is drawn from Security Scorecards, which is a tool that scores a project's adherence to security best practices. You may wish to run a Scorecards scan directly on this repository for more details.


    This issue will auto resolve when the policy is in compliance.

    Issue created by Allstar. See https://github.com/ossf/allstar/ for more information. For questions specific to the repository, please contact the owner or maintainer.

    allstar 
    opened by allstar-app[bot] 6
  • Security Policy violation Branch Protection

    Security Policy violation Branch Protection

    This issue was automatically created by Allstar.

    Security Policy Violation Dismiss stale reviews not configured for branch master


    This issue will auto resolve when the policy is in compliance.

    Issue created by Allstar. See https://github.com/ossf/allstar/ for more information. For questions specific to the repository, please contact the owner or maintainer.

    allstar 
    opened by allstar-app[bot] 1
  • Don't add tasks to the rootProject

    Don't add tasks to the rootProject

    It works (I had a bug, so it didn't really work always) but it's not a good practice to modify the rootProject from the subprojects. It was a premature optimization to reduce the number of tasks and copies of the credentials and smallApp

    opened by CristianGM 0
  • Improve Application signing validation

    Improve Application signing validation

    Move the validation from configuration time to FlankRunTask execution. Don't hardcode the signingConfig name, use the buildType one Make the task fail if using the default keystore with hermeticTests

    opened by CristianGM 0
  • Use Flank --dry option to remove the need for credentials on tests

    Use Flank --dry option to remove the need for credentials on tests

    closes #1 , closes #4

    Instead of creating integrationTest and require FTL credentials I decided to use the --dry option from Flank and make credentials unnecessary.

    opened by CristianGM 0
  • Macrobenchmark tests are not supported out of the box

    Macrobenchmark tests are not supported out of the box

    Simple-flank does not create the flankRun test when the module is a com.android.test, so it can not be used for macrobenchmark test out of the box https://developer.android.com/topic/performance/benchmarking/macrobenchmark-overview#setup-macrobenchmark

    We can workaround by creating a custom FlankRunTask setting the flank yaml file, but, ideally the plugin would create the task also for these sort of modules.

    BTW thanks a lot for the plugin, it works great! 💪

    opened by dmarin 0
Releases(v0.3.0)
  • v0.3.0(Jun 3, 2022)

  • v0.2.1(May 16, 2022)

  • v0.2.0(May 11, 2022)

    SimpleFlank is now more configurable:

    simpleFlank {
      // Changing the credentials file, default: rootProject.file("ftl-credentials.json")
      credentialsFile.set(file("some-credentials.json"))
      
      // Making the tests cacheable
      hermeticTests.set(true)
      // if all modules have hermetic tests, add `simple-flank.hermeticTests=true` to your `gradle.properties`
    
      // Choosing the devices manually
      // default is NexusLowRes, and the minSdk from the project
      devices.set(listOf(
        io.github.flank.gradle.NexusLowRes(23),
        io.github.flank.gradle.NexusLowRes(30, "es_ES", io.github.flank.gradle.Device.Orientation.landscape),
        io.github.flank.gradle.Device("oriole", 31, "Google", "Pixel 6")
      ))
    
      // Filtering tests
      testTargets {
        inClass("io.flank.sample.TestClass")
        notInClass("io.flank.sample.NotATestClass", "io.flank.sample.NotATestClassEither")
    
        small() // or medium() or large()
    
        annotation("io.flank.test.InstrumentationTest")
        notAnnotation("io.flank.test.Flaky")
    
        inPackage("io.flank.sample")
        notInPackage("io.flank.external")
    
        testFile("/sdcard/tmp/testFile.txt")
        notTestFile("/sdcard/tmp/notTestFile.txt")
    
        regex("BarTest.*")
    
        filter("com.android.foo.MyCustomFilter", "com.android.foo.AnotherCustomFilter")
    
        runnerBuilder("com.android.foo.MyCustomBuilder", "com.android.foo.AnotherCustomBuilder")
      }
    
      // EnvironmentVariables
      // default 
      environmentVariables.set(mapOf("clearPackageData" to "true", "something" to "1", "whatever" to "I don't know"))
    
      // default extracted from credentials
      projectId.set("my-GCP-project")
    
      // Downloading files
      directoriesToPull.set(listOf("/sdcard/"))
      filesToDownload.set(listOf("a.txt","b.txt"))
      keepFilePath.set(true)
    
    
      // other options
      testTimeout.set("15m")
      recordVideo.set(true)
      numFlakyTestAttempts.set(3)
      failFast.set(true)
      performanceMetrics.set(true)
    }
    
    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(May 5, 2022)

  • v0.0.2-retry(Apr 26, 2022)

  • v0.0.2(Apr 25, 2022)

Owner
Flank
Massively parallel Android and iOS test runner for Firebase Test Lab
Flank
⌨️ A tool that gives you a massive head start when building Compose based apps. It saves you from time-consuming setup and configuration

⌨️ A tool that gives you a massive head start when building Compose based apps. It saves you from time-consuming setup and configuration

theapache64 467 Dec 23, 2022
Sharkur is a fork of Purpur which adds more configuration and also some optimalization.

Sharkur Sharkur is a fork of Purpur which adds more configuration and also some optimization. API Javadoc Dependency Information Maven <repository>

SharkurMC 8 Aug 1, 2022
Dev Experience is a set of projects to make life easier for developers, in order to import, configure and use.

Dev Experience The experience that all developer need Dev Experience is a set of projects to make life easier for developers, in order to import, conf

Wagner Fernando Costa 3 Aug 31, 2022
A simple, modern and coroutine based Kotlin Email API for clientside projects

Kotlinmailer is a Kotlin Mail API, using coroutines and providing DSLs. It may be used in a Ktor Backend for verification mails.

David Bieregger 4 Oct 5, 2022
An Open-Source repository that contains all the Android Dev and Kotlin concepts and several projects on android ranging in difficulty making this repo completely beginner-friendly.

An Open-Source repository that contains all the Android Dev and Kotlin concepts and several projects on android ranging in difficulty making this repo completely beginner-friendly. The main aim of this repository is to help students who are learning Android Development or preparing for an Android Developer role-based job.

Mimo Patra 15 Dec 29, 2022
Collection of Small Android Projects

AndroidDemoProjects ActivityRecognition: Example of using Google Play Services to recognize a user's activity, such as running, walking, or riding a b

Paul Ruiz 601 Dec 9, 2022
This projects implements Github User search with Android Pagination 3 Library

GithubUser Search An Android App that lists the github users sorted by most followers Resources GitHub API Building Clone the git repository Build ./g

Siyanatullah Khan 3 Oct 12, 2022
Easy setup of static analysis tools for Android and Java projects.

[DEPRECATED] Gradle static analysis plugin ⚠️ A fork of this project is maintained at https://github.com/GradleUp/static-analysis-plugin/ Please migra

Novoda 408 Dec 19, 2022
An Open Source App which enables users to drop all their professional handles and projects at one place.

An Open Source App which enables users to drop all their professional handles and projects at one place. This is a Beginner Friendly Repository made for Open Source Enthusiasts who can contribute to the App during HacktoberFest 2021.

GDSC JSS Noida 32 May 26, 2022
Help users of coding platforms to create findable, well documented, secure and offering good quality projects

The Ambassador The Ambassador will help users of coding platforms to create findable, well documented and offering good quality projects. It measures

F. Hoffmann-La Roche 15 Nov 7, 2022
The App shows PR of Github Open Projects

GithubPull This App shows PR of Github Open Projects -> Developed using :- Kotlin Programming Language MVVM Design Pattern Data Binding Pagination for

Akshay Rohilla 0 Nov 2, 2021
This app is used to divide a particular task in subtask and assign it to others with priorities. This may be useful for team projects or collaborative work

TaskDivider-Android-App This app is used to divide a particular task in subtask and assign it to others with priorities. This may be useful for team p

Manikant Rai 1 Jan 10, 2022
PreTask - A project planner app that allows an enterprise to plan their projects work within a team

PreTask - A project planner app that allows an enterprise to plan their projects work within a team

Ashish Pimpre 1 Jan 27, 2022
PyCharm plugin for ruff. This plugin provides reformat code using ruff.

Ruff PyCharm Plugin A JetBrains PyCharm plugin for ruff. Help See documentation for more details. Sponsors ScreenShots Features Run ruff --fix as an a

Koudai Aono 4 Dec 17, 2022
A plugin for Termux to use native Android GUI components from CLI applications.

Termux:GUI This is a plugin for Termux that enables command line programs to use the native android GUI. In the examples directory you can find demo v

Termux 345 Jan 1, 2023
android + Kotlin + Semantic releases + SpotBugs + Jacoco + maven + Gradle + groovy + GitHub actions + SonarQube + commitlint

Contents Installation Package Root project build.gradle App project build.gradle Contributing Citation Copyright Installation Package The latest versi

AbdElraouf Sabri 9 Oct 25, 2022
A multi-modular Gradle project that encapsulates various modules to learn Kotlin language, tools and frameworks.

KotlinLearn This is a gradle project for the sole basis of exploring and learning Kotlin language, tools and frameworks. The root project wil encapsul

Victor Kiprop 2 Oct 10, 2021
A Kotlin/JVM Project Template with Gradle

kotlin-project-template A Kotlin/JVM Project Template with Gradle. Clone or npx

cog25 0 Dec 23, 2021
Kotlin + Tornadofx + Gradle 7.1

Sudoku Kotlin + Tornadofx + Gradle 7.1 View this post on Instagram A post shared by Hồ Sỹ Thế (@the.hosy) <script async src="//www.instagram.com/embed

Hồ Sỹ Thế 2 Jan 8, 2022