# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
#     https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

# ================ Platform ================

default_platform(:android)

# ================ Lanes ================

platform :android do

  before_all do
    clean_reports()
  end

  desc "Detekt checks"
  lane :detekt do
    run_detekt()
  end

  desc "Runs tests in app module"
  lane :test_app do
    run_app_tests()
  end

  desc "Runs tests in core module"
  lane :test_core do
    run_core_tests()
  end

  desc "Runs tests in launches module"
  lane :test_launches do
    run_launches_tests()
  end

  desc "Runs tests in detail module"
  lane :test_detail do
    run_detail_tests()
  end

  desc "Runs tests in repository module"
  lane :test_repository do
    run_repository_tests()
  end

# ================ Gradle tasks ================

  def run_detekt
    gradle(task: "detekt --continue")
  end

  def clean_reports
    gradle(task: "removeReports")
  end

  def run_app_tests
    gradle(task: "app:test --continue")
  end

  def run_core_tests
    gradle(task: "core:test --continue")
  end

  def run_launches_tests
    gradle(task: "features:launches:test --continue")
  end

  def run_detail_tests
    gradle(task: "features:detail:test --continue")
  end

  def run_repository_tests
    gradle(task: "repository:test --continue")
  end
end
