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

#835 Added printing available iOS software versions #897

Merged
merged 4 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- [#890](https://github.com/Flank/flank/pull/890) Convert bitrise ubuntu workflow into GitHub actions. ([piotradamczyk5](https://github.com/piotradamczyk5))
- [#876](https://github.com/Flank/flank/pull/876) Added option to print Android available devices to test against. ([piotradamczyk5](https://github.com/piotradamczyk5))
- [#895](https://github.com/Flank/flank/pull/895) Added option to print iOS available devices to test against. ([piotradamczyk5](https://github.com/piotradamczyk5))
- [#897](https://github.com/Flank/flank/pull/897) Added option to print iOS available versions to test against. ([piotradamczyk5](https://github.com/piotradamczyk5))
-
-
-
Expand Down
3 changes: 3 additions & 0 deletions test_runner/docs/ascii/flank.jar_-firebase-test-ios.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ flank.jar
*models*::
Information about available models

*versions*::
Information about available software versions

// end::picocli-generated-man-section-commands[]

// end::picocli-generated-full-manpage[]
3 changes: 3 additions & 0 deletions test_runner/docs/ascii/flank.jar_-ios.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ flank.jar
*models*::
Information about available models

*versions*::
Information about available software versions

// end::picocli-generated-man-section-commands[]

// end::picocli-generated-full-manpage[]
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ftl.cli.firebase.test
import ftl.cli.firebase.test.ios.IosDoctorCommand
import ftl.cli.firebase.test.ios.IosRunCommand
import ftl.cli.firebase.test.ios.models.IosModelsCommand
import ftl.cli.firebase.test.ios.versions.IosVersionsCommand
import picocli.CommandLine
import picocli.CommandLine.Command

Expand All @@ -12,7 +13,8 @@ import picocli.CommandLine.Command
subcommands = [
IosRunCommand::class,
IosDoctorCommand::class,
IosModelsCommand::class
IosModelsCommand::class,
IosVersionsCommand::class
],
usageHelpAutoWidth = true
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ftl.cli.firebase.test.ios.versions

import picocli.CommandLine

@CommandLine.Command(
name = "versions",
subcommands = [IosVersionsListCommand::class],
headerHeading = "",
synopsisHeading = "%n",
descriptionHeading = "%n@|bold,underline Description:|@%n%n",
parameterListHeading = "%n@|bold,underline Parameters:|@%n",
optionListHeading = "%n@|bold,underline Options:|@%n",
header = ["Information about available software versions"],
description = ["Information about available software versions. For example prints list of available software versions"],
usageHelpAutoWidth = true
)
class IosVersionsCommand : Runnable {
override fun run() {
CommandLine.usage(IosVersionsCommand(), System.out)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package ftl.cli.firebase.test.ios.versions

import ftl.args.IosArgs
import ftl.config.FtlConstants
import ftl.ios.IosCatalog.softwareVersionsAsTable
import picocli.CommandLine
import java.nio.file.Paths

@CommandLine.Command(
name = "list",
headerHeading = "",
synopsisHeading = "%n",
descriptionHeading = "%n@|bold,underline Description:|@%n%n",
parameterListHeading = "%n@|bold,underline Parameters:|@%n",
optionListHeading = "%n@|bold,underline Options:|@%n",
header = ["List of OS versions available to test against"],
description = ["Print current list of iOS versions available to test against"],
usageHelpAutoWidth = true
)
class IosVersionsListCommand : Runnable {
override fun run() {
println(softwareVersionsAsTable(IosArgs.load(Paths.get(configPath)).project))
}

@CommandLine.Option(names = ["-c", "--config"], description = ["YAML config file path"])
var configPath: String = FtlConstants.defaultIosConfig

@CommandLine.Option(names = ["-h", "--help"], usageHelp = true, description = ["Prints this help message"])
var usageHelpRequested: Boolean = false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package ftl.environment

import com.google.api.services.testing.model.IosVersion
import ftl.util.applyColorsUsing
import ftl.util.buildTable

fun List<IosVersion>.asPrintableTable() = createTestEnvironmentInfo().createIOsSoftwareVersionsTable()

private fun List<IosVersion>.createTestEnvironmentInfo() =
fold(mutableMapOf<String, MutableList<String>>()) { softwareInfo, softwareVersion ->
softwareInfo.apply {
getOrCreateList(OS_VERSION_ID).add(softwareVersion.id.orUnknown())
getOrCreateList(MAJOR_VERSION).add(softwareVersion.majorVersion?.toString().orEmpty())
getOrCreateList(MINOR_VERSION).add(softwareVersion.minorVersion?.toString().orEmpty())
getOrCreateList(TAGS).add(softwareVersion.tags.orEmpty().joinToString())
getOrCreateList(SUPPORTED_XCODE_VERSION_IDS).add(softwareVersion.supportedXcodeVersionIds.joinToString())
}
}

private fun TestEnvironmentInfo.createIOsSoftwareVersionsTable() = buildTable(
createTableColumnFor(OS_VERSION_ID),
createTableColumnFor(MAJOR_VERSION),
createTableColumnFor(MINOR_VERSION),
createTableColumnFor(TAGS).applyColorsUsing(tagToSystemOutColorMapper),
createTableColumnFor(SUPPORTED_XCODE_VERSION_IDS)
)

private const val MAJOR_VERSION = "MAJOR_VERSION"
private const val MINOR_VERSION = "MINOR_VERSION"
private const val SUPPORTED_XCODE_VERSION_IDS = "SUPPORTED_XCODE_VERSION_IDS"
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ const val RESOLUTION = "RESOLUTION"
const val OS_VERSION_IDS = "OS_VERSION_IDS"
const val TAGS = "TAGS"
const val PHYSICAL_DEVICE = "PHYSICAL"
const val OS_VERSION_ID = "OS_VERSION_ID"
2 changes: 2 additions & 0 deletions test_runner/src/main/kotlin/ftl/ios/IosCatalog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ object IosCatalog {

fun devicesCatalogAsTable(projectId: String) = iosDeviceCatalog(projectId).models.asPrintableTable()

fun softwareVersionsAsTable(projectId: String) = iosDeviceCatalog(projectId).versions.asPrintableTable()

fun supportedXcode(version: String, projectId: String) = xcodeVersions(projectId).contains(version)

private fun xcodeVersions(projectId: String) =
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
package ftl.cli.firebase.test.ios.models

import com.google.common.truth.Truth.assertThat
import ftl.config.FtlConstants
import org.junit.Test
import picocli.CommandLine

class IosModelsListCommandTest {

@Test
fun iosModelsListCommandOptions() {
val cmd = IosModelsListCommand()
assertThat(cmd.configPath).isEqualTo(FtlConstants.defaultIosConfig)
cmd.configPath = "tmp"
assertThat(cmd.configPath).isEqualTo("tmp")

assertThat(cmd.usageHelpRequested).isFalse()
cmd.usageHelpRequested = true
assertThat(cmd.usageHelpRequested).isTrue()
}

@Test
fun iosModelsListCommandShouldParseConfig() {
val cmd = IosModelsListCommand()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ftl.cli.firebase.test.ios.versions

import com.google.common.truth.Truth.assertThat
import org.junit.Test
import picocli.CommandLine

class IosVersionsListCommandTest {

@Test
fun iosVersionsListCommandShouldParseConfig() {
val cmd = IosVersionsListCommand()
CommandLine(cmd).parseArgs("--config=a")

assertThat(cmd.configPath).isEqualTo("a")
}
}
19 changes: 19 additions & 0 deletions test_runner/src/test/kotlin/ftl/ios/IosCatalogTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,23 @@ class IosCatalogTest {
// number of separators match
assertThat(headers.count { it == '│' }).isEqualTo(expectedSeparatorCount)
}

@Test
fun `should print available software versions as table`() {
// given
val expectedHeaders = arrayOf("OS_VERSION_ID", "MAJOR_VERSION", "MINOR_VERSION", "TAGS", "SUPPORTED_XCODE_VERSION_IDS")
val expectedSeparatorCount = expectedHeaders.size + 1

// when
val devicesTable = IosCatalog.softwareVersionsAsTable(projectId)
val headers = devicesTable.lines()[1]

// then
// has all necessary headers
expectedHeaders.forEach {
assertThat(headers.contains(it)).isTrue()
}
// number of separators match
assertThat(headers.count { it == '│' }).isEqualTo(expectedSeparatorCount)
}
}