before_all do
  clear_derived_data if is_ci?
  reset_simulators if is_ci?
end

lane :localcoverage do
    test

    slather(
        html: true,
        scheme: "Sentry",
        output_directory: "fastlane/test_output/slather",
        show: true
    )
end

# Danger is already taken by the fastlane danger action:
# https://docs.fastlane.tools/actions/danger/
lane :dangerLint do
    if ENV["DANGER_GITHUB_API_TOKEN"]
        danger(
            github_api_token: ENV["DANGER_GITHUB_API_TOKEN"],
            danger_id: "github",
            dangerfile: "./Dangerfile",
            verbose: true
        )
    end
end

lane :lint do
    sh('cd ..; ./scripts/check-clang-format.py -r Sources Tests')
    swiftlint(
        mode: :lint,
        config_file: ".swiftlint.yml",
        raise_if_swiftlint_error: true
    )
end

lane :test do
    scan(scheme: "Sentry", code_coverage: true)
end
