From 73254a8c0618ffa03766e79fcd3c02c6fa0526d3 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Fri, 17 Jul 2020 12:36:22 +0200 Subject: [PATCH 1/3] #835 Added printing available iOS software versions --- release_notes.md | 1 + .../ascii/flank.jar_-firebase-test-ios.adoc | 3 ++ test_runner/docs/ascii/flank.jar_-ios.adoc | 3 ++ .../ftl/cli/firebase/test/IosCommand.kt | 4 ++- .../test/ios/versions/IosVersionsCommand.kt | 21 +++++++++++++ .../ios/versions/IosVersionsListCommand.kt | 30 +++++++++++++++++++ .../ftl/environment/ListIOsSofwareVersions.kt | 30 +++++++++++++++++++ .../ftl/environment/TestEnvironmentInfo.kt | 1 + .../src/main/kotlin/ftl/ios/IosCatalog.kt | 2 ++ .../ftl/cli/firebase/test/IosCommandTest.kt | 28 ----------------- .../versions/IosVersionsListCommandTest.kt | 29 ++++++++++++++++++ .../src/test/kotlin/ftl/ios/IosCatalogTest.kt | 19 ++++++++++++ 12 files changed, 142 insertions(+), 29 deletions(-) create mode 100644 test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsCommand.kt create mode 100644 test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommand.kt create mode 100644 test_runner/src/main/kotlin/ftl/environment/ListIOsSofwareVersions.kt delete mode 100644 test_runner/src/test/kotlin/ftl/cli/firebase/test/IosCommandTest.kt create mode 100644 test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommandTest.kt diff --git a/release_notes.md b/release_notes.md index 9a1c6d1e91..27732ebb52 100644 --- a/release_notes.md +++ b/release_notes.md @@ -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)) +- [#896](https://github.com/Flank/flank/pull/896) Added option to print iOS available versions to test against. ([piotradamczyk5](https://github.com/piotradamczyk5)) - - - diff --git a/test_runner/docs/ascii/flank.jar_-firebase-test-ios.adoc b/test_runner/docs/ascii/flank.jar_-firebase-test-ios.adoc index c9a565ea6f..3fb634898a 100644 --- a/test_runner/docs/ascii/flank.jar_-firebase-test-ios.adoc +++ b/test_runner/docs/ascii/flank.jar_-firebase-test-ios.adoc @@ -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[] \ No newline at end of file diff --git a/test_runner/docs/ascii/flank.jar_-ios.adoc b/test_runner/docs/ascii/flank.jar_-ios.adoc index 66563e2894..4c0b5c7ec4 100644 --- a/test_runner/docs/ascii/flank.jar_-ios.adoc +++ b/test_runner/docs/ascii/flank.jar_-ios.adoc @@ -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[] \ No newline at end of file diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/IosCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/IosCommand.kt index e5e6b4d3b2..4d8a97146c 100644 --- a/test_runner/src/main/kotlin/ftl/cli/firebase/test/IosCommand.kt +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/IosCommand.kt @@ -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 @@ -12,7 +13,8 @@ import picocli.CommandLine.Command subcommands = [ IosRunCommand::class, IosDoctorCommand::class, - IosModelsCommand::class + IosModelsCommand::class, + IosVersionsCommand::class ], usageHelpAutoWidth = true ) diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsCommand.kt new file mode 100644 index 0000000000..219e246943 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsCommand.kt @@ -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) + } +} diff --git a/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommand.kt b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommand.kt new file mode 100644 index 0000000000..6a37fd6ddc --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommand.kt @@ -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 +} diff --git a/test_runner/src/main/kotlin/ftl/environment/ListIOsSofwareVersions.kt b/test_runner/src/main/kotlin/ftl/environment/ListIOsSofwareVersions.kt new file mode 100644 index 0000000000..4338988e75 --- /dev/null +++ b/test_runner/src/main/kotlin/ftl/environment/ListIOsSofwareVersions.kt @@ -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.asPrintableTable() = createTestEnvironmentInfo().createIOsSoftwareVersionsTable() + +private fun List.createTestEnvironmentInfo() = + fold(mutableMapOf>()) { 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" diff --git a/test_runner/src/main/kotlin/ftl/environment/TestEnvironmentInfo.kt b/test_runner/src/main/kotlin/ftl/environment/TestEnvironmentInfo.kt index b2f2ef2672..307e09dc46 100644 --- a/test_runner/src/main/kotlin/ftl/environment/TestEnvironmentInfo.kt +++ b/test_runner/src/main/kotlin/ftl/environment/TestEnvironmentInfo.kt @@ -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" diff --git a/test_runner/src/main/kotlin/ftl/ios/IosCatalog.kt b/test_runner/src/main/kotlin/ftl/ios/IosCatalog.kt index ba7646bf47..a4b58418d7 100644 --- a/test_runner/src/main/kotlin/ftl/ios/IosCatalog.kt +++ b/test_runner/src/main/kotlin/ftl/ios/IosCatalog.kt @@ -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) = diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/IosCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/IosCommandTest.kt deleted file mode 100644 index d6d3554d76..0000000000 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/test/IosCommandTest.kt +++ /dev/null @@ -1,28 +0,0 @@ -package ftl.cli.firebase.test - -import com.google.common.truth.Truth -import ftl.test.util.FlankTestRunner -import ftl.test.util.TestHelper.normalizeLineEnding -import org.junit.Rule -import org.junit.Test -import org.junit.contrib.java.lang.system.SystemOutRule -import org.junit.runner.RunWith - -@RunWith(FlankTestRunner::class) -class IosCommandTest { - @Rule - @JvmField - val systemOutRule: SystemOutRule = SystemOutRule().enableLog().muteForSuccessfulTests() - - @Test - fun androidCommandPrintsHelp() { - IosCommand().run() - val output = systemOutRule.log.normalizeLineEnding() - Truth.assertThat(output).startsWith( - "ios [COMMAND]\n" + - "Commands:\n" + - " run Run tests on Firebase Test Lab\n" + - " doctor Verifies flank firebase is setup correctly\n" - ) - } -} diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommandTest.kt new file mode 100644 index 0000000000..958cc94834 --- /dev/null +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommandTest.kt @@ -0,0 +1,29 @@ +package ftl.cli.firebase.test.ios.versions + +import com.google.common.truth.Truth.assertThat +import ftl.config.FtlConstants +import org.junit.Test +import picocli.CommandLine + +class IosVersionsListCommandTest { + + @Test + fun iosVersionsListCommandOptions() { + val cmd = IosVersionsListCommand() + 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 iosVersionsListCommandShouldParseConfig() { + val cmd = IosVersionsListCommand() + CommandLine(cmd).parseArgs("--config=a") + + assertThat(cmd.configPath).isEqualTo("a") + } +} diff --git a/test_runner/src/test/kotlin/ftl/ios/IosCatalogTest.kt b/test_runner/src/test/kotlin/ftl/ios/IosCatalogTest.kt index d79dca29f8..d2e035a9e1 100644 --- a/test_runner/src/test/kotlin/ftl/ios/IosCatalogTest.kt +++ b/test_runner/src/test/kotlin/ftl/ios/IosCatalogTest.kt @@ -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) + } } From 4cbc7c225d581483e138a237abdcce5987f241b8 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Fri, 17 Jul 2020 12:38:37 +0200 Subject: [PATCH 2/3] #835 update release notes --- release_notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_notes.md b/release_notes.md index 27732ebb52..13283447cb 100644 --- a/release_notes.md +++ b/release_notes.md @@ -2,7 +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)) -- [#896](https://github.com/Flank/flank/pull/896) Added option to print iOS available versions 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)) - - - From 5d7a298a04c00689b1cae5bf85e8d06636d9f15f Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Fri, 17 Jul 2020 15:58:57 +0200 Subject: [PATCH 3/3] #835 removed dummy tests --- .../test/ios/models/IosModelsListCommandTest.kt | 13 ------------- .../test/ios/versions/IosVersionsListCommandTest.kt | 13 ------------- 2 files changed, 26 deletions(-) diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/models/IosModelsListCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/models/IosModelsListCommandTest.kt index e35762d2dd..96060a0336 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/models/IosModelsListCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/models/IosModelsListCommandTest.kt @@ -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() diff --git a/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommandTest.kt b/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommandTest.kt index 958cc94834..aa0db5ca1c 100644 --- a/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommandTest.kt +++ b/test_runner/src/test/kotlin/ftl/cli/firebase/test/ios/versions/IosVersionsListCommandTest.kt @@ -1,24 +1,11 @@ package ftl.cli.firebase.test.ios.versions import com.google.common.truth.Truth.assertThat -import ftl.config.FtlConstants import org.junit.Test import picocli.CommandLine class IosVersionsListCommandTest { - @Test - fun iosVersionsListCommandOptions() { - val cmd = IosVersionsListCommand() - 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 iosVersionsListCommandShouldParseConfig() { val cmd = IosVersionsListCommand()