From a9061d07ee38d61bf58141c543a6b9bcbdf66a60 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Wed, 7 Oct 2020 14:25:22 +0200 Subject: [PATCH 01/95] feat: Change updateFlank script to Kotlin --- flank-bash/build.gradle.kts | 11 +++++++++ flank-bash/scripts/GradleCommand.kt | 6 +++++ flank-bash/scripts/updateFlank.main.kts | 32 +++++++++++++++++++++++++ settings.gradle.kts | 1 + 4 files changed, 50 insertions(+) create mode 100644 flank-bash/build.gradle.kts create mode 100644 flank-bash/scripts/GradleCommand.kt create mode 100644 flank-bash/scripts/updateFlank.main.kts diff --git a/flank-bash/build.gradle.kts b/flank-bash/build.gradle.kts new file mode 100644 index 0000000000..57c4f2d185 --- /dev/null +++ b/flank-bash/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + kotlin("jvm") +} + +dependencies { + implementation("org.jetbrains.kotlin:kotlin-scripting-common:${Versions.KOTLIN}") + implementation("org.jetbrains.kotlin:kotlin-scripting-jvm:${Versions.KOTLIN}") + implementation("org.jetbrains.kotlin:kotlin-scripting-jvm-host:${Versions.KOTLIN}") + implementation("org.jetbrains.kotlin:kotlin-scripting-dependencies:${Versions.KOTLIN}") + implementation("org.apache.ivy:ivy:2.5.0") +} diff --git a/flank-bash/scripts/GradleCommand.kt b/flank-bash/scripts/GradleCommand.kt new file mode 100644 index 0000000000..ea399169b9 --- /dev/null +++ b/flank-bash/scripts/GradleCommand.kt @@ -0,0 +1,6 @@ +import java.nio.file.Paths + +fun createGradleCommand( + workingDir: String, + options: List +) = "${Paths.get(workingDir, "gradlew").toString()} ${options.joinToString(" ")}" diff --git a/flank-bash/scripts/updateFlank.main.kts b/flank-bash/scripts/updateFlank.main.kts new file mode 100644 index 0000000000..b672c09672 --- /dev/null +++ b/flank-bash/scripts/updateFlank.main.kts @@ -0,0 +1,32 @@ +#!/usr/bin/env kotlin + +@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") +@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") +@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") +@file:Import("GradleCommand.kt") +@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") +@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) + +import eu.jrie.jetbrains.kotlinshell.shell.* +import java.nio.file.Path +import java.nio.file.Paths + +val rootDirectoryPath = Paths + .get("") + .toAbsolutePath() + .parent + .toString() + +val gradleCommand = createGradleCommand( + workingDir = rootDirectoryPath, + options = listOf(":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar") +) + +val flankDirectory: Path = Paths.get(rootDirectoryPath, "test_runner") + +shell { + gradleCommand() +} + +Paths.get(flankDirectory.toString(), "build", "libs", "flank.jar").toFile() + .copyTo(Paths.get(flankDirectory.toString(), "bash", "flank.jar").toFile(), overwrite = true) diff --git a/settings.gradle.kts b/settings.gradle.kts index 1bf1e0bb4d..c0a5acaea3 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -4,6 +4,7 @@ include( ":test_runner", ":firebase_apis:test_api", ":flank-scripts", + ":flank-bash", ":integration_tests", "samples:gradle-export-api", "test_projects:android" From 42a6370645c827ef41f5331146cd41fc8d2a8e95 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Wed, 7 Oct 2020 14:39:53 +0200 Subject: [PATCH 02/95] create PathHelper --- flank-bash/scripts/PathHelper.kt | 7 +++++++ flank-bash/scripts/updateFlank.main.kts | 7 +------ 2 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 flank-bash/scripts/PathHelper.kt diff --git a/flank-bash/scripts/PathHelper.kt b/flank-bash/scripts/PathHelper.kt new file mode 100644 index 0000000000..2f0b4005a6 --- /dev/null +++ b/flank-bash/scripts/PathHelper.kt @@ -0,0 +1,7 @@ +import java.nio.file.Paths + +val rootDirectoryPath = Paths + .get("") + .toAbsolutePath() + .parent + .toString() diff --git a/flank-bash/scripts/updateFlank.main.kts b/flank-bash/scripts/updateFlank.main.kts index b672c09672..65cb99b1b6 100644 --- a/flank-bash/scripts/updateFlank.main.kts +++ b/flank-bash/scripts/updateFlank.main.kts @@ -4,6 +4,7 @@ @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") @file:Import("GradleCommand.kt") +@file:Import("PathHelper.kt") @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) @@ -11,12 +12,6 @@ import eu.jrie.jetbrains.kotlinshell.shell.* import java.nio.file.Path import java.nio.file.Paths -val rootDirectoryPath = Paths - .get("") - .toAbsolutePath() - .parent - .toString() - val gradleCommand = createGradleCommand( workingDir = rootDirectoryPath, options = listOf(":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar") From fb5b26040f8e71db849f52c9404a1f35eb2cf78f Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Wed, 7 Oct 2020 16:07:49 +0200 Subject: [PATCH 03/95] added buildGo script --- flank-bash/scripts/buildGo.main.kts | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 flank-bash/scripts/buildGo.main.kts diff --git a/flank-bash/scripts/buildGo.main.kts b/flank-bash/scripts/buildGo.main.kts new file mode 100644 index 0000000000..724eb1c3a3 --- /dev/null +++ b/flank-bash/scripts/buildGo.main.kts @@ -0,0 +1,43 @@ +#!/usr/bin/env kotlin + +@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") +@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") +@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") + +@file:Import("PathHelper.kt") + +@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) + +import java.nio.file.Paths +import eu.jrie.jetbrains.kotlinshell.shell.* + +enum class GoOS( + val goName: String, + val directory: String, + val extension: String = "" +) { + LINUX("linux", "bin/linux"), + MAC("darwin", "bin/mac"), + WINDOWS("windows", "bin/win", ".exe"), +} + +private val goHelloDirectory = + (if (args.isNotEmpty()) Paths.get(args[1]) else Paths.get(rootDirectoryPath, "test_project", "gohello")) + .toString() +private val goHelloBinDirectoryPath = Paths.get(goHelloDirectory, "bin") + +fun createExecutable(os: GoOS) { + Paths.get(goHelloBinDirectoryPath.toString(), *os.directory.split('/').toTypedArray()) + .toFile() + .mkdirs() + shell { + "GOOS=${os.goName}"() + "GOARCH=amd64"() + "go build -o ./${os.directory}/gohello${os.extension}"() + } +} + +goHelloBinDirectoryPath.toFile().deleteRecursively() + +GoOS.values().forEach { createExecutable(it) } + From 54e3a776dda7bb57362b5199bb2a89009ba86b13 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 7 Oct 2020 16:30:06 +0200 Subject: [PATCH 04/95] GradleCommand, updateFlank - windows compability --- flank-bash/scripts/GradleCommand.kt | 5 ++++- flank-bash/scripts/updateFlank.main.kts | 2 -- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/flank-bash/scripts/GradleCommand.kt b/flank-bash/scripts/GradleCommand.kt index ea399169b9..36e31d6f8b 100644 --- a/flank-bash/scripts/GradleCommand.kt +++ b/flank-bash/scripts/GradleCommand.kt @@ -3,4 +3,7 @@ import java.nio.file.Paths fun createGradleCommand( workingDir: String, options: List -) = "${Paths.get(workingDir, "gradlew").toString()} ${options.joinToString(" ")}" +) = if (isWindows) "${Paths.get(workingDir, "gradlew.bat").toString()} ${options.joinToString(" ")}" +else "${Paths.get(workingDir, "gradlew").toString()} ${options.joinToString(" ")}" + +private val isWindows = System.getProperty("os.name").startsWith("Windows") diff --git a/flank-bash/scripts/updateFlank.main.kts b/flank-bash/scripts/updateFlank.main.kts index 65cb99b1b6..a5f1011232 100644 --- a/flank-bash/scripts/updateFlank.main.kts +++ b/flank-bash/scripts/updateFlank.main.kts @@ -1,5 +1,3 @@ -#!/usr/bin/env kotlin - @file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") From 45e0a32c123c54b16cb8c97dbeb8054c392e46aa Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Wed, 7 Oct 2020 16:32:47 +0200 Subject: [PATCH 05/95] fix GradleCommand.kt --- flank-bash/scripts/GradleCommand.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/flank-bash/scripts/GradleCommand.kt b/flank-bash/scripts/GradleCommand.kt index 36e31d6f8b..2e10e2e372 100644 --- a/flank-bash/scripts/GradleCommand.kt +++ b/flank-bash/scripts/GradleCommand.kt @@ -3,7 +3,9 @@ import java.nio.file.Paths fun createGradleCommand( workingDir: String, options: List -) = if (isWindows) "${Paths.get(workingDir, "gradlew.bat").toString()} ${options.joinToString(" ")}" -else "${Paths.get(workingDir, "gradlew").toString()} ${options.joinToString(" ")}" +) = "${Paths.get(workingDir, gradleExecutable).toString()} ${options.joinToString(" ")}" + +private val gradleExecutable: String + get() = if(isWindows) "gradlew.bat" else "gradlew" private val isWindows = System.getProperty("os.name").startsWith("Windows") From 8146ca4c2e6e3ec114a99f133bff5f763c414cf4 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Wed, 7 Oct 2020 16:37:56 +0200 Subject: [PATCH 06/95] added buildFlankScripts.main.kts --- flank-bash/scripts/buildFlankScripts.main.kts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 flank-bash/scripts/buildFlankScripts.main.kts diff --git a/flank-bash/scripts/buildFlankScripts.main.kts b/flank-bash/scripts/buildFlankScripts.main.kts new file mode 100644 index 0000000000..19f75420ff --- /dev/null +++ b/flank-bash/scripts/buildFlankScripts.main.kts @@ -0,0 +1,25 @@ +@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") +@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") +@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") +@file:Import("GradleCommand.kt") +@file:Import("PathHelper.kt") +@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") +@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) + +import eu.jrie.jetbrains.kotlinshell.shell.* +import java.nio.file.Path +import java.nio.file.Paths + +val gradleCommand = createGradleCommand( + workingDir = rootDirectoryPath, + options = listOf(":flank-scripts:clean", ":flank-scripts:assemble", ":flank-scripts:shadowJar") +) + +val flankScriptsDirectory: Path = Paths.get(rootDirectoryPath, "flank-scripts") + +shell { + gradleCommand() +} + +Paths.get(flankScriptsDirectory.toString(), "build", "libs", "flankScripts.jar").toFile() + .copyTo(Paths.get(flankScriptsDirectory.toString(), "bash", "flankScripts.jar").toFile(), overwrite = true) From b4f9081ebe21ebc639b4ad629d789431dfc1ecf1 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Wed, 7 Oct 2020 17:07:47 +0200 Subject: [PATCH 07/95] fixed buildGo script --- flank-bash/scripts/buildGo.main.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flank-bash/scripts/buildGo.main.kts b/flank-bash/scripts/buildGo.main.kts index 724eb1c3a3..3d0904219c 100644 --- a/flank-bash/scripts/buildGo.main.kts +++ b/flank-bash/scripts/buildGo.main.kts @@ -22,7 +22,7 @@ enum class GoOS( } private val goHelloDirectory = - (if (args.isNotEmpty()) Paths.get(args[1]) else Paths.get(rootDirectoryPath, "test_project", "gohello")) + (if (args.isNotEmpty()) Paths.get(args.first()) else Paths.get(rootDirectoryPath, "test_project", "gohello")) .toString() private val goHelloBinDirectoryPath = Paths.get(goHelloDirectory, "bin") From 0ccd2549b2ef962674bbda705b14d6d26a33b7c4 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Wed, 7 Oct 2020 17:27:40 +0200 Subject: [PATCH 08/95] added testFilters helpers --- flank-bash/scripts/TestFilters.kt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 flank-bash/scripts/TestFilters.kt diff --git a/flank-bash/scripts/TestFilters.kt b/flank-bash/scripts/TestFilters.kt new file mode 100644 index 0000000000..e101d5f1dc --- /dev/null +++ b/flank-bash/scripts/TestFilters.kt @@ -0,0 +1,27 @@ +private const val PACKAGE = "com.example.test_app" +private const val PACKAGE_FOO = "com.example.test_app.foo" +private const val PACKAGE_BAR = "com.example.test_app.bar" + +private const val ANNOTATION = "$PACKAGE.Annotation" + +private const val CLASS = "$PACKAGE.InstrumentedTest" +private const val CLASS_FOO = "$PACKAGE_FOO.FooInstrumentedTest" +private const val CLASS_BAR = "$PACKAGE_BAR.BarInstrumentedTest" + +private const val METHOD_1 = "$CLASS#test1" +private const val METHOD_FOO = "$CLASS_FOO#testFoo" +private const val METHOD_BAR = "$CLASS_BAR#testBar" + +private const val RUNNER = "com.example.test_app.test/androidx.test.runner.AndroidJUnitRunner" + +val runAllTestsShellCommand: String + get() = "adb shell am instrument -r -w \$@ $RUNNER" + +val filterPackageBarClassFooMethod1Command: String + get() = "$runAllTestsShellCommand -e package $PACKAGE_BAR -e class $CLASS_FOO -e class $METHOD_1" + +val filterAnnotationMethodFooCommand: String + get() = "$runAllTestsShellCommand -e annotation $ANNOTATION -e class $METHOD_FOO" + +val filterNotPackageFooNotClassBarCommand: String + get() = "$runAllTestsShellCommand -e notPackage $PACKAGE_FOO -e notClass $CLASS_BAR" From 089e3381e03df7f9b2e96b8ba90db52eb0e280f9 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 7 Oct 2020 18:29:36 +0200 Subject: [PATCH 09/95] Add android paths, initial work of android build command --- flank-bash/scripts/PathHelper.kt | 5 +++++ flank-bash/scripts/android.ops.main.kts | 24 ++++++++++++++++++++++++ flank-bash/scripts/ops.main.kts | 25 +++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 flank-bash/scripts/android.ops.main.kts create mode 100644 flank-bash/scripts/ops.main.kts diff --git a/flank-bash/scripts/PathHelper.kt b/flank-bash/scripts/PathHelper.kt index 2f0b4005a6..25fe6f5d2b 100644 --- a/flank-bash/scripts/PathHelper.kt +++ b/flank-bash/scripts/PathHelper.kt @@ -5,3 +5,8 @@ val rootDirectoryPath = Paths .toAbsolutePath() .parent .toString() + +val testProjectsPath = Paths.get(rootDirectoryPath, "test_projects").toString() +val androidTestProjectsPath = Paths.get(testProjectsPath, "android").toString() +val iOsTestProjectsPath = Paths.get(testProjectsPath, "ios").toString() +val flankFixturesTmpPath = Paths.get(rootDirectoryPath, "/test_runner/src/test/kotlin/ftl/fixtures/tmp").toString() diff --git a/flank-bash/scripts/android.ops.main.kts b/flank-bash/scripts/android.ops.main.kts new file mode 100644 index 0000000000..514c552df6 --- /dev/null +++ b/flank-bash/scripts/android.ops.main.kts @@ -0,0 +1,24 @@ +@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") +@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") +@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") +@file:Import("GradleCommand.kt") +@file:Import("PathHelper.kt") +@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") +@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) + +import eu.jrie.jetbrains.kotlinshell.shell.* + +fun generateApkAndTests() { + baseAppApk() +} + +val buildBaseApk = createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, "app:clean", "app:assemble") +) + +fun baseAppApk() { + shell { + buildBaseApk() + } +} diff --git a/flank-bash/scripts/ops.main.kts b/flank-bash/scripts/ops.main.kts new file mode 100644 index 0000000000..18375cf782 --- /dev/null +++ b/flank-bash/scripts/ops.main.kts @@ -0,0 +1,25 @@ +@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") +@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") +@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") +@file:Import("GradleCommand.kt") +@file:Import("PathHelper.kt") +@file:Import("android.ops.main.kts") +@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") +@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) + +import eu.jrie.jetbrains.kotlinshell.shell.* + +shell { + args.map { it.toUpperCase() }.onEach { + when (it) { + OpsOptions.ANDROID.toString() -> generateApkAndTests() + } + } +} + + +enum class OpsOptions { + ANDROID, + IOS, + GO +} From 3907e38af745204422150b247cc3784a194bab9d Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 8 Oct 2020 18:10:37 +0200 Subject: [PATCH 10/95] Add build of base android apk and tests with copy to directory --- flank-bash/scripts/android.ops.main.kts | 37 +++++++++++++++++++++---- flank-bash/scripts/ops.main.kts | 17 +++++------- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/flank-bash/scripts/android.ops.main.kts b/flank-bash/scripts/android.ops.main.kts index 514c552df6..3ec1e60a77 100644 --- a/flank-bash/scripts/android.ops.main.kts +++ b/flank-bash/scripts/android.ops.main.kts @@ -6,19 +6,46 @@ @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) +import java.io.File +import java.nio.file.Files +import java.nio.file.Paths import eu.jrie.jetbrains.kotlinshell.shell.* - -fun generateApkAndTests() { - baseAppApk() -} +import java.nio.file.StandardCopyOption val buildBaseApk = createGradleCommand( workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, "app:clean", "app:assemble") + options = listOf("-p", androidTestProjectsPath, "app:assemble") ) +val buildBaseTestApk = createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, "app:assembleAndroidTest") +) + +fun generateApkAndTests() { + baseAppApk() + baseTesApks() +} + fun baseAppApk() { shell { buildBaseApk() + val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "singleSuccess", "debug", "app-single-success-debug.apk") + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "app-debug.apk") + if(!outputDir.parent.toFile().exists()){ + Files.createDirectories(outputDir.parent) + } + Files.copy(assembleDirectory, outputDir, StandardCopyOption.REPLACE_EXISTING) + } +} + +fun baseTesApks() { + shell { + buildBaseTestApk() + val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "androidTest") + File(assembleDirectory.toString()).walk().filter { it.extension == "apk" }.forEach { + File("test.log").appendText("Test FILE: ${it.toPath()}") + Files.copy(it.toPath(), Paths.get(flankFixturesTmpPath, "apk", it.name)) + } } } diff --git a/flank-bash/scripts/ops.main.kts b/flank-bash/scripts/ops.main.kts index 18375cf782..227944795e 100644 --- a/flank-bash/scripts/ops.main.kts +++ b/flank-bash/scripts/ops.main.kts @@ -1,14 +1,18 @@ @file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") -@file:Import("GradleCommand.kt") -@file:Import("PathHelper.kt") -@file:Import("android.ops.main.kts") +@file:Import("androidOps.main.kts") @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) import eu.jrie.jetbrains.kotlinshell.shell.* +enum class OpsOptions { + ANDROID, + IOS, + GO +} + shell { args.map { it.toUpperCase() }.onEach { when (it) { @@ -16,10 +20,3 @@ shell { } } } - - -enum class OpsOptions { - ANDROID, - IOS, - GO -} From 6819e5abcce76846ea984ffff637fb2ec1341f35 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Fri, 9 Oct 2020 09:24:42 +0200 Subject: [PATCH 11/95] added update library kotlin script --- flank-bash/scripts/updateBinaries.main.kts | 25 +++++++++ .../scripts/updateLibs/downloadFiles.main.kts | 17 ++++++ flank-bash/scripts/updateLibs/unpack.main.kts | 42 ++++++++++++++ .../scripts/updateLibs/updateAtomic.main.kts | 55 ++++++++++++++++++ .../scripts/updateLibs/updateLlvm.main.kts | 56 +++++++++++++++++++ .../scripts/updateLibs/updateSwift.main.kts | 55 ++++++++++++++++++ 6 files changed, 250 insertions(+) create mode 100644 flank-bash/scripts/updateBinaries.main.kts create mode 100644 flank-bash/scripts/updateLibs/downloadFiles.main.kts create mode 100644 flank-bash/scripts/updateLibs/unpack.main.kts create mode 100644 flank-bash/scripts/updateLibs/updateAtomic.main.kts create mode 100644 flank-bash/scripts/updateLibs/updateLlvm.main.kts create mode 100644 flank-bash/scripts/updateLibs/updateSwift.main.kts diff --git a/flank-bash/scripts/updateBinaries.main.kts b/flank-bash/scripts/updateBinaries.main.kts new file mode 100644 index 0000000000..af50f27046 --- /dev/null +++ b/flank-bash/scripts/updateBinaries.main.kts @@ -0,0 +1,25 @@ +@file:Repository("https://repo1.maven.org/maven2/org/rauschig/jarchivelib/") +@file:DependsOn("org.rauschig:jarchivelib:1.1.0") +@file:DependsOn("org.tukaani:xz:1.0") + +@file:Repository("https://dl.bintray.com/kittinunf/maven/com/github/kittinunf/fuel/fuel/") +@file:DependsOn("com.github.kittinunf.fuel:fuel:2.3.0") +@file:DependsOn("com.github.kittinunf.fuel:fuel-coroutines:2.3.0") + +@file:Import("./updateLibs/updateAtomic.main.kts") +@file:Import("./updateLibs/updateLlvm.main.kts") +@file:Import("./updateLibs/updateSwift.main.kts") + +@file:DependsOn("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9") + +import java.io.File +import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.launch + +runBlocking { + launch { updateAtomic() } + launch { updateLlvm() } + launch { updateSwift() } +} + +println("Binaries updated!") diff --git a/flank-bash/scripts/updateLibs/downloadFiles.main.kts b/flank-bash/scripts/updateLibs/downloadFiles.main.kts new file mode 100644 index 0000000000..fcb65dab90 --- /dev/null +++ b/flank-bash/scripts/updateLibs/downloadFiles.main.kts @@ -0,0 +1,17 @@ +@file:Repository("https://dl.bintray.com/kittinunf/maven/com/github/kittinunf/fuel/fuel/") +@file:DependsOn("com.github.kittinunf.fuel:fuel:2.3.0") +@file:DependsOn("com.github.kittinunf.fuel:fuel-coroutines:2.3.0") + +import com.github.kittinunf.fuel.Fuel +import java.io.File + +fun downloadFile( + url: String, + destinationPath: String +) { + println("Downloading from $url") + Fuel.download(url) + .fileDestination { _, _ -> File(destinationPath) } + .response() +} + diff --git a/flank-bash/scripts/updateLibs/unpack.main.kts b/flank-bash/scripts/updateLibs/unpack.main.kts new file mode 100644 index 0000000000..bf05dc238c --- /dev/null +++ b/flank-bash/scripts/updateLibs/unpack.main.kts @@ -0,0 +1,42 @@ +@file:Repository("https://repo1.maven.org/maven2/org/rauschig/jarchivelib/") +@file:DependsOn("org.rauschig:jarchivelib:1.1.0") +@file:DependsOn("org.tukaani:xz:1.0") + +import org.rauschig.jarchivelib.* +import java.io.File + +fun File.extract( + destination: File, + archiveFormat: ArchiveFormat = ArchiveFormat.AR, + compressFormat: CompressionType? = null +) { + println("Unpacking...$name") + val archiver = if (compressFormat != null) { + ArchiverFactory.createArchiver(archiveFormat, compressFormat) + } else { + ArchiverFactory.createArchiver(archiveFormat) + } + kotlin.runCatching { + archiver.extract(this, destination) + }.onFailure { + println("There was an error when unpacking $name") + } +} + +fun File.extract( + destination: File, + archiveFormat: String, + compressFormat: String? = null +) { + println("Unpacking...$name") + val archiver = if (compressFormat != null) { + ArchiverFactory.createArchiver(archiveFormat, compressFormat) + } else { + ArchiverFactory.createArchiver(archiveFormat) + } + kotlin.runCatching { + archiver.extract(this, destination) + }.onFailure { + println("There was an error when unpacking $name") + } +} diff --git a/flank-bash/scripts/updateLibs/updateAtomic.main.kts b/flank-bash/scripts/updateLibs/updateAtomic.main.kts new file mode 100644 index 0000000000..b551dd4761 --- /dev/null +++ b/flank-bash/scripts/updateLibs/updateAtomic.main.kts @@ -0,0 +1,55 @@ +@file:CompilerOptions("jvmTarget = '1.8'") + +@file:Import("downloadFiles.main.kts") +@file:Import("unpack.main.kts") + +import java.io.File +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.StandardCopyOption +import java.util.stream.Collectors + +private val currentPath = Paths.get("") +private val atomicPath = Paths.get(currentPath.toString(), "libatomic") + +fun updateAtomic() { + val atomicDeb = Paths.get(atomicPath.toString(), "libatomic.deb").toFile() + val atomicDataTarXz = Paths.get(atomicPath.toString(), "data.tar.xz").toFile() + + if (atomicDeb.exists()) { + println("Atomic exists") + } else { + println("Downloading Atomic...") + atomicPath.toFile().mkdirs() + downloadFile( + url = "http://mirrors.kernel.org/ubuntu/pool/main/g/gcc-8/libatomic1_8-20180414-1ubuntu2_amd64.deb", + destinationPath = atomicDeb.toString() + ) + } + + atomicDeb.extract(atomicPath.toFile(), "ar") + atomicDataTarXz.extract(atomicPath.toFile(), "tar", "xz") + findAndCopyLicense() + findAndCopyAtomicFiles() + atomicPath.toFile().deleteRecursively() +} + +fun findAndCopyLicense() { + val licenseOutputFile = Paths.get(currentPath.toString(), "libatomic.txt").toFile() + + downloadFile( + "http://changelogs.ubuntu.com/changelogs/pool/main/g/gcc-8/gcc-8_8-20180414-1ubuntu2/copyright", + licenseOutputFile.toString() + ) +} + +fun findAndCopyAtomicFiles() { + println("Copying atomic files ...") + val list = Files.walk(atomicPath) + .filter { it.toString().endsWith("libatomic.so.1") || it.toString().endsWith("libatomic.so.1.2.0") } + .collect(Collectors.toList()) + + list.forEach { + it.toFile().copyTo(Paths.get(currentPath.toString(), it.fileName.toString()).toFile(), true) + } +} diff --git a/flank-bash/scripts/updateLibs/updateLlvm.main.kts b/flank-bash/scripts/updateLibs/updateLlvm.main.kts new file mode 100644 index 0000000000..a50d6f53b5 --- /dev/null +++ b/flank-bash/scripts/updateLibs/updateLlvm.main.kts @@ -0,0 +1,56 @@ +@file:CompilerOptions("jvmTarget = '1.8'") + +@file:Import("downloadFiles.main.kts") +@file:Import("unpack.main.kts") + +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.StandardCopyOption + +private val currentPath = Paths.get("") +private val llvmPath = Paths.get(currentPath.toString(), "llvm") + +fun updateLlvm() { + val llvmTarXz = Paths.get(llvmPath.toString(), "llvm.tar.xz") + + if (llvmTarXz.toFile().exists()) { + println("LLVM exists") + } else { + println("Downloading LLVM...") + llvmPath.toFile().mkdirs() + downloadFile( + url = "http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz", + destinationPath = llvmTarXz.toString() + ) + } + + llvmTarXz.toFile().extract(llvmPath.toFile(), "tar", "xz") + findAndCopyLicense() + findAndCopyLlvmNmFile() + llvmPath.toFile().deleteRecursively() +} + + +fun findAndCopyLicense() { + val licensePathSuffix = Paths.get("include","llvm","Support" ,"LICENSE.TXT").toString() + val licenseOutputFile = Paths.get(currentPath.toString(), "llvm.txt").toFile() + + println("Copying license ...") + Files.walk(llvmPath) + .filter { it.toString().endsWith(licensePathSuffix) } + .findFirst() + .takeIf { it.isPresent } + ?.run { get().toFile().copyTo(licenseOutputFile, overwrite = true) } +} + +fun findAndCopyLlvmNmFile() { + val llvmNmSuffix = Paths.get("bin","llvm-nm").toString() + val llvmNmOutputFile = Paths.get(currentPath.toString(), "nm").toFile() + + println("Copying llvm nm ...") + Files.walk(llvmPath) + .filter { it.toString().endsWith(llvmNmSuffix) } + .findFirst() + .takeIf { it.isPresent } + ?.run { get().toFile().copyTo(llvmNmOutputFile, overwrite = true) } +} diff --git a/flank-bash/scripts/updateLibs/updateSwift.main.kts b/flank-bash/scripts/updateLibs/updateSwift.main.kts new file mode 100644 index 0000000000..0c09fe2f1c --- /dev/null +++ b/flank-bash/scripts/updateLibs/updateSwift.main.kts @@ -0,0 +1,55 @@ +@file:CompilerOptions("jvmTarget = '1.8'") + +@file:Import("downloadFiles.main.kts") +@file:Import("unpack.main.kts") + +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.StandardCopyOption + +private val currentPath = Paths.get("") +private val swiftPath = Paths.get(currentPath.toString(), "swift") + +fun updateSwift() { + val swiftTarGz = Paths.get(swiftPath.toString(), "swift.tar.gz") + + if (swiftTarGz.toFile().exists()) { + println("Swift exists") + } else { + println("Downloading swift") + swiftPath.toFile().mkdirs() + downloadFile( + url = "https://swift.org/builds/swift-5.0.1-release/ubuntu1604/swift-5.0.1-RELEASE/swift-5.0.1-RELEASE-ubuntu16.04.tar.gz", + destinationPath = swiftTarGz.toString() + ) + } + + swiftTarGz.toFile().extract(swiftPath.toFile(), "tar", "gz") + findAndCopyLicense() + findAndCopySwiftDemangleFile() + swiftPath.toFile().deleteRecursively() +} + +fun findAndCopyLicense() { + val licenseFileSuffix = Paths.get("usr", "share", "swift", "LICENSE.txt").toString() + val licenseOutputFile = Paths.get(currentPath.toString(), "swift.txt").toFile() + + println("Copying license ...") + Files.walk(swiftPath) + .filter { it.toString().endsWith(licenseFileSuffix) } + .findFirst() + .takeIf { it.isPresent } + ?.run { get().toFile().copyTo(licenseOutputFile, overwrite = true) } +} + +fun findAndCopySwiftDemangleFile() { + val switftDemangleFileSuffix = Paths.get("usr", "bin", "swift-demangle").toString() + val switftDemangleOutputFile = Paths.get(currentPath.toString(), "swift-demangle").toFile() + + println("Copying swift-demangle ...") + Files.walk(swiftPath) + .filter { it.toString().endsWith(switftDemangleFileSuffix) } + .findFirst() + .takeIf { it.isPresent } + ?.run { get().toFile().copyTo(switftDemangleOutputFile, overwrite = true) } +} From 2f1473bf367825a881a9097c846d28002b2ae000 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Fri, 9 Oct 2020 11:49:15 +0200 Subject: [PATCH 12/95] WIP added first iteration of windows file downloads --- .../scripts/updateLibs/downloadFiles.main.kts | 10 ++++++- flank-bash/scripts/updateLibs/unpack.main.kts | 4 +-- .../scripts/updateLibs/update.constants.kts | 3 ++ .../scripts/updateLibs/updateLlvm.main.kts | 29 ++++++++++++++++--- .../scripts/updateLibs/updateSwift.main.kts | 25 +++++++++++++++- 5 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 flank-bash/scripts/updateLibs/update.constants.kts diff --git a/flank-bash/scripts/updateLibs/downloadFiles.main.kts b/flank-bash/scripts/updateLibs/downloadFiles.main.kts index fcb65dab90..9b9aa70ae6 100644 --- a/flank-bash/scripts/updateLibs/downloadFiles.main.kts +++ b/flank-bash/scripts/updateLibs/downloadFiles.main.kts @@ -8,10 +8,18 @@ import java.io.File fun downloadFile( url: String, destinationPath: String -) { +) { println("Downloading from $url") + var lastUpdate = 0L Fuel.download(url) .fileDestination { _, _ -> File(destinationPath) } + .progress { readBytes, totalBytes -> + if (System.currentTimeMillis() - lastUpdate > 2000) { + lastUpdate = System.currentTimeMillis() + val progress = readBytes.toFloat() / totalBytes.toFloat() * 100 + println("Bytes downloaded $readBytes / $totalBytes ($progress %)") + } + } .response() } diff --git a/flank-bash/scripts/updateLibs/unpack.main.kts b/flank-bash/scripts/updateLibs/unpack.main.kts index bf05dc238c..c5b8821662 100644 --- a/flank-bash/scripts/updateLibs/unpack.main.kts +++ b/flank-bash/scripts/updateLibs/unpack.main.kts @@ -19,7 +19,7 @@ fun File.extract( kotlin.runCatching { archiver.extract(this, destination) }.onFailure { - println("There was an error when unpacking $name") + println("There was an error when unpacking $name - $it") } } @@ -37,6 +37,6 @@ fun File.extract( kotlin.runCatching { archiver.extract(this, destination) }.onFailure { - println("There was an error when unpacking $name") + println("There was an error when unpacking $name - $it") } } diff --git a/flank-bash/scripts/updateLibs/update.constants.kts b/flank-bash/scripts/updateLibs/update.constants.kts new file mode 100644 index 0000000000..471651fecf --- /dev/null +++ b/flank-bash/scripts/updateLibs/update.constants.kts @@ -0,0 +1,3 @@ + val isWindows = System.getProperty("os.name").startsWith("Windows") + val isMacOS = System.getProperty("os.name").indexOf("mac") >= 0 + val isLinux = !isWindows && !isMacOS \ No newline at end of file diff --git a/flank-bash/scripts/updateLibs/updateLlvm.main.kts b/flank-bash/scripts/updateLibs/updateLlvm.main.kts index a50d6f53b5..ae39b73da2 100644 --- a/flank-bash/scripts/updateLibs/updateLlvm.main.kts +++ b/flank-bash/scripts/updateLibs/updateLlvm.main.kts @@ -2,6 +2,7 @@ @file:Import("downloadFiles.main.kts") @file:Import("unpack.main.kts") +@file:Import("update.constants.kts") import java.nio.file.Files import java.nio.file.Paths @@ -10,13 +11,32 @@ import java.nio.file.StandardCopyOption private val currentPath = Paths.get("") private val llvmPath = Paths.get(currentPath.toString(), "llvm") -fun updateLlvm() { +fun updateLlvmWindows() { + val llvmExe = Paths.get(llvmPath.toString(), "LLVM-win64.exe") + if (llvmExe.toFile().exists()) { + println("LLVM exists") + } else { + println("Downloading Windows LLVM...") + llvmPath.toFile().mkdirs() + downloadFile( + url = "https://releases.llvm.org/8.0.0/LLVM-8.0.0-win64.exe", + destinationPath = llvmExe.toString() + ) + } + + llvmExe.toFile().extract(llvmPath.toFile(), "zip", "xz") + findAndCopyLicense() + findAndCopyLlvmNmFile() + llvmPath.toFile().deleteRecursively() +} + +fun updateLlvmNonWindows() { val llvmTarXz = Paths.get(llvmPath.toString(), "llvm.tar.xz") if (llvmTarXz.toFile().exists()) { println("LLVM exists") } else { - println("Downloading LLVM...") + println("Downloading LLVM for Windows...") llvmPath.toFile().mkdirs() downloadFile( url = "http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz", @@ -30,9 +50,10 @@ fun updateLlvm() { llvmPath.toFile().deleteRecursively() } +fun updateLlvm() = if (isWindows) updateLlvmWindows() else updateLlvmNonWindows() fun findAndCopyLicense() { - val licensePathSuffix = Paths.get("include","llvm","Support" ,"LICENSE.TXT").toString() + val licensePathSuffix = Paths.get("include", "llvm", "Support", "LICENSE.TXT").toString() val licenseOutputFile = Paths.get(currentPath.toString(), "llvm.txt").toFile() println("Copying license ...") @@ -44,7 +65,7 @@ fun findAndCopyLicense() { } fun findAndCopyLlvmNmFile() { - val llvmNmSuffix = Paths.get("bin","llvm-nm").toString() + val llvmNmSuffix = Paths.get("bin", "llvm-nm").toString() val llvmNmOutputFile = Paths.get(currentPath.toString(), "nm").toFile() println("Copying llvm nm ...") diff --git a/flank-bash/scripts/updateLibs/updateSwift.main.kts b/flank-bash/scripts/updateLibs/updateSwift.main.kts index 0c09fe2f1c..d4dc815fdb 100644 --- a/flank-bash/scripts/updateLibs/updateSwift.main.kts +++ b/flank-bash/scripts/updateLibs/updateSwift.main.kts @@ -2,6 +2,7 @@ @file:Import("downloadFiles.main.kts") @file:Import("unpack.main.kts") +@file:Import("update.constants.kts") import java.nio.file.Files import java.nio.file.Paths @@ -10,7 +11,27 @@ import java.nio.file.StandardCopyOption private val currentPath = Paths.get("") private val swiftPath = Paths.get(currentPath.toString(), "swift") -fun updateSwift() { +fun updateSwiftWindows() { + val swiftExe = Paths.get(swiftPath.toString(), "swift.exe") + + if (swiftExe.toFile().exists()) { + println("Swift exists") + } else { + println("Downloading swift") + swiftPath.toFile().mkdirs() + downloadFile( + url = "https://swift.org/builds/swift-5.3-release/windows10/swift-5.3-RELEASE/swift-5.3-RELEASE-windows10.exe", + destinationPath = swiftExe.toString() + ) + } + + swiftExe.toFile().extract(swiftPath.toFile(), "zip", "gz") + findAndCopyLicense() + findAndCopySwiftDemangleFile() + swiftPath.toFile().deleteRecursively() +} + +fun updateSwiftOther() { val swiftTarGz = Paths.get(swiftPath.toString(), "swift.tar.gz") if (swiftTarGz.toFile().exists()) { @@ -30,6 +51,8 @@ fun updateSwift() { swiftPath.toFile().deleteRecursively() } +fun updateSwift() = if (isWindows) updateSwiftWindows() else updateSwiftOther() + fun findAndCopyLicense() { val licenseFileSuffix = Paths.get("usr", "share", "swift", "LICENSE.txt").toString() val licenseOutputFile = Paths.get(currentPath.toString(), "swift.txt").toFile() From 1dcdfa6d485bca3f355629252c64acc0f4f0c2b2 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 9 Oct 2020 13:15:33 +0200 Subject: [PATCH 13/95] Add duplicated apk names build and doc --- docs/development_kotlin_scripts.md | 15 +++++ flank-bash/scripts/android.ops.main.kts | 79 ++++++++++++++++--------- flank-bash/scripts/ops.main.kts | 2 +- 3 files changed, 67 insertions(+), 29 deletions(-) create mode 100644 docs/development_kotlin_scripts.md diff --git a/docs/development_kotlin_scripts.md b/docs/development_kotlin_scripts.md new file mode 100644 index 0000000000..1306bac409 --- /dev/null +++ b/docs/development_kotlin_scripts.md @@ -0,0 +1,15 @@ +# Development kotlin scripts hints + +Sometimes kotlin scrips keep cached scripts even if you modify the source to prevent it you could: + +1. Set env variable for ```KOTLIN_MAIN_KTS_COMPILED_SCRIPTS_CACHE_DIR``` +1. Run script with additional commands + +```bash + +rm -d -r $KOTLIN_MAIN_KTS_COMPILED_SCRIPTS_CACHE_DIR && mkdir $KOTLIN_MAIN_KTS_COMPILED_SCRIPTS_CACHE_DIR && kotlin {SCRIPT_FILE_NAME} + +``` + +This command remove all cached scripts and make fresh run + diff --git a/flank-bash/scripts/android.ops.main.kts b/flank-bash/scripts/android.ops.main.kts index 3ec1e60a77..2806e205c5 100644 --- a/flank-bash/scripts/android.ops.main.kts +++ b/flank-bash/scripts/android.ops.main.kts @@ -12,40 +12,63 @@ import java.nio.file.Paths import eu.jrie.jetbrains.kotlinshell.shell.* import java.nio.file.StandardCopyOption -val buildBaseApk = createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, "app:assemble") -) +suspend fun Shell.generateApkAndTests() { + duplicatedNamesApks() +// baseAppApk() +// baseTesApks() +// duplicatedNamesApks() +} -val buildBaseTestApk = createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, "app:assembleAndroidTest") -) +suspend fun Shell.baseAppApk() { + val buildBaseApk = createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, "app:assemble") + ) + buildBaseApk() + val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "singleSuccess", "debug", "app-single-success-debug.apk") + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "app-debug.apk") + if (!outputDir.parent.toFile().exists()) { + Files.createDirectories(outputDir.parent) + } + Files.copy(assembleDirectory, outputDir, StandardCopyOption.REPLACE_EXISTING) -fun generateApkAndTests() { - baseAppApk() - baseTesApks() } -fun baseAppApk() { - shell { - buildBaseApk() - val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "singleSuccess", "debug", "app-single-success-debug.apk") - val outputDir = Paths.get(flankFixturesTmpPath, "apk", "app-debug.apk") - if(!outputDir.parent.toFile().exists()){ - Files.createDirectories(outputDir.parent) - } - Files.copy(assembleDirectory, outputDir, StandardCopyOption.REPLACE_EXISTING) +suspend fun Shell.baseTesApks() { + val buildBaseTestApk = createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, "app:assembleAndroidTest") + ) + buildBaseTestApk() + val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "androidTest") + File(assembleDirectory.toString()).walk().filter { it.extension == "apk" }.forEach { + Files.copy(it.toPath(), Paths.get(flankFixturesTmpPath, "apk", it.name), StandardCopyOption.REPLACE_EXISTING) } + } -fun baseTesApks() { - shell { - buildBaseTestApk() - val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "androidTest") - File(assembleDirectory.toString()).walk().filter { it.extension == "apk" }.forEach { - File("test.log").appendText("Test FILE: ${it.toPath()}") - Files.copy(it.toPath(), Paths.get(flankFixturesTmpPath, "apk", it.name)) - } +suspend fun Shell.duplicatedNamesApks() { + val modules = (0..3).map { "dir$it" } + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath) + modules.map { "$it:testModule:assembleAndroidTest" } + )() + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "duplicated_names") + if (!outputDir.toFile().exists()) { + Files.createDirectories(outputDir) } + modules.map { Paths.get(androidTestProjectsPath, it, "testModule", "build", "outputs", "apk").toFile() } + .flatMap { it.walk().filter { file -> file.extension == "apk" }.toList() } + .forEachIndexed { index, file -> + Paths.get(outputDir.toString(), modules[index], file.name).let { path -> + if (!path.parent.toFile().exists()) { + Files.createDirectories(path.parent) + } + Files.copy( + file.toPath(), + path, + StandardCopyOption.REPLACE_EXISTING + ) + } + } } diff --git a/flank-bash/scripts/ops.main.kts b/flank-bash/scripts/ops.main.kts index 227944795e..0975df9048 100644 --- a/flank-bash/scripts/ops.main.kts +++ b/flank-bash/scripts/ops.main.kts @@ -1,7 +1,7 @@ @file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") -@file:Import("androidOps.main.kts") +@file:Import("android.ops.main.kts") @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) From b873e0af6055a6173c071838f7659d0a393149b6 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 9 Oct 2020 13:36:58 +0200 Subject: [PATCH 14/95] Update android.ops.main.kts --- flank-bash/scripts/android.ops.main.kts | 28 +++++++++++++------------ 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/flank-bash/scripts/android.ops.main.kts b/flank-bash/scripts/android.ops.main.kts index 2806e205c5..cb9fa39ed8 100644 --- a/flank-bash/scripts/android.ops.main.kts +++ b/flank-bash/scripts/android.ops.main.kts @@ -10,13 +10,13 @@ import java.io.File import java.nio.file.Files import java.nio.file.Paths import eu.jrie.jetbrains.kotlinshell.shell.* +import java.nio.file.Path import java.nio.file.StandardCopyOption suspend fun Shell.generateApkAndTests() { + baseAppApk() + baseTesApks() duplicatedNamesApks() -// baseAppApk() -// baseTesApks() -// duplicatedNamesApks() } suspend fun Shell.baseAppApk() { @@ -60,15 +60,17 @@ suspend fun Shell.duplicatedNamesApks() { modules.map { Paths.get(androidTestProjectsPath, it, "testModule", "build", "outputs", "apk").toFile() } .flatMap { it.walk().filter { file -> file.extension == "apk" }.toList() } .forEachIndexed { index, file -> - Paths.get(outputDir.toString(), modules[index], file.name).let { path -> - if (!path.parent.toFile().exists()) { - Files.createDirectories(path.parent) - } - Files.copy( - file.toPath(), - path, - StandardCopyOption.REPLACE_EXISTING - ) - } + file.copyDuplicatedApkToDirectory(Paths.get(outputDir.toString(), modules[index], file.name)) } } + +fun File.copyDuplicatedApkToDirectory(output: Path) = toPath().let { sourceFile -> + if (!output.parent.toFile().exists()) + Files.createDirectories(output.parent) + Files.copy( + sourceFile, + output, + StandardCopyOption.REPLACE_EXISTING + ) +} + From 8aa867c91a64a21f5a555b237c835bafdeb960f7 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 9 Oct 2020 15:20:49 +0200 Subject: [PATCH 15/95] Added build of multiModule app and cucumber App --- flank-bash/scripts/android.ops.main.kts | 50 +++++++++++++++++++------ 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/flank-bash/scripts/android.ops.main.kts b/flank-bash/scripts/android.ops.main.kts index cb9fa39ed8..47e06f60f1 100644 --- a/flank-bash/scripts/android.ops.main.kts +++ b/flank-bash/scripts/android.ops.main.kts @@ -17,6 +17,8 @@ suspend fun Shell.generateApkAndTests() { baseAppApk() baseTesApks() duplicatedNamesApks() + multiModulesApks() + cucumberSampleApp() } suspend fun Shell.baseAppApk() { @@ -41,7 +43,7 @@ suspend fun Shell.baseTesApks() { ) buildBaseTestApk() val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "androidTest") - File(assembleDirectory.toString()).walk().filter { it.extension == "apk" }.forEach { + File(assembleDirectory.toString()).findApks().forEach { Files.copy(it.toPath(), Paths.get(flankFixturesTmpPath, "apk", it.name), StandardCopyOption.REPLACE_EXISTING) } @@ -54,23 +56,47 @@ suspend fun Shell.duplicatedNamesApks() { options = listOf("-p", androidTestProjectsPath) + modules.map { "$it:testModule:assembleAndroidTest" } )() val outputDir = Paths.get(flankFixturesTmpPath, "apk", "duplicated_names") - if (!outputDir.toFile().exists()) { - Files.createDirectories(outputDir) - } + if (!outputDir.toFile().exists()) Files.createDirectories(outputDir) + modules.map { Paths.get(androidTestProjectsPath, it, "testModule", "build", "outputs", "apk").toFile() } - .flatMap { it.walk().filter { file -> file.extension == "apk" }.toList() } + .flatMap { it.findApks().toList() } .forEachIndexed { index, file -> file.copyDuplicatedApkToDirectory(Paths.get(outputDir.toString(), modules[index], file.name)) } } fun File.copyDuplicatedApkToDirectory(output: Path) = toPath().let { sourceFile -> - if (!output.parent.toFile().exists()) - Files.createDirectories(output.parent) - Files.copy( - sourceFile, - output, - StandardCopyOption.REPLACE_EXISTING - ) + if (!output.parent.toFile().exists()) Files.createDirectories(output.parent) + Files.copy(sourceFile, output, StandardCopyOption.REPLACE_EXISTING) } +suspend fun Shell.multiModulesApks() { + val modulesName = (1..20).map { "testModule$it" } + val gradleModules = modulesName.map { ":multi-modules:$it:assembleAndroidTest" } + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, ":multi-modules:multiapp:assemble") + gradleModules + )() + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "multi-modules").toString() + Paths.get(androidTestProjectsPath, "multi-modules").toFile().findApks() + .forEach { + it.copyDuplicatedApkToDirectory(Paths.get(outputDir, it.name)) + } + +} + +suspend fun Shell.cucumberSampleApp() { + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, "cucumber_sample_app:cukeulator:assembleDebug", ":cucumber_sample_app:cukeulator:assembleAndroidTest") + )() + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "cucumber_sample_app").toString() + Paths.get(androidTestProjectsPath, "cucumber_sample_app").toFile().findApks() + .copyApksToPath(outputDir) +} + +fun File.findApks() = walk().filter { it.extension == "apk" } + +fun Sequence.copyApksToPath(outputDirectory: String) = forEach { + it.copyDuplicatedApkToDirectory(Paths.get(outputDirectory, it.name)) +} From 8e699d2c6f5e1eac5d5ed56a705c4707821fc3c8 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 9 Oct 2020 15:37:04 +0200 Subject: [PATCH 16/95] Update android.ops.main.kts --- flank-bash/scripts/android.ops.main.kts | 35 +++++++++---------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/flank-bash/scripts/android.ops.main.kts b/flank-bash/scripts/android.ops.main.kts index 47e06f60f1..3d09936fdd 100644 --- a/flank-bash/scripts/android.ops.main.kts +++ b/flank-bash/scripts/android.ops.main.kts @@ -22,31 +22,26 @@ suspend fun Shell.generateApkAndTests() { } suspend fun Shell.baseAppApk() { - val buildBaseApk = createGradleCommand( + createGradleCommand( workingDir = androidTestProjectsPath, options = listOf("-p", androidTestProjectsPath, "app:assemble") - ) - buildBaseApk() - val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "singleSuccess", "debug", "app-single-success-debug.apk") + )() val outputDir = Paths.get(flankFixturesTmpPath, "apk", "app-debug.apk") - if (!outputDir.parent.toFile().exists()) { - Files.createDirectories(outputDir.parent) - } + if (!outputDir.parent.toFile().exists()) Files.createDirectories(outputDir.parent) + val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "singleSuccess", "debug", "app-single-success-debug.apk") Files.copy(assembleDirectory, outputDir, StandardCopyOption.REPLACE_EXISTING) } suspend fun Shell.baseTesApks() { - val buildBaseTestApk = createGradleCommand( + createGradleCommand( workingDir = androidTestProjectsPath, options = listOf("-p", androidTestProjectsPath, "app:assembleAndroidTest") - ) - buildBaseTestApk() + )() val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "androidTest") File(assembleDirectory.toString()).findApks().forEach { Files.copy(it.toPath(), Paths.get(flankFixturesTmpPath, "apk", it.name), StandardCopyOption.REPLACE_EXISTING) } - } suspend fun Shell.duplicatedNamesApks() { @@ -61,28 +56,23 @@ suspend fun Shell.duplicatedNamesApks() { modules.map { Paths.get(androidTestProjectsPath, it, "testModule", "build", "outputs", "apk").toFile() } .flatMap { it.findApks().toList() } .forEachIndexed { index, file -> - file.copyDuplicatedApkToDirectory(Paths.get(outputDir.toString(), modules[index], file.name)) + file.copyApkToDirectory(Paths.get(outputDir.toString(), modules[index], file.name)) } } -fun File.copyDuplicatedApkToDirectory(output: Path) = toPath().let { sourceFile -> +fun File.copyApkToDirectory(output: Path) = toPath().let { sourceFile -> if (!output.parent.toFile().exists()) Files.createDirectories(output.parent) Files.copy(sourceFile, output, StandardCopyOption.REPLACE_EXISTING) } suspend fun Shell.multiModulesApks() { - val modulesName = (1..20).map { "testModule$it" } - val gradleModules = modulesName.map { ":multi-modules:$it:assembleAndroidTest" } createGradleCommand( workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, ":multi-modules:multiapp:assemble") + gradleModules + options = listOf("-p", androidTestProjectsPath, ":multi-modules:multiapp:assemble") + (1..20).map { ":multi-modules:testModule$it:assembleAndroidTest" } )() val outputDir = Paths.get(flankFixturesTmpPath, "apk", "multi-modules").toString() Paths.get(androidTestProjectsPath, "multi-modules").toFile().findApks() - .forEach { - it.copyDuplicatedApkToDirectory(Paths.get(outputDir, it.name)) - } - + .forEach { it.copyApkToDirectory(Paths.get(outputDir, it.name)) } } suspend fun Shell.cucumberSampleApp() { @@ -91,12 +81,11 @@ suspend fun Shell.cucumberSampleApp() { options = listOf("-p", androidTestProjectsPath, "cucumber_sample_app:cukeulator:assembleDebug", ":cucumber_sample_app:cukeulator:assembleAndroidTest") )() val outputDir = Paths.get(flankFixturesTmpPath, "apk", "cucumber_sample_app").toString() - Paths.get(androidTestProjectsPath, "cucumber_sample_app").toFile().findApks() - .copyApksToPath(outputDir) + Paths.get(androidTestProjectsPath, "cucumber_sample_app").toFile().findApks().copyApksToPath(outputDir) } fun File.findApks() = walk().filter { it.extension == "apk" } fun Sequence.copyApksToPath(outputDirectory: String) = forEach { - it.copyDuplicatedApkToDirectory(Paths.get(outputDirectory, it.name)) + it.copyApkToDirectory(Paths.get(outputDirectory, it.name)) } From 61bf5a29de1ed7908b6cf6b244f5d689a6dfc46e Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Fri, 9 Oct 2020 17:50:53 +0200 Subject: [PATCH 17/95] adding updatingJson and generatingJavaClient --- .../scripts/generateJavaClient.main.kts | 52 +++++++++++++++++++ flank-bash/scripts/updateApiJson.main.kts | 35 +++++++++++++ .../scripts/updateLibs/downloadFiles.main.kts | 2 +- 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 flank-bash/scripts/generateJavaClient.main.kts create mode 100644 flank-bash/scripts/updateApiJson.main.kts diff --git a/flank-bash/scripts/generateJavaClient.main.kts b/flank-bash/scripts/generateJavaClient.main.kts new file mode 100644 index 0000000000..cfd9e27c46 --- /dev/null +++ b/flank-bash/scripts/generateJavaClient.main.kts @@ -0,0 +1,52 @@ +@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") +@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") +@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") + +@file:Import("updateLibs/downloadFiles.main.kts") + +@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") +@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) + +import eu.jrie.jetbrains.kotlinshell.shell.* +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.StandardCopyOption + +var containsPip = false +shell { + val exitCode = kotlin.runCatching { + val process = "pip -V"() + process.pcb.exitCode + }.getOrDefault(1) + containsPip = exitCode == 0 +} +if (!containsPip) { + downloadFile( + url = "https://bootstrap.pypa.io/get-pip.py", + destinationPath = "get-pip.py" + ) + shell { + "python get-pip.py"() + } +} + +shell { + "pip install google-apis-client-generator"() +} + +val apiPath = Paths.get("test_api").toString() +Paths.get(apiPath, "src").toFile().deleteRecursively() +shell { + val generateLibraryCommand = "generate_library " + + "--input=./json/testing_v1.json " + + "--language=java " + + "--package_path=api/services " + + "--output_dir=./test_api/src/main/java" + generateLibraryCommand() +} + +Files.move( + Paths.get(apiPath, "src", "main", "java", "pom.xml"), + Paths.get(apiPath, "pom.xml"), + StandardCopyOption.REPLACE_EXISTING +) diff --git a/flank-bash/scripts/updateApiJson.main.kts b/flank-bash/scripts/updateApiJson.main.kts new file mode 100644 index 0000000000..db0cd32973 --- /dev/null +++ b/flank-bash/scripts/updateApiJson.main.kts @@ -0,0 +1,35 @@ + +@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") +@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") +@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") + +@file:Import("updateLibs/downloadFiles.main.kts") + +@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) + +import eu.jrie.jetbrains.kotlinshell.shell.shell +import java.nio.file.Paths + +private val currentPath = Paths.get("").toString() +private val jsonDirectoryPath = Paths.get(currentPath, "json") +val testingV1Path = Paths.get(jsonDirectoryPath.toString(), "testing_v1.json").toString() +val testingV1Beta3Path = Paths.get(jsonDirectoryPath.toString(), "toolresults_v1beta3.json").toString() + +jsonDirectoryPath.toFile().mkdir() + +downloadFile( + "https://raw.githubusercontent.com/Flank/gcloud_cli/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/testing_v1.json", + testingV1Path +) + +downloadFile( + "https://raw.githubusercontent.com/Flank/gcloud_cli/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/toolresults_v1beta3.json", + testingV1Beta3Path +) + +shell { + "sort-json $testingV1Path"() + "sort-json $testingV1Beta3Path"() +} + + diff --git a/flank-bash/scripts/updateLibs/downloadFiles.main.kts b/flank-bash/scripts/updateLibs/downloadFiles.main.kts index 9b9aa70ae6..de0ca1e7b1 100644 --- a/flank-bash/scripts/updateLibs/downloadFiles.main.kts +++ b/flank-bash/scripts/updateLibs/downloadFiles.main.kts @@ -16,7 +16,7 @@ fun downloadFile( .progress { readBytes, totalBytes -> if (System.currentTimeMillis() - lastUpdate > 2000) { lastUpdate = System.currentTimeMillis() - val progress = readBytes.toFloat() / totalBytes.toFloat() * 100 + val progress = (readBytes.toFloat() / totalBytes.toFloat() * 100).toInt() println("Bytes downloaded $readBytes / $totalBytes ($progress %)") } } From 58c85c3ed85a0df54b4a3b373eec9530f985c09c Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 9 Oct 2020 16:19:58 +0200 Subject: [PATCH 18/95] initial ios --- flank-bash/scripts/GradleCommand.kt | 2 +- flank-bash/scripts/ios.ops.main.kts | 18 ++++++++++++++++++ flank-bash/scripts/ops.main.kts | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 flank-bash/scripts/ios.ops.main.kts diff --git a/flank-bash/scripts/GradleCommand.kt b/flank-bash/scripts/GradleCommand.kt index 2e10e2e372..3ebd010c0a 100644 --- a/flank-bash/scripts/GradleCommand.kt +++ b/flank-bash/scripts/GradleCommand.kt @@ -8,4 +8,4 @@ fun createGradleCommand( private val gradleExecutable: String get() = if(isWindows) "gradlew.bat" else "gradlew" -private val isWindows = System.getProperty("os.name").startsWith("Windows") +val isWindows = System.getProperty("os.name").startsWith("Windows") diff --git a/flank-bash/scripts/ios.ops.main.kts b/flank-bash/scripts/ios.ops.main.kts new file mode 100644 index 0000000000..09afb71f7a --- /dev/null +++ b/flank-bash/scripts/ios.ops.main.kts @@ -0,0 +1,18 @@ +@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") +@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") +@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") +@file:Import("GradleCommand.kt") +@file:Import("PathHelper.kt") +@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") +@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) + +import java.io.File +import java.nio.file.Files +import java.nio.file.Paths +import eu.jrie.jetbrains.kotlinshell.shell.* +import java.nio.file.Path +import java.nio.file.StandardCopyOption + +fun Shell.generateIos() = takeUnless { isWindows }?.let { + +} diff --git a/flank-bash/scripts/ops.main.kts b/flank-bash/scripts/ops.main.kts index 0975df9048..2d1a32845c 100644 --- a/flank-bash/scripts/ops.main.kts +++ b/flank-bash/scripts/ops.main.kts @@ -2,6 +2,7 @@ @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") @file:Import("android.ops.main.kts") +@file:Import("ios.ops.main.kts") @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) @@ -17,6 +18,7 @@ shell { args.map { it.toUpperCase() }.onEach { when (it) { OpsOptions.ANDROID.toString() -> generateApkAndTests() + OpsOptions.IOS.toString() -> generateIos() } } } From e3495b2a2a99d6ca6df4b584dca4dea6426ed63e Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 12 Oct 2020 13:38:20 +0200 Subject: [PATCH 19/95] Update ios.ops.main.kts --- flank-bash/scripts/ios.ops.main.kts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/flank-bash/scripts/ios.ops.main.kts b/flank-bash/scripts/ios.ops.main.kts index 09afb71f7a..8dd508edc5 100644 --- a/flank-bash/scripts/ios.ops.main.kts +++ b/flank-bash/scripts/ios.ops.main.kts @@ -6,13 +6,25 @@ @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) -import java.io.File -import java.nio.file.Files -import java.nio.file.Paths import eu.jrie.jetbrains.kotlinshell.shell.* -import java.nio.file.Path -import java.nio.file.StandardCopyOption +import java.nio.file.Paths + + +suspend fun Shell.generateIos() = takeUnless { isWindows }?.let { + setupIosEnv() +} + +suspend fun Shell.setupIosEnv() { + val shouldInstallXcpretty = kotlin.runCatching { "xcpretty -V"().pcb.exitCode }.getOrDefault(1) != 0 + if (shouldInstallXcpretty) "gem install cocoapods -v 1.9.3"() + val earlGreyExample = Paths.get(iOsTestProjectsPath, "EarlGreyExample") + "cd $earlGreyExample && pod install")() +} + +suspend fun installXcpretty() { + +} -fun Shell.generateIos() = takeUnless { isWindows }?.let { +suspend fun Shell.buildEarlGreyExample() { } From 3dd546a89e28b3a2fd1ec5fa24d9d1766abc4c61 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 12 Oct 2020 14:47:59 +0200 Subject: [PATCH 20/95] Update ios.ops.main.kts --- flank-bash/scripts/ios.ops.main.kts | 31 +++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/flank-bash/scripts/ios.ops.main.kts b/flank-bash/scripts/ios.ops.main.kts index 8dd508edc5..9b5ff3ab81 100644 --- a/flank-bash/scripts/ios.ops.main.kts +++ b/flank-bash/scripts/ios.ops.main.kts @@ -18,13 +18,36 @@ suspend fun Shell.setupIosEnv() { val shouldInstallXcpretty = kotlin.runCatching { "xcpretty -V"().pcb.exitCode }.getOrDefault(1) != 0 if (shouldInstallXcpretty) "gem install cocoapods -v 1.9.3"() val earlGreyExample = Paths.get(iOsTestProjectsPath, "EarlGreyExample") - "cd $earlGreyExample && pod install")() + ("cd $earlGreyExample && pod install")() } -suspend fun installXcpretty() { - +suspend fun Shell.installXcpretty() { + val shouldInstallXcpretty = kotlin.runCatching { "xcpretty -V"().pcb.exitCode }.getOrDefault(1) != 0 + if(shouldInstallXcpretty) ("gem install xcpretty")() } suspend fun Shell.buildEarlGreyExample() { - + installXcpretty() + val buildDir = Paths.get(iOsTestProjectsPath, "EarlGreyExample", "build") + ("rm -rf \"${buildDir}\"")() + (""" + xcodebuild build-for-testing \ + -allowProvisioningUpdates \ + -workspace "${buildDir.parent}/EarlGreyExample.xcworkspace" \ + -scheme "EarlGreyExampleSwiftTests" \ + -derivedDataPath "${buildDir.parent}" \ + -sdk iphoneos | + xcpretty + """.trimIndent())() + + + (""" + xcodebuild build-for-testing \ + -allowProvisioningUpdates \ + -workspace "${buildDir.parent}/EarlGreyExample.xcworkspace" \ + -scheme "EarlGreyExampleTests" \ + -derivedDataPath "${buildDir.parent}" \ + -sdk iphoneos | + xcpretty + """.trimIndent())() } From 5354945d6a593d3fd08963188cdb91b69a5ba267 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 12 Oct 2020 17:34:41 +0200 Subject: [PATCH 21/95] Update ios.ops.main.kts --- flank-bash/scripts/ios.ops.main.kts | 64 +++++++++++++++++------------ 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/flank-bash/scripts/ios.ops.main.kts b/flank-bash/scripts/ios.ops.main.kts index 9b5ff3ab81..077200f9da 100644 --- a/flank-bash/scripts/ios.ops.main.kts +++ b/flank-bash/scripts/ios.ops.main.kts @@ -7,47 +7,59 @@ @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) import eu.jrie.jetbrains.kotlinshell.shell.* +import java.nio.file.Files import java.nio.file.Paths +import java.nio.file.StandardCopyOption suspend fun Shell.generateIos() = takeUnless { isWindows }?.let { setupIosEnv() + installPods() + buildEarlGreyExample() } suspend fun Shell.setupIosEnv() { - val shouldInstallXcpretty = kotlin.runCatching { "xcpretty -V"().pcb.exitCode }.getOrDefault(1) != 0 + val shouldInstallXcpretty = kotlin.runCatching { + val result = "xcpretty -v"() + result.pcb.exitCode + }.getOrDefault(1) != 0 if (shouldInstallXcpretty) "gem install cocoapods -v 1.9.3"() - val earlGreyExample = Paths.get(iOsTestProjectsPath, "EarlGreyExample") - ("cd $earlGreyExample && pod install")() } -suspend fun Shell.installXcpretty() { - val shouldInstallXcpretty = kotlin.runCatching { "xcpretty -V"().pcb.exitCode }.getOrDefault(1) != 0 - if(shouldInstallXcpretty) ("gem install xcpretty")() +suspend fun Shell.installPods() { + val earlGreyExample = Paths.get(iOsTestProjectsPath, "EarlGreyExample") + kotlin.runCatching { "cd $earlGreyExample && pod install"() } } suspend fun Shell.buildEarlGreyExample() { installXcpretty() val buildDir = Paths.get(iOsTestProjectsPath, "EarlGreyExample", "build") ("rm -rf \"${buildDir}\"")() - (""" - xcodebuild build-for-testing \ - -allowProvisioningUpdates \ - -workspace "${buildDir.parent}/EarlGreyExample.xcworkspace" \ - -scheme "EarlGreyExampleSwiftTests" \ - -derivedDataPath "${buildDir.parent}" \ - -sdk iphoneos | - xcpretty - """.trimIndent())() - - - (""" - xcodebuild build-for-testing \ - -allowProvisioningUpdates \ - -workspace "${buildDir.parent}/EarlGreyExample.xcworkspace" \ - -scheme "EarlGreyExampleTests" \ - -derivedDataPath "${buildDir.parent}" \ - -sdk iphoneos | - xcpretty - """.trimIndent())() + val cmd = + ("xcodebuild build-for-testing -allowProvisioningUpdates -workspace ${buildDir.parent}/EarlGreyExample.xcworkspace -scheme EarlGreyExampleSwiftTests -derivedDataPath ${buildDir.parent} -sdk iphoneos") + println(cmd) + cmd() + + +// (""" +// xcodebuild build-for-testing +// -allowProvisioningUpdates +// -workspace '${buildDir.parent}/EarlGreyExample.xcworkspace' +// -scheme 'EarlGreyExampleTests' +// -derivedDataPath '${buildDir.parent}' +// -sdk iphoneos | xcpretty +// """.trimIndent())() + + val productsDir = Paths.get(buildDir.toString(), "Build", "Products") + productsDir.toFile().walk().filter { + it.nameWithoutExtension.endsWith("-iphoneos") || it.extension == "xctestrun" + }.forEach { + Files.copy(it.toPath(), Paths.get(flankFixturesTmpPath, it.name), StandardCopyOption.REPLACE_EXISTING) + } + +} + +suspend fun Shell.installXcpretty() { + val shouldInstallXcpretty = kotlin.runCatching { "xcpretty -v"().pcb.exitCode }.getOrDefault(1) != 0 + if (shouldInstallXcpretty) ("gem install xcpretty")() } From 7643a2cb65578fd4ed073faeb9d1e454cebc5bb0 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 12 Oct 2020 17:54:17 +0200 Subject: [PATCH 22/95] run pod install working --- flank-bash/scripts/ios.ops.main.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flank-bash/scripts/ios.ops.main.kts b/flank-bash/scripts/ios.ops.main.kts index 077200f9da..9b8fb4656f 100644 --- a/flank-bash/scripts/ios.ops.main.kts +++ b/flank-bash/scripts/ios.ops.main.kts @@ -28,7 +28,7 @@ suspend fun Shell.setupIosEnv() { suspend fun Shell.installPods() { val earlGreyExample = Paths.get(iOsTestProjectsPath, "EarlGreyExample") - kotlin.runCatching { "cd $earlGreyExample && pod install"() } + kotlin.runCatching { "pod install --project-directory=$earlGreyExample --verbose"() } } suspend fun Shell.buildEarlGreyExample() { From 72f30ca470af0509a21f959752fb14db62cfd8ae Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 13 Oct 2020 13:11:23 +0200 Subject: [PATCH 23/95] Build and copy ios artifacts --- flank-bash/scripts/ios.ops.main.kts | 41 +++++++++++++++++------------ 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/flank-bash/scripts/ios.ops.main.kts b/flank-bash/scripts/ios.ops.main.kts index 9b8fb4656f..0a34015e89 100644 --- a/flank-bash/scripts/ios.ops.main.kts +++ b/flank-bash/scripts/ios.ops.main.kts @@ -7,6 +7,7 @@ @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) import eu.jrie.jetbrains.kotlinshell.shell.* +import java.io.File import java.nio.file.Files import java.nio.file.Paths import java.nio.file.StandardCopyOption @@ -33,30 +34,36 @@ suspend fun Shell.installPods() { suspend fun Shell.buildEarlGreyExample() { installXcpretty() - val buildDir = Paths.get(iOsTestProjectsPath, "EarlGreyExample", "build") - ("rm -rf \"${buildDir}\"")() - val cmd = - ("xcodebuild build-for-testing -allowProvisioningUpdates -workspace ${buildDir.parent}/EarlGreyExample.xcworkspace -scheme EarlGreyExampleSwiftTests -derivedDataPath ${buildDir.parent} -sdk iphoneos") - println(cmd) - cmd() + val buildDir = Paths.get(iOsTestProjectsPath, "EarlGreyExample", "Build") + buildDir.toFile().deleteRecursively() + ("xcodebuild build-for-testing " + + "-allowProvisioningUpdates " + + "-workspace ${buildDir.parent}/EarlGreyExample.xcworkspace " + + "-scheme EarlGreyExampleSwiftTests " + + "-derivedDataPath ${buildDir.parent} " + + "-sdk iphoneos")() -// (""" -// xcodebuild build-for-testing -// -allowProvisioningUpdates -// -workspace '${buildDir.parent}/EarlGreyExample.xcworkspace' -// -scheme 'EarlGreyExampleTests' -// -derivedDataPath '${buildDir.parent}' -// -sdk iphoneos | xcpretty -// """.trimIndent())() - val productsDir = Paths.get(buildDir.toString(), "Build", "Products") + ("xcodebuild build-for-testing " + + "-allowProvisioningUpdates " + + "-workspace ${buildDir.parent}/EarlGreyExample.xcworkspace " + + "-scheme EarlGreyExampleTests " + + "-derivedDataPath ${buildDir.parent} " + + "-sdk iphoneos")() + + Files.createDirectories(Paths.get(flankFixturesTmpPath, "objc")) + Files.createDirectories(Paths.get(flankFixturesTmpPath, "swift")) + val productsDir = Paths.get(buildDir.toString(), "Products") productsDir.toFile().walk().filter { it.nameWithoutExtension.endsWith("-iphoneos") || it.extension == "xctestrun" }.forEach { - Files.copy(it.toPath(), Paths.get(flankFixturesTmpPath, it.name), StandardCopyOption.REPLACE_EXISTING) + println(it.name) + if (it.isDirectory) it.copyRecursively(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) + else it.copyTo(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) } - + Files.copy(Paths.get(productsDir.toString(), "Debug-iphoneos", "EarlGreyExampleSwift.app", "PlugIns", "EarlGreyExampleTests.xctest", "EarlGreyExampleTests"), Paths.get(flankFixturesTmpPath, "objc", "EarlGreyExampleTests"), StandardCopyOption.REPLACE_EXISTING) + Files.copy(Paths.get(productsDir.toString(), "Debug-iphoneos", "EarlGreyExampleSwift.app", "PlugIns", "EarlGreyExampleSwiftTests.xctest", "EarlGreyExampleSwiftTests"), Paths.get(flankFixturesTmpPath, "swift", "EarlGreyExampleSwiftTests"), StandardCopyOption.REPLACE_EXISTING) } suspend fun Shell.installXcpretty() { From 7485a8f5ac9a7f912f6ef8f3d6187f40ed3aef8b Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Tue, 13 Oct 2020 16:14:19 +0200 Subject: [PATCH 24/95] added ios scripts --- flank-bash/scripts/ios/LipoHelper.kt | 5 ++ flank-bash/scripts/ios/buildExample.main.kts | 58 +++++++++++++++++++ flank-bash/scripts/ios/buildFtl.main.kts | 47 +++++++++++++++ flank-bash/scripts/ios/packer.main.kts | 21 +++++++ flank-bash/scripts/ios/runFtlLocal.main.kts | 28 +++++++++ .../scripts/ios/universalFramework.main.kts | 50 ++++++++++++++++ flank-bash/scripts/ios/xcPretty.main.kts | 21 +++++++ 7 files changed, 230 insertions(+) create mode 100644 flank-bash/scripts/ios/LipoHelper.kt create mode 100644 flank-bash/scripts/ios/buildExample.main.kts create mode 100644 flank-bash/scripts/ios/buildFtl.main.kts create mode 100644 flank-bash/scripts/ios/packer.main.kts create mode 100644 flank-bash/scripts/ios/runFtlLocal.main.kts create mode 100644 flank-bash/scripts/ios/universalFramework.main.kts create mode 100644 flank-bash/scripts/ios/xcPretty.main.kts diff --git a/flank-bash/scripts/ios/LipoHelper.kt b/flank-bash/scripts/ios/LipoHelper.kt new file mode 100644 index 0000000000..3b12b2032d --- /dev/null +++ b/flank-bash/scripts/ios/LipoHelper.kt @@ -0,0 +1,5 @@ + +fun createLipoCommand( + outputPath: String, + vararg files: String +) = "lipo -create ${files.joinToString(" ")} -output $outputPath" diff --git a/flank-bash/scripts/ios/buildExample.main.kts b/flank-bash/scripts/ios/buildExample.main.kts new file mode 100644 index 0000000000..8c690dc69e --- /dev/null +++ b/flank-bash/scripts/ios/buildExample.main.kts @@ -0,0 +1,58 @@ + +@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") +@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") +@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") + +@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") +@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) + +@file:Import("xcPretty.main.kts") +@file:Import("packer.main.kts") + +import eu.jrie.jetbrains.kotlinshell.shell.shell +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths +import java.nio.file.StandardCopyOption +import java.util.stream.Collectors + +val currentPath = Paths.get("") +val dataPath: Path = Paths.get("", "dd_tmp") +dataPath.toFile().deleteRecursively() +val archiveFileName = "earlgrey_example.zip" +val buildProductPath = Paths.get(dataPath.toString(), "Build", "Products") +downloadXcPrettyIfNeeded() + +shell { + + val xcodeCommandSwiftTests = "xcodebuild build-for-testing" + + " -allowProvisioningUpdates" + + " -workspace ./EarlGreyExample.xcworkspace" + + " -scheme \"EarlGreyExampleSwiftTests\"" + + " -derivedDataPath $dataPath" + + " -sdk iphoneos".process() + val xcPrettyCommand = "xcpretty".process() + + pipeline { xcodeCommandSwiftTests pipe xcPrettyCommand } + + val xcodeCommandTests = "xcodebuild build-for-testing" + + " -allowProvisioningUpdates" + + " -workspace ./EarlGreyExample.xcworkspace" + + " -scheme \"EarlGreyExampleTests\"" + + " -derivedDataPath $dataPath" + + " -sdk iphoneos".process() + + pipeline { xcodeCommandTests pipe xcPrettyCommand } +} + +Files.walk(Paths.get("")) + .filter { it.fileName.toString().endsWith("-iphoneos") || it.fileName.toString().endsWith(".xctestrun") } + .map { it.toFile() } + .collect(Collectors.toList()) + .archive(archiveFileName, currentPath.toFile()) + +Files.move( + Paths.get("", archiveFileName), + Paths.get(buildProductPath.toString(), archiveFileName), + StandardCopyOption.REPLACE_EXISTING +) diff --git a/flank-bash/scripts/ios/buildFtl.main.kts b/flank-bash/scripts/ios/buildFtl.main.kts new file mode 100644 index 0000000000..07aa6df749 --- /dev/null +++ b/flank-bash/scripts/ios/buildFtl.main.kts @@ -0,0 +1,47 @@ +@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") +@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") +@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") + +@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") +@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) + +@file:Import("xcPretty.main.kts") +@file:Import("packer.main.kts") + +import eu.jrie.jetbrains.kotlinshell.shell.shell +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths +import java.nio.file.StandardCopyOption +import java.util.stream.Collectors + +val currentPath = Paths.get("") +val dataPath: Path = Paths.get("", "dd_tmp") +dataPath.toFile().deleteRecursively() +val archiveFileName = "earlgrey_example.zip" +val buildProductPath = Paths.get(dataPath.toString(), "Build", "Products") +downloadXcPrettyIfNeeded() + +shell { + val xcodeCommand = "xcodebuild build-for-testing" + + " -allowProvisioningUpdates" + + " -workspace ./EarlGreyExample.xcworkspace" + + " -scheme \"EarlGreyExampleSwiftTests\"" + + " -derivedDataPath $dataPath" + + " -sdk iphoneos".process() + val xcPrettyCommand = "xcpretty".process() + + pipeline { xcodeCommand pipe xcPrettyCommand } + + Files.walk(Paths.get("")) + .filter { it.fileName.toString().endsWith("-iphoneos") || it.fileName.toString().endsWith(".xctestrun") } + .map { it.toFile() } + .collect(Collectors.toList()) + .archive(archiveFileName, currentPath.toFile()) + + Files.move( + Paths.get("", archiveFileName), + Paths.get(buildProductPath.toString(), archiveFileName), + StandardCopyOption.REPLACE_EXISTING + ) +} diff --git a/flank-bash/scripts/ios/packer.main.kts b/flank-bash/scripts/ios/packer.main.kts new file mode 100644 index 0000000000..814edb6e92 --- /dev/null +++ b/flank-bash/scripts/ios/packer.main.kts @@ -0,0 +1,21 @@ +@file:Repository("https://repo1.maven.org/maven2/org/rauschig/jarchivelib/") +@file:DependsOn("org.rauschig:jarchivelib:1.1.0") +@file:DependsOn("org.tukaani:xz:1.0") + +import org.rauschig.jarchivelib.* +import java.io.File + +fun List.archive( + destinationFileName: String, + destinationDirectory: File, + archiveFormat: ArchiveFormat = ArchiveFormat.ZIP +) { + println("Packing...$destinationFileName") + val archiver = ArchiverFactory.createArchiver(archiveFormat) + runCatching { + archiver.create(destinationFileName, destinationDirectory, *toTypedArray()) + }.onFailure { + println("There was an error when packing ${destinationDirectory.absolutePath}${File.separator}$destinationFileName - $it") + } +} + diff --git a/flank-bash/scripts/ios/runFtlLocal.main.kts b/flank-bash/scripts/ios/runFtlLocal.main.kts new file mode 100644 index 0000000000..4e51218511 --- /dev/null +++ b/flank-bash/scripts/ios/runFtlLocal.main.kts @@ -0,0 +1,28 @@ + +@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") +@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") +@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") + +@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") +@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) + +import eu.jrie.jetbrains.kotlinshell.shell.shell +import java.nio.file.Path +import java.nio.file.Paths +import kotlin.system.exitProcess + +val id = args.firstOrNull() ?: { + println("Pass device id. Please take it from Xcode -> Window -> Devices and Simulators") + exitProcess(1) +} + +val dataPath: Path = Paths.get("", "dd_tmp", "Build" , "Products") + +val xcodeCommand = "xcodebuild test-without-building " + + " -xctestrun $dataPath/*.xctestrun " + + "-derivedDataPath $dataPath " + + "-destination 'id=$id'" + +shell { + xcodeCommand() +} diff --git a/flank-bash/scripts/ios/universalFramework.main.kts b/flank-bash/scripts/ios/universalFramework.main.kts new file mode 100644 index 0000000000..29fa6d6246 --- /dev/null +++ b/flank-bash/scripts/ios/universalFramework.main.kts @@ -0,0 +1,50 @@ +@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") +@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") +@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") + +@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") +@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) + +@file:Import("LipoHelper.kt") + +import eu.jrie.jetbrains.kotlinshell.shell.shell +import java.nio.file.Path +import java.nio.file.Paths + +val comboPath = Paths.get("ios-frameworks").toString() +val devicePath = Paths.get(comboPath, "Debug-iphoneos").toString() +val simPath = Paths.get(comboPath, "Debug-iphonesimulator").toString() + +val universalFilesNames = listOf( + "libChannelLib.a", + "libCommonLib.a", + "libeDistantObject.a", + "libTestLib.a", + "libUILib.a" +) + +shell { + universalFilesNames.forEach {fileName -> + createLipoCommand( + outputPath = Paths.get(comboPath, fileName).toString(), + Paths.get(devicePath, fileName).toString(), Paths.get(simPath, fileName).toString() + ) + } +} +private val appFrameworkFramework = "AppFramework.framework" +private val appFramework = "AppFramework" +Paths.get(devicePath, appFrameworkFramework).toFile() + .copyRecursively(Paths.get(comboPath, appFrameworkFramework).toFile(), overwrite = true) + +val deviceFramework = Paths.get(devicePath, appFrameworkFramework, appFramework).toString() +val simFramework = Paths.get(simPath, appFrameworkFramework, appFramework).toString() +val universalFramework = Paths.get(comboPath, appFrameworkFramework, appFramework).toString() + +shell { + createLipoCommand( + outputPath = universalFramework, + deviceFramework, simFramework + ) + + "dsymutil $universalFramework --out ${Paths.get(comboPath, "AppFramework.framework.dSYM")}" +} diff --git a/flank-bash/scripts/ios/xcPretty.main.kts b/flank-bash/scripts/ios/xcPretty.main.kts new file mode 100644 index 0000000000..e2d3727921 --- /dev/null +++ b/flank-bash/scripts/ios/xcPretty.main.kts @@ -0,0 +1,21 @@ +@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") +@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") +@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") + +@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") +@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) + +import eu.jrie.jetbrains.kotlinshell.shell.shell + +fun downloadXcPrettyIfNeeded() { + shell { + val exitCode = runCatching { + val process = "command -v xcpretty"() + process.pcb.exitCode + }.getOrDefault(1) + + if(exitCode != 0) { + "gem install xcpretty"() + } + } +} From ba806eade6c8abe8276c9f9d587746345f953b58 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Tue, 13 Oct 2020 16:15:41 +0200 Subject: [PATCH 25/95] added iosScripts --- flank-bash/scripts/PathHelper.kt | 5 ++++- flank-bash/scripts/ios/buildExample.main.kts | 4 ++-- flank-bash/scripts/ios/buildFtl.main.kts | 1 + flank-bash/scripts/ios/runFtlLocal.main.kts | 4 +++- flank-bash/scripts/ios/universalFramework.main.kts | 4 ++-- flank-bash/scripts/updateBinaries.main.kts | 1 - 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/flank-bash/scripts/PathHelper.kt b/flank-bash/scripts/PathHelper.kt index 25fe6f5d2b..95a3ee961c 100644 --- a/flank-bash/scripts/PathHelper.kt +++ b/flank-bash/scripts/PathHelper.kt @@ -6,7 +6,10 @@ val rootDirectoryPath = Paths .parent .toString() +val currentPath = Paths.get("") + val testProjectsPath = Paths.get(rootDirectoryPath, "test_projects").toString() val androidTestProjectsPath = Paths.get(testProjectsPath, "android").toString() val iOsTestProjectsPath = Paths.get(testProjectsPath, "ios").toString() -val flankFixturesTmpPath = Paths.get(rootDirectoryPath, "/test_runner/src/test/kotlin/ftl/fixtures/tmp").toString() +val flankFixturesTmpPath = + Paths.get(rootDirectoryPath, "test_runner", "src", "test", "kotlin", "ftl", "fixtures", "tmp").toString() diff --git a/flank-bash/scripts/ios/buildExample.main.kts b/flank-bash/scripts/ios/buildExample.main.kts index 8c690dc69e..7d6852c5c9 100644 --- a/flank-bash/scripts/ios/buildExample.main.kts +++ b/flank-bash/scripts/ios/buildExample.main.kts @@ -8,6 +8,7 @@ @file:Import("xcPretty.main.kts") @file:Import("packer.main.kts") +@file:Import("../PathHelper.kt") import eu.jrie.jetbrains.kotlinshell.shell.shell import java.nio.file.Files @@ -16,8 +17,7 @@ import java.nio.file.Paths import java.nio.file.StandardCopyOption import java.util.stream.Collectors -val currentPath = Paths.get("") -val dataPath: Path = Paths.get("", "dd_tmp") +val dataPath: Path = Paths.get(currentPath.toString(), "dd_tmp") dataPath.toFile().deleteRecursively() val archiveFileName = "earlgrey_example.zip" val buildProductPath = Paths.get(dataPath.toString(), "Build", "Products") diff --git a/flank-bash/scripts/ios/buildFtl.main.kts b/flank-bash/scripts/ios/buildFtl.main.kts index 07aa6df749..8110c84174 100644 --- a/flank-bash/scripts/ios/buildFtl.main.kts +++ b/flank-bash/scripts/ios/buildFtl.main.kts @@ -7,6 +7,7 @@ @file:Import("xcPretty.main.kts") @file:Import("packer.main.kts") +@file:Import("PathHelper.kt") import eu.jrie.jetbrains.kotlinshell.shell.shell import java.nio.file.Files diff --git a/flank-bash/scripts/ios/runFtlLocal.main.kts b/flank-bash/scripts/ios/runFtlLocal.main.kts index 4e51218511..f6e4267f28 100644 --- a/flank-bash/scripts/ios/runFtlLocal.main.kts +++ b/flank-bash/scripts/ios/runFtlLocal.main.kts @@ -6,6 +6,8 @@ @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) +@file:Import("../PathHelper.kt") + import eu.jrie.jetbrains.kotlinshell.shell.shell import java.nio.file.Path import java.nio.file.Paths @@ -16,7 +18,7 @@ val id = args.firstOrNull() ?: { exitProcess(1) } -val dataPath: Path = Paths.get("", "dd_tmp", "Build" , "Products") +val dataPath: Path = Paths.get(currentPath.toString(), "dd_tmp", "Build" , "Products") val xcodeCommand = "xcodebuild test-without-building " + " -xctestrun $dataPath/*.xctestrun " + diff --git a/flank-bash/scripts/ios/universalFramework.main.kts b/flank-bash/scripts/ios/universalFramework.main.kts index 29fa6d6246..a24bceaf0f 100644 --- a/flank-bash/scripts/ios/universalFramework.main.kts +++ b/flank-bash/scripts/ios/universalFramework.main.kts @@ -6,12 +6,12 @@ @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) @file:Import("LipoHelper.kt") +@file:Import("../PathHelper.kt") import eu.jrie.jetbrains.kotlinshell.shell.shell -import java.nio.file.Path import java.nio.file.Paths -val comboPath = Paths.get("ios-frameworks").toString() +val comboPath = Paths.get(currentPath.toString(), "ios-frameworks").toString() val devicePath = Paths.get(comboPath, "Debug-iphoneos").toString() val simPath = Paths.get(comboPath, "Debug-iphonesimulator").toString() diff --git a/flank-bash/scripts/updateBinaries.main.kts b/flank-bash/scripts/updateBinaries.main.kts index af50f27046..adccafa6a5 100644 --- a/flank-bash/scripts/updateBinaries.main.kts +++ b/flank-bash/scripts/updateBinaries.main.kts @@ -12,7 +12,6 @@ @file:DependsOn("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9") -import java.io.File import kotlinx.coroutines.runBlocking import kotlinx.coroutines.launch From cc3fcd0cf4f8d42bbe06e8c90ad637786c5add71 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Tue, 13 Oct 2020 16:44:05 +0200 Subject: [PATCH 26/95] directories reorganization --- flank-bash/scripts/android.ops.main.kts | 4 ++-- flank-bash/scripts/buildFlankScripts.main.kts | 4 ++-- flank-bash/scripts/buildGo.main.kts | 2 +- flank-bash/scripts/ios.ops.main.kts | 4 ++-- .../{ => updateFirebaseApi}/generateJavaClient.main.kts | 2 +- .../scripts/{ => updateFirebaseApi}/updateApiJson.main.kts | 2 +- flank-bash/scripts/updateFlank.main.kts | 4 ++-- flank-bash/scripts/updateLibs/updateAtomic.main.kts | 4 ++-- flank-bash/scripts/{ => updateLibs}/updateBinaries.main.kts | 6 +++--- flank-bash/scripts/updateLibs/updateLlvm.main.kts | 4 ++-- flank-bash/scripts/updateLibs/updateSwift.main.kts | 4 ++-- flank-bash/scripts/{ => util}/GradleCommand.kt | 0 flank-bash/scripts/{ => util}/PathHelper.kt | 0 .../scripts/{updateLibs => util}/downloadFiles.main.kts | 0 flank-bash/scripts/{updateLibs => util}/unpack.main.kts | 0 15 files changed, 20 insertions(+), 20 deletions(-) rename flank-bash/scripts/{ => updateFirebaseApi}/generateJavaClient.main.kts (96%) rename flank-bash/scripts/{ => updateFirebaseApi}/updateApiJson.main.kts (95%) rename flank-bash/scripts/{ => updateLibs}/updateBinaries.main.kts (81%) rename flank-bash/scripts/{ => util}/GradleCommand.kt (100%) rename flank-bash/scripts/{ => util}/PathHelper.kt (100%) rename flank-bash/scripts/{updateLibs => util}/downloadFiles.main.kts (100%) rename flank-bash/scripts/{updateLibs => util}/unpack.main.kts (100%) diff --git a/flank-bash/scripts/android.ops.main.kts b/flank-bash/scripts/android.ops.main.kts index 3d09936fdd..4d113acd24 100644 --- a/flank-bash/scripts/android.ops.main.kts +++ b/flank-bash/scripts/android.ops.main.kts @@ -1,8 +1,8 @@ @file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") -@file:Import("GradleCommand.kt") -@file:Import("PathHelper.kt") +@file:Import("util/GradleCommand.kt") +@file:Import("util/PathHelper.kt") @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) diff --git a/flank-bash/scripts/buildFlankScripts.main.kts b/flank-bash/scripts/buildFlankScripts.main.kts index 19f75420ff..ca40fee67e 100644 --- a/flank-bash/scripts/buildFlankScripts.main.kts +++ b/flank-bash/scripts/buildFlankScripts.main.kts @@ -1,8 +1,8 @@ @file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") -@file:Import("GradleCommand.kt") -@file:Import("PathHelper.kt") +@file:Import("util/GradleCommand.kt") +@file:Import("util/PathHelper.kt") @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) diff --git a/flank-bash/scripts/buildGo.main.kts b/flank-bash/scripts/buildGo.main.kts index 3d0904219c..277c6c2a18 100644 --- a/flank-bash/scripts/buildGo.main.kts +++ b/flank-bash/scripts/buildGo.main.kts @@ -4,7 +4,7 @@ @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") -@file:Import("PathHelper.kt") +@file:Import("util/PathHelper.kt") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) diff --git a/flank-bash/scripts/ios.ops.main.kts b/flank-bash/scripts/ios.ops.main.kts index 0a34015e89..a6d1312783 100644 --- a/flank-bash/scripts/ios.ops.main.kts +++ b/flank-bash/scripts/ios.ops.main.kts @@ -1,8 +1,8 @@ @file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") -@file:Import("GradleCommand.kt") -@file:Import("PathHelper.kt") +@file:Import("util/GradleCommand.kt") +@file:Import("util/PathHelper.kt") @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) diff --git a/flank-bash/scripts/generateJavaClient.main.kts b/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts similarity index 96% rename from flank-bash/scripts/generateJavaClient.main.kts rename to flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts index cfd9e27c46..e635ec03a0 100644 --- a/flank-bash/scripts/generateJavaClient.main.kts +++ b/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts @@ -2,7 +2,7 @@ @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") -@file:Import("updateLibs/downloadFiles.main.kts") +@file:Import("../util/downloadFiles.main.kts") @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) diff --git a/flank-bash/scripts/updateApiJson.main.kts b/flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts similarity index 95% rename from flank-bash/scripts/updateApiJson.main.kts rename to flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts index db0cd32973..9de8bcb079 100644 --- a/flank-bash/scripts/updateApiJson.main.kts +++ b/flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts @@ -3,7 +3,7 @@ @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") -@file:Import("updateLibs/downloadFiles.main.kts") +@file:Import("../util/downloadFiles.main.kts") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) diff --git a/flank-bash/scripts/updateFlank.main.kts b/flank-bash/scripts/updateFlank.main.kts index a5f1011232..cad83d8149 100644 --- a/flank-bash/scripts/updateFlank.main.kts +++ b/flank-bash/scripts/updateFlank.main.kts @@ -1,8 +1,8 @@ @file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") -@file:Import("GradleCommand.kt") -@file:Import("PathHelper.kt") +@file:Import("util/GradleCommand.kt") +@file:Import("util/PathHelper.kt") @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) diff --git a/flank-bash/scripts/updateLibs/updateAtomic.main.kts b/flank-bash/scripts/updateLibs/updateAtomic.main.kts index b551dd4761..767065a14e 100644 --- a/flank-bash/scripts/updateLibs/updateAtomic.main.kts +++ b/flank-bash/scripts/updateLibs/updateAtomic.main.kts @@ -1,7 +1,7 @@ @file:CompilerOptions("jvmTarget = '1.8'") -@file:Import("downloadFiles.main.kts") -@file:Import("unpack.main.kts") +@file:Import("../util/downloadFiles.main.kts") +@file:Import("../util/unpack.main.kts") import java.io.File import java.nio.file.Files diff --git a/flank-bash/scripts/updateBinaries.main.kts b/flank-bash/scripts/updateLibs/updateBinaries.main.kts similarity index 81% rename from flank-bash/scripts/updateBinaries.main.kts rename to flank-bash/scripts/updateLibs/updateBinaries.main.kts index adccafa6a5..50c7be5604 100644 --- a/flank-bash/scripts/updateBinaries.main.kts +++ b/flank-bash/scripts/updateLibs/updateBinaries.main.kts @@ -6,9 +6,9 @@ @file:DependsOn("com.github.kittinunf.fuel:fuel:2.3.0") @file:DependsOn("com.github.kittinunf.fuel:fuel-coroutines:2.3.0") -@file:Import("./updateLibs/updateAtomic.main.kts") -@file:Import("./updateLibs/updateLlvm.main.kts") -@file:Import("./updateLibs/updateSwift.main.kts") +@file:Import("updateAtomic.main.kts") +@file:Import("updateLlvm.main.kts") +@file:Import("updateSwift.main.kts") @file:DependsOn("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9") diff --git a/flank-bash/scripts/updateLibs/updateLlvm.main.kts b/flank-bash/scripts/updateLibs/updateLlvm.main.kts index ae39b73da2..c18e106c9b 100644 --- a/flank-bash/scripts/updateLibs/updateLlvm.main.kts +++ b/flank-bash/scripts/updateLibs/updateLlvm.main.kts @@ -1,7 +1,7 @@ @file:CompilerOptions("jvmTarget = '1.8'") -@file:Import("downloadFiles.main.kts") -@file:Import("unpack.main.kts") +@file:Import("../util/downloadFiles.main.kts") +@file:Import("../util/unpack.main.kts") @file:Import("update.constants.kts") import java.nio.file.Files diff --git a/flank-bash/scripts/updateLibs/updateSwift.main.kts b/flank-bash/scripts/updateLibs/updateSwift.main.kts index d4dc815fdb..19f873e211 100644 --- a/flank-bash/scripts/updateLibs/updateSwift.main.kts +++ b/flank-bash/scripts/updateLibs/updateSwift.main.kts @@ -1,7 +1,7 @@ @file:CompilerOptions("jvmTarget = '1.8'") -@file:Import("downloadFiles.main.kts") -@file:Import("unpack.main.kts") +@file:Import("../util/downloadFiles.main.kts") +@file:Import("../util/unpack.main.kts") @file:Import("update.constants.kts") import java.nio.file.Files diff --git a/flank-bash/scripts/GradleCommand.kt b/flank-bash/scripts/util/GradleCommand.kt similarity index 100% rename from flank-bash/scripts/GradleCommand.kt rename to flank-bash/scripts/util/GradleCommand.kt diff --git a/flank-bash/scripts/PathHelper.kt b/flank-bash/scripts/util/PathHelper.kt similarity index 100% rename from flank-bash/scripts/PathHelper.kt rename to flank-bash/scripts/util/PathHelper.kt diff --git a/flank-bash/scripts/updateLibs/downloadFiles.main.kts b/flank-bash/scripts/util/downloadFiles.main.kts similarity index 100% rename from flank-bash/scripts/updateLibs/downloadFiles.main.kts rename to flank-bash/scripts/util/downloadFiles.main.kts diff --git a/flank-bash/scripts/updateLibs/unpack.main.kts b/flank-bash/scripts/util/unpack.main.kts similarity index 100% rename from flank-bash/scripts/updateLibs/unpack.main.kts rename to flank-bash/scripts/util/unpack.main.kts From 2814cf75a3b7b9f72f13d6e5a9acd56c1df99cc9 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Tue, 13 Oct 2020 17:24:30 +0200 Subject: [PATCH 27/95] refactor utils --- flank-bash/scripts/ios/buildExample.main.kts | 6 +-- flank-bash/scripts/ios/buildFtl.main.kts | 4 +- flank-bash/scripts/ios/packer.main.kts | 21 -------- flank-bash/scripts/ios/runFtlLocal.main.kts | 2 +- .../scripts/ios/universalFramework.main.kts | 2 +- flank-bash/scripts/ios/xcPretty.main.kts | 21 -------- .../generateJavaClient.main.kts | 29 +++-------- .../updateFirebaseApi/updateApiJson.main.kts | 7 ++- flank-bash/scripts/updateFlank.main.kts | 2 + .../scripts/updateLibs/updateAtomic.main.kts | 2 +- .../scripts/updateLibs/updateLlvm.main.kts | 2 +- .../scripts/updateLibs/updateSwift.main.kts | 2 +- .../{unpack.main.kts => archive.main.kts} | 14 ++++++ .../scripts/util/downloadSoftware.main.kts | 49 +++++++++++++++++++ 14 files changed, 87 insertions(+), 76 deletions(-) delete mode 100644 flank-bash/scripts/ios/packer.main.kts delete mode 100644 flank-bash/scripts/ios/xcPretty.main.kts rename flank-bash/scripts/util/{unpack.main.kts => archive.main.kts} (70%) create mode 100644 flank-bash/scripts/util/downloadSoftware.main.kts diff --git a/flank-bash/scripts/ios/buildExample.main.kts b/flank-bash/scripts/ios/buildExample.main.kts index 7d6852c5c9..3fb2223c9e 100644 --- a/flank-bash/scripts/ios/buildExample.main.kts +++ b/flank-bash/scripts/ios/buildExample.main.kts @@ -6,9 +6,9 @@ @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) -@file:Import("xcPretty.main.kts") -@file:Import("packer.main.kts") -@file:Import("../PathHelper.kt") +@file:Import("../util/archive.main.kts") +@file:Import("../util/downloadSoftware.main.kts") +@file:Import("../util/PathHelper.kt") import eu.jrie.jetbrains.kotlinshell.shell.shell import java.nio.file.Files diff --git a/flank-bash/scripts/ios/buildFtl.main.kts b/flank-bash/scripts/ios/buildFtl.main.kts index 8110c84174..282ad50861 100644 --- a/flank-bash/scripts/ios/buildFtl.main.kts +++ b/flank-bash/scripts/ios/buildFtl.main.kts @@ -6,8 +6,8 @@ @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) @file:Import("xcPretty.main.kts") -@file:Import("packer.main.kts") -@file:Import("PathHelper.kt") +@file:Import("../util/archive.main.kts") +@file:Import("../util/PathHelper.kt") import eu.jrie.jetbrains.kotlinshell.shell.shell import java.nio.file.Files diff --git a/flank-bash/scripts/ios/packer.main.kts b/flank-bash/scripts/ios/packer.main.kts deleted file mode 100644 index 814edb6e92..0000000000 --- a/flank-bash/scripts/ios/packer.main.kts +++ /dev/null @@ -1,21 +0,0 @@ -@file:Repository("https://repo1.maven.org/maven2/org/rauschig/jarchivelib/") -@file:DependsOn("org.rauschig:jarchivelib:1.1.0") -@file:DependsOn("org.tukaani:xz:1.0") - -import org.rauschig.jarchivelib.* -import java.io.File - -fun List.archive( - destinationFileName: String, - destinationDirectory: File, - archiveFormat: ArchiveFormat = ArchiveFormat.ZIP -) { - println("Packing...$destinationFileName") - val archiver = ArchiverFactory.createArchiver(archiveFormat) - runCatching { - archiver.create(destinationFileName, destinationDirectory, *toTypedArray()) - }.onFailure { - println("There was an error when packing ${destinationDirectory.absolutePath}${File.separator}$destinationFileName - $it") - } -} - diff --git a/flank-bash/scripts/ios/runFtlLocal.main.kts b/flank-bash/scripts/ios/runFtlLocal.main.kts index f6e4267f28..8fed0e31fe 100644 --- a/flank-bash/scripts/ios/runFtlLocal.main.kts +++ b/flank-bash/scripts/ios/runFtlLocal.main.kts @@ -6,7 +6,7 @@ @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) -@file:Import("../PathHelper.kt") +@file:Import("../util/PathHelper.kt") import eu.jrie.jetbrains.kotlinshell.shell.shell import java.nio.file.Path diff --git a/flank-bash/scripts/ios/universalFramework.main.kts b/flank-bash/scripts/ios/universalFramework.main.kts index a24bceaf0f..d4b428238c 100644 --- a/flank-bash/scripts/ios/universalFramework.main.kts +++ b/flank-bash/scripts/ios/universalFramework.main.kts @@ -6,7 +6,7 @@ @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) @file:Import("LipoHelper.kt") -@file:Import("../PathHelper.kt") +@file:Import("../util/PathHelper.kt") import eu.jrie.jetbrains.kotlinshell.shell.shell import java.nio.file.Paths diff --git a/flank-bash/scripts/ios/xcPretty.main.kts b/flank-bash/scripts/ios/xcPretty.main.kts deleted file mode 100644 index e2d3727921..0000000000 --- a/flank-bash/scripts/ios/xcPretty.main.kts +++ /dev/null @@ -1,21 +0,0 @@ -@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") -@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") -@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") - -@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") -@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) - -import eu.jrie.jetbrains.kotlinshell.shell.shell - -fun downloadXcPrettyIfNeeded() { - shell { - val exitCode = runCatching { - val process = "command -v xcpretty"() - process.pcb.exitCode - }.getOrDefault(1) - - if(exitCode != 0) { - "gem install xcpretty"() - } - } -} diff --git a/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts b/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts index e635ec03a0..bc2e43d229 100644 --- a/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts +++ b/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts @@ -2,7 +2,7 @@ @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") -@file:Import("../util/downloadFiles.main.kts") +@file:Import("../util/downloadSoftware.main.kts") @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) @@ -12,41 +12,26 @@ import java.nio.file.Files import java.nio.file.Paths import java.nio.file.StandardCopyOption -var containsPip = false -shell { - val exitCode = kotlin.runCatching { - val process = "pip -V"() - process.pcb.exitCode - }.getOrDefault(1) - containsPip = exitCode == 0 -} -if (!containsPip) { - downloadFile( - url = "https://bootstrap.pypa.io/get-pip.py", - destinationPath = "get-pip.py" - ) - shell { - "python get-pip.py"() - } -} +downloadPipIfNeeded() shell { "pip install google-apis-client-generator"() } - val apiPath = Paths.get("test_api").toString() +val outputDirectory = Paths.get(apiPath, "src", "main", "java").toString() +val testingJsonInput = Paths.get("json", "testing_v1.json").toString() Paths.get(apiPath, "src").toFile().deleteRecursively() shell { val generateLibraryCommand = "generate_library " + - "--input=./json/testing_v1.json " + + "--input=$testingJsonInput " + "--language=java " + "--package_path=api/services " + - "--output_dir=./test_api/src/main/java" + "--output_dir=$outputDirectory" generateLibraryCommand() } Files.move( - Paths.get(apiPath, "src", "main", "java", "pom.xml"), + Paths.get(outputDirectory, "pom.xml"), Paths.get(apiPath, "pom.xml"), StandardCopyOption.REPLACE_EXISTING ) diff --git a/flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts b/flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts index 9de8bcb079..3c3de57212 100644 --- a/flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts +++ b/flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts @@ -4,14 +4,15 @@ @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") @file:Import("../util/downloadFiles.main.kts") +@file:Import("../util/PathHelper.kt") +@file:Import("../util/downloadSoftware.main.kts") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) import eu.jrie.jetbrains.kotlinshell.shell.shell import java.nio.file.Paths -private val currentPath = Paths.get("").toString() -private val jsonDirectoryPath = Paths.get(currentPath, "json") +private val jsonDirectoryPath = Paths.get(currentPath.toString(), "json") val testingV1Path = Paths.get(jsonDirectoryPath.toString(), "testing_v1.json").toString() val testingV1Beta3Path = Paths.get(jsonDirectoryPath.toString(), "toolresults_v1beta3.json").toString() @@ -27,6 +28,8 @@ downloadFile( testingV1Beta3Path ) +downloadSortJsonIfNeeded() + shell { "sort-json $testingV1Path"() "sort-json $testingV1Beta3Path"() diff --git a/flank-bash/scripts/updateFlank.main.kts b/flank-bash/scripts/updateFlank.main.kts index cad83d8149..2d527b027b 100644 --- a/flank-bash/scripts/updateFlank.main.kts +++ b/flank-bash/scripts/updateFlank.main.kts @@ -1,8 +1,10 @@ @file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") + @file:Import("util/GradleCommand.kt") @file:Import("util/PathHelper.kt") + @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) diff --git a/flank-bash/scripts/updateLibs/updateAtomic.main.kts b/flank-bash/scripts/updateLibs/updateAtomic.main.kts index 767065a14e..556bf16a0a 100644 --- a/flank-bash/scripts/updateLibs/updateAtomic.main.kts +++ b/flank-bash/scripts/updateLibs/updateAtomic.main.kts @@ -1,7 +1,7 @@ @file:CompilerOptions("jvmTarget = '1.8'") @file:Import("../util/downloadFiles.main.kts") -@file:Import("../util/unpack.main.kts") +@file:Import("../util/archive.main.kts") import java.io.File import java.nio.file.Files diff --git a/flank-bash/scripts/updateLibs/updateLlvm.main.kts b/flank-bash/scripts/updateLibs/updateLlvm.main.kts index c18e106c9b..6f95aaba51 100644 --- a/flank-bash/scripts/updateLibs/updateLlvm.main.kts +++ b/flank-bash/scripts/updateLibs/updateLlvm.main.kts @@ -1,7 +1,7 @@ @file:CompilerOptions("jvmTarget = '1.8'") @file:Import("../util/downloadFiles.main.kts") -@file:Import("../util/unpack.main.kts") +@file:Import("../util/archive.main.kts") @file:Import("update.constants.kts") import java.nio.file.Files diff --git a/flank-bash/scripts/updateLibs/updateSwift.main.kts b/flank-bash/scripts/updateLibs/updateSwift.main.kts index 19f873e211..60e6676ef4 100644 --- a/flank-bash/scripts/updateLibs/updateSwift.main.kts +++ b/flank-bash/scripts/updateLibs/updateSwift.main.kts @@ -1,7 +1,7 @@ @file:CompilerOptions("jvmTarget = '1.8'") @file:Import("../util/downloadFiles.main.kts") -@file:Import("../util/unpack.main.kts") +@file:Import("../util/archive.main.kts") @file:Import("update.constants.kts") import java.nio.file.Files diff --git a/flank-bash/scripts/util/unpack.main.kts b/flank-bash/scripts/util/archive.main.kts similarity index 70% rename from flank-bash/scripts/util/unpack.main.kts rename to flank-bash/scripts/util/archive.main.kts index c5b8821662..850dcfe838 100644 --- a/flank-bash/scripts/util/unpack.main.kts +++ b/flank-bash/scripts/util/archive.main.kts @@ -40,3 +40,17 @@ fun File.extract( println("There was an error when unpacking $name - $it") } } + +fun List.archive( + destinationFileName: String, + destinationDirectory: File, + archiveFormat: ArchiveFormat = ArchiveFormat.ZIP +) { + println("Packing...$destinationFileName") + val archiver = ArchiverFactory.createArchiver(archiveFormat) + runCatching { + archiver.create(destinationFileName, destinationDirectory, *toTypedArray()) + }.onFailure { + println("There was an error when packing ${destinationDirectory.absolutePath}${File.separator}$destinationFileName - $it") + } +} diff --git a/flank-bash/scripts/util/downloadSoftware.main.kts b/flank-bash/scripts/util/downloadSoftware.main.kts new file mode 100644 index 0000000000..c750bf9c57 --- /dev/null +++ b/flank-bash/scripts/util/downloadSoftware.main.kts @@ -0,0 +1,49 @@ +@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") +@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") +@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") + +@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") +@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) + +import eu.jrie.jetbrains.kotlinshell.shell.Shell +import eu.jrie.jetbrains.kotlinshell.shell.shell +import java.io.File + +suspend fun Shell.commandExitCode(command: String) = runCatching { command().pcb.exitCode }.getOrDefault(1) + +fun checkAndInstall( + checkCommand: String, + install: suspend Shell.() -> Unit +) { + shell { + if (commandExitCode(checkCommand) != 0) { + install() + } + } +} + +fun downloadXcPrettyIfNeeded() { + checkAndInstall(checkCommand = "command -v xcpretty") { + "gem install xcpretty"() + } +} + +fun downloadPipIfNeeded() { + + checkAndInstall("pip -V") { + val pipOutputFile = File("get-pip.py") + downloadFile( + url = "https://bootstrap.pypa.io/get-pip.py", + destinationPath = pipOutputFile.absolutePath + ) + "python get-pip.py"() + + pipOutputFile.delete() + } +} + +fun downloadSortJsonIfNeeded() { + checkAndInstall("sort-json") { + "npm -g install sort-json"() + } +} From a8762cd4e8e6501bc8ae4561638d8153d47f609b Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 13 Oct 2020 16:49:13 +0200 Subject: [PATCH 28/95] Update ios.ops.main.kts --- flank-bash/scripts/ios.ops.main.kts | 108 ++++++++++++++++++---------- 1 file changed, 70 insertions(+), 38 deletions(-) diff --git a/flank-bash/scripts/ios.ops.main.kts b/flank-bash/scripts/ios.ops.main.kts index a6d1312783..541dfed955 100644 --- a/flank-bash/scripts/ios.ops.main.kts +++ b/flank-bash/scripts/ios.ops.main.kts @@ -9,64 +9,96 @@ import eu.jrie.jetbrains.kotlinshell.shell.* import java.io.File import java.nio.file.Files +import java.nio.file.Path import java.nio.file.Paths import java.nio.file.StandardCopyOption - suspend fun Shell.generateIos() = takeUnless { isWindows }?.let { setupIosEnv() installPods() + installXcpretty() buildEarlGreyExample() } suspend fun Shell.setupIosEnv() { val shouldInstallXcpretty = kotlin.runCatching { - val result = "xcpretty -v"() - result.pcb.exitCode + "xcpretty -v"().pcb.exitCode }.getOrDefault(1) != 0 if (shouldInstallXcpretty) "gem install cocoapods -v 1.9.3"() } suspend fun Shell.installPods() { - val earlGreyExample = Paths.get(iOsTestProjectsPath, "EarlGreyExample") + val earlGreyExample = Paths.get(iOsTestProjectsPath, earlGreyExample) kotlin.runCatching { "pod install --project-directory=$earlGreyExample --verbose"() } } -suspend fun Shell.buildEarlGreyExample() { - installXcpretty() - val buildDir = Paths.get(iOsTestProjectsPath, "EarlGreyExample", "Build") - buildDir.toFile().deleteRecursively() - - ("xcodebuild build-for-testing " + - "-allowProvisioningUpdates " + - "-workspace ${buildDir.parent}/EarlGreyExample.xcworkspace " + - "-scheme EarlGreyExampleSwiftTests " + - "-derivedDataPath ${buildDir.parent} " + - "-sdk iphoneos")() - - - ("xcodebuild build-for-testing " + - "-allowProvisioningUpdates " + - "-workspace ${buildDir.parent}/EarlGreyExample.xcworkspace " + - "-scheme EarlGreyExampleTests " + - "-derivedDataPath ${buildDir.parent} " + - "-sdk iphoneos")() - - Files.createDirectories(Paths.get(flankFixturesTmpPath, "objc")) - Files.createDirectories(Paths.get(flankFixturesTmpPath, "swift")) - val productsDir = Paths.get(buildDir.toString(), "Products") - productsDir.toFile().walk().filter { - it.nameWithoutExtension.endsWith("-iphoneos") || it.extension == "xctestrun" - }.forEach { - println(it.name) - if (it.isDirectory) it.copyRecursively(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) - else it.copyTo(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) - } - Files.copy(Paths.get(productsDir.toString(), "Debug-iphoneos", "EarlGreyExampleSwift.app", "PlugIns", "EarlGreyExampleTests.xctest", "EarlGreyExampleTests"), Paths.get(flankFixturesTmpPath, "objc", "EarlGreyExampleTests"), StandardCopyOption.REPLACE_EXISTING) - Files.copy(Paths.get(productsDir.toString(), "Debug-iphoneos", "EarlGreyExampleSwift.app", "PlugIns", "EarlGreyExampleSwiftTests.xctest", "EarlGreyExampleSwiftTests"), Paths.get(flankFixturesTmpPath, "swift", "EarlGreyExampleSwiftTests"), StandardCopyOption.REPLACE_EXISTING) -} - suspend fun Shell.installXcpretty() { val shouldInstallXcpretty = kotlin.runCatching { "xcpretty -v"().pcb.exitCode }.getOrDefault(1) != 0 if (shouldInstallXcpretty) ("gem install xcpretty")() } + +suspend fun buildEarlGreyExample() = Paths.get(iOsTestProjectsPath, earlGreyExample, buildDirectory).runBuilds().let { buildDir -> + createDirectories() + Paths.get(buildDir.toString(), "Products") +}.apply { + filterFilesToCopy().copyIosProductFiles() +}.copyTestFiles() + +fun Path.copyTestFiles() = toString().let { productsDirectory -> + copyTestFile(productsDirectory, earlGreyExampleTests, TestType.OBJECTIVE_C) + copyTestFile(productsDirectory, earlGreyExampleSwiftTests, TestType.SWIFT) +} + +fun copyTestFile(productsDirectory: String, name: String, type: TestType) = Files.copy( + Paths.get(productsDirectory, *pluginsDirectory, "$name.xctest", name), + Paths.get(flankFixturesTmpPath, type.toString().toLowerCase(), name), + StandardCopyOption.REPLACE_EXISTING +) + +suspend fun Path.runBuilds() = toFile().let { projectPath -> + projectPath.deleteRecursively() + shell { + createIosBuildCommand(projectPath.parent, scheme = earlGreyExampleTests)() + createIosBuildCommand(projectPath.parent, scheme = earlGreyExampleSwiftTests)() + } + this +} + +fun createDirectories() { + createDirectoryInFixture(directoryName = "objc") + createDirectoryInFixture(directoryName = "swift") +} + +fun createDirectoryInFixture(directoryName: String): Path = Files.createDirectories(Paths.get(flankFixturesTmpPath, directoryName)) + +fun createIosBuildCommand(buildDir: String, scheme: String) = "xcodebuild build-for-testing " + + "-allowProvisioningUpdates " + + "-workspace $buildDir/EarlGreyExample.xcworkspace " + + "-scheme $scheme " + + "-derivedDataPath $buildDir " + + "-sdk iphoneos" + +fun Path.filterFilesToCopy() = toFile().walk().filter { it.nameWithoutExtension.endsWith("-iphoneos") || it.extension == "xctestrun" } + +fun Sequence.copyIosProductFiles() = forEach { + if (it.isDirectory) it.copyRecursively(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) + else it.copyTo(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) +} + + +val debugIphoneOs = "Debug-iphoneos" +val earlGreyExampleSwift = "EarlGreyExampleSwift.app" +val plugins = "PlugIns" +val earlGreyExample = "EarlGreyExample" + +val earlGreyExampleTests = "EarlGreyExampleTests" +val earlGreyExampleSwiftTests = "EarlGreyExampleSwiftTests" + +val buildDirectory = "Build" + +val pluginsDirectory = arrayOf(debugIphoneOs, earlGreyExampleSwift, plugins) + +enum class TestType { + SWIFT, + OBJECTIVE_C +} From 391f63345fa19ee0550c6ab7396d74d331ab25d3 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 13 Oct 2020 17:30:32 +0200 Subject: [PATCH 29/95] Ios Command in separated file --- flank-bash/scripts/ios.ops.main.kts | 17 +++++++++-------- flank-bash/scripts/ios/util/IosBuildCommand.kt | 7 +++++++ 2 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 flank-bash/scripts/ios/util/IosBuildCommand.kt diff --git a/flank-bash/scripts/ios.ops.main.kts b/flank-bash/scripts/ios.ops.main.kts index 541dfed955..1b25b1c453 100644 --- a/flank-bash/scripts/ios.ops.main.kts +++ b/flank-bash/scripts/ios.ops.main.kts @@ -3,6 +3,7 @@ @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") @file:Import("util/GradleCommand.kt") @file:Import("util/PathHelper.kt") +@file:Import("ios/util/IosBuildCommand.kt") @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) @@ -58,8 +59,14 @@ fun copyTestFile(productsDirectory: String, name: String, type: TestType) = File suspend fun Path.runBuilds() = toFile().let { projectPath -> projectPath.deleteRecursively() shell { - createIosBuildCommand(projectPath.parent, scheme = earlGreyExampleTests)() - createIosBuildCommand(projectPath.parent, scheme = earlGreyExampleSwiftTests)() + val swiftCommand = createIosBuildCommand( + projectPath.parent, Paths.get(projectPath.parent, "EarlGreyExample.xcworkspace").toString(), scheme = earlGreyExampleTests + ).process() + + pipeline { swiftCommand pipe "xcpretty".process() } + + val objcCommand = createIosBuildCommand(projectPath.parent, Paths.get(projectPath.parent, "EarlGreyExample.xcworkspace").toString(), scheme = earlGreyExampleSwiftTests).process() + pipeline { objcCommand pipe "xcpretty".process() } } this } @@ -71,12 +78,6 @@ fun createDirectories() { fun createDirectoryInFixture(directoryName: String): Path = Files.createDirectories(Paths.get(flankFixturesTmpPath, directoryName)) -fun createIosBuildCommand(buildDir: String, scheme: String) = "xcodebuild build-for-testing " + - "-allowProvisioningUpdates " + - "-workspace $buildDir/EarlGreyExample.xcworkspace " + - "-scheme $scheme " + - "-derivedDataPath $buildDir " + - "-sdk iphoneos" fun Path.filterFilesToCopy() = toFile().walk().filter { it.nameWithoutExtension.endsWith("-iphoneos") || it.extension == "xctestrun" } diff --git a/flank-bash/scripts/ios/util/IosBuildCommand.kt b/flank-bash/scripts/ios/util/IosBuildCommand.kt new file mode 100644 index 0000000000..4fefcbac26 --- /dev/null +++ b/flank-bash/scripts/ios/util/IosBuildCommand.kt @@ -0,0 +1,7 @@ +fun createIosBuildCommand(buildDir: String, workSpace: String, scheme: String) = + "xcodebuild build-for-testing " + + "-allowProvisioningUpdates " + + "-workspace $workSpace " + + "-scheme $scheme " + + "-derivedDataPath $buildDir " + + "-sdk iphoneos" From a0d974c82057de6ae706d29ed9bc970b80b61f54 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 13 Oct 2020 17:36:27 +0200 Subject: [PATCH 30/95] ios example change to createCommand --- flank-bash/scripts/ios/buildExample.main.kts | 16 +++------------- flank-bash/scripts/ios/util/IosBuildCommand.kt | 4 ++-- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/flank-bash/scripts/ios/buildExample.main.kts b/flank-bash/scripts/ios/buildExample.main.kts index 3fb2223c9e..89a5b3c8fa 100644 --- a/flank-bash/scripts/ios/buildExample.main.kts +++ b/flank-bash/scripts/ios/buildExample.main.kts @@ -9,6 +9,7 @@ @file:Import("../util/archive.main.kts") @file:Import("../util/downloadSoftware.main.kts") @file:Import("../util/PathHelper.kt") +@file:Import("util/IosBuildCommand.kt") import eu.jrie.jetbrains.kotlinshell.shell.shell import java.nio.file.Files @@ -25,23 +26,12 @@ downloadXcPrettyIfNeeded() shell { - val xcodeCommandSwiftTests = "xcodebuild build-for-testing" + - " -allowProvisioningUpdates" + - " -workspace ./EarlGreyExample.xcworkspace" + - " -scheme \"EarlGreyExampleSwiftTests\"" + - " -derivedDataPath $dataPath" + - " -sdk iphoneos".process() + val xcodeCommandSwiftTests = createIosBuildCommand(dataPath.toString(),"./EarlGreyExample.xcworkspace", "EarlGreyExampleSwiftTests") val xcPrettyCommand = "xcpretty".process() pipeline { xcodeCommandSwiftTests pipe xcPrettyCommand } - val xcodeCommandTests = "xcodebuild build-for-testing" + - " -allowProvisioningUpdates" + - " -workspace ./EarlGreyExample.xcworkspace" + - " -scheme \"EarlGreyExampleTests\"" + - " -derivedDataPath $dataPath" + - " -sdk iphoneos".process() - + val xcodeCommandTests = createIosBuildCommand(dataPath.toString(),"./EarlGreyExample.xcworkspace", "EarlGreyExampleTests") pipeline { xcodeCommandTests pipe xcPrettyCommand } } diff --git a/flank-bash/scripts/ios/util/IosBuildCommand.kt b/flank-bash/scripts/ios/util/IosBuildCommand.kt index 4fefcbac26..42b72f61a2 100644 --- a/flank-bash/scripts/ios/util/IosBuildCommand.kt +++ b/flank-bash/scripts/ios/util/IosBuildCommand.kt @@ -1,7 +1,7 @@ -fun createIosBuildCommand(buildDir: String, workSpace: String, scheme: String) = +fun createIosBuildCommand(buildDir: String, workspace: String, scheme: String) = "xcodebuild build-for-testing " + "-allowProvisioningUpdates " + - "-workspace $workSpace " + + "-workspace $workspace " + "-scheme $scheme " + "-derivedDataPath $buildDir " + "-sdk iphoneos" From a3eecf8919d3cc050dae76328b90a86ec672a92f Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 13 Oct 2020 18:06:37 +0200 Subject: [PATCH 31/95] Move some functions of ios to downloadSoftware main --- flank-bash/scripts/ios.ops.main.kts | 64 +++++++------------ flank-bash/scripts/util/PathHelper.kt | 2 +- .../scripts/util/downloadSoftware.main.kts | 14 +++- 3 files changed, 37 insertions(+), 43 deletions(-) diff --git a/flank-bash/scripts/ios.ops.main.kts b/flank-bash/scripts/ios.ops.main.kts index 1b25b1c453..1c54a4106f 100644 --- a/flank-bash/scripts/ios.ops.main.kts +++ b/flank-bash/scripts/ios.ops.main.kts @@ -4,6 +4,7 @@ @file:Import("util/GradleCommand.kt") @file:Import("util/PathHelper.kt") @file:Import("ios/util/IosBuildCommand.kt") +@file:Import("util/downloadSoftware.main.kts") @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) @@ -14,37 +15,37 @@ import java.nio.file.Path import java.nio.file.Paths import java.nio.file.StandardCopyOption -suspend fun Shell.generateIos() = takeUnless { isWindows }?.let { - setupIosEnv() - installPods() - installXcpretty() - buildEarlGreyExample() -} -suspend fun Shell.setupIosEnv() { - val shouldInstallXcpretty = kotlin.runCatching { - "xcpretty -v"().pcb.exitCode - }.getOrDefault(1) != 0 - if (shouldInstallXcpretty) "gem install cocoapods -v 1.9.3"() -} +val debugIphoneOs = "Debug-iphoneos" +val earlGreyExampleSwift = "EarlGreyExampleSwift.app" +val plugins = "PlugIns" +val earlGreyExample = "EarlGreyExample" +val earlGreyExampleTests = "EarlGreyExampleTests" +val earlGreyExampleSwiftTests = "EarlGreyExampleSwiftTests" +val buildDirectory = "Build" +val pluginsDirectory = arrayOf(debugIphoneOs, earlGreyExampleSwift, plugins) -suspend fun Shell.installPods() { - val earlGreyExample = Paths.get(iOsTestProjectsPath, earlGreyExample) - kotlin.runCatching { "pod install --project-directory=$earlGreyExample --verbose"() } +enum class TestType { + SWIFT, + OBJECTIVE_C } -suspend fun Shell.installXcpretty() { - val shouldInstallXcpretty = kotlin.runCatching { "xcpretty -v"().pcb.exitCode }.getOrDefault(1) != 0 - if (shouldInstallXcpretty) ("gem install xcpretty")() -} -suspend fun buildEarlGreyExample() = Paths.get(iOsTestProjectsPath, earlGreyExample, buildDirectory).runBuilds().let { buildDir -> +suspend fun Shell.generateIos() = takeUnless { isWindows }?.let { + downloadCocoaPodsIfNeeded() + installPods(Paths.get(iOSTestProjectsPath, earlGreyExample)) + downloadXcPrettyIfNeeded() createDirectories() - Paths.get(buildDir.toString(), "Products") -}.apply { + buildEarlGreyExample() +} + +suspend fun buildEarlGreyExample() = buildDirectoryPath.runBuilds().resolve("Products").apply { filterFilesToCopy().copyIosProductFiles() }.copyTestFiles() + +val buildDirectoryPath = Paths.get(iOSTestProjectsPath, earlGreyExample, buildDirectory) + fun Path.copyTestFiles() = toString().let { productsDirectory -> copyTestFile(productsDirectory, earlGreyExampleTests, TestType.OBJECTIVE_C) copyTestFile(productsDirectory, earlGreyExampleSwiftTests, TestType.SWIFT) @@ -78,28 +79,9 @@ fun createDirectories() { fun createDirectoryInFixture(directoryName: String): Path = Files.createDirectories(Paths.get(flankFixturesTmpPath, directoryName)) - fun Path.filterFilesToCopy() = toFile().walk().filter { it.nameWithoutExtension.endsWith("-iphoneos") || it.extension == "xctestrun" } fun Sequence.copyIosProductFiles() = forEach { if (it.isDirectory) it.copyRecursively(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) else it.copyTo(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) } - - -val debugIphoneOs = "Debug-iphoneos" -val earlGreyExampleSwift = "EarlGreyExampleSwift.app" -val plugins = "PlugIns" -val earlGreyExample = "EarlGreyExample" - -val earlGreyExampleTests = "EarlGreyExampleTests" -val earlGreyExampleSwiftTests = "EarlGreyExampleSwiftTests" - -val buildDirectory = "Build" - -val pluginsDirectory = arrayOf(debugIphoneOs, earlGreyExampleSwift, plugins) - -enum class TestType { - SWIFT, - OBJECTIVE_C -} diff --git a/flank-bash/scripts/util/PathHelper.kt b/flank-bash/scripts/util/PathHelper.kt index 95a3ee961c..bfc6ba5eb6 100644 --- a/flank-bash/scripts/util/PathHelper.kt +++ b/flank-bash/scripts/util/PathHelper.kt @@ -10,6 +10,6 @@ val currentPath = Paths.get("") val testProjectsPath = Paths.get(rootDirectoryPath, "test_projects").toString() val androidTestProjectsPath = Paths.get(testProjectsPath, "android").toString() -val iOsTestProjectsPath = Paths.get(testProjectsPath, "ios").toString() +val iOSTestProjectsPath = Paths.get(testProjectsPath, "ios").toString() val flankFixturesTmpPath = Paths.get(rootDirectoryPath, "test_runner", "src", "test", "kotlin", "ftl", "fixtures", "tmp").toString() diff --git a/flank-bash/scripts/util/downloadSoftware.main.kts b/flank-bash/scripts/util/downloadSoftware.main.kts index c750bf9c57..3242b05fd0 100644 --- a/flank-bash/scripts/util/downloadSoftware.main.kts +++ b/flank-bash/scripts/util/downloadSoftware.main.kts @@ -1,13 +1,15 @@ @file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") - +@file:Import("downloadFiles.main.kts") @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) import eu.jrie.jetbrains.kotlinshell.shell.Shell import eu.jrie.jetbrains.kotlinshell.shell.shell import java.io.File +import java.nio.file.Path +import java.nio.file.Paths suspend fun Shell.commandExitCode(command: String) = runCatching { command().pcb.exitCode }.getOrDefault(1) @@ -28,6 +30,16 @@ fun downloadXcPrettyIfNeeded() { } } +fun downloadCocoaPodsIfNeeded() { + checkAndInstall(checkCommand = "command -v xcpretty") { + "gem install cocoapods -v 1.9.3"() + } +} + +suspend fun Shell.installPods(path: Path) { + kotlin.runCatching { "pod install --project-directory=$path --verbose"() } +} + fun downloadPipIfNeeded() { checkAndInstall("pip -V") { From 39d1929871b75c828302a9180cfe99efd96b3019 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Tue, 13 Oct 2020 18:17:22 +0200 Subject: [PATCH 32/95] refactor utils --- flank-bash/scripts/ios/buildFtl.main.kts | 2 +- .../scripts/updateLibs/updateAtomic.main.kts | 2 -- .../updateLibs/updateBinaries.main.kts | 21 +++---------------- .../scripts/updateLibs/updateLlvm.main.kts | 2 +- .../scripts/updateLibs/updateSwift.main.kts | 2 +- .../scripts/util/downloadSoftware.main.kts | 1 - 6 files changed, 6 insertions(+), 24 deletions(-) diff --git a/flank-bash/scripts/ios/buildFtl.main.kts b/flank-bash/scripts/ios/buildFtl.main.kts index 282ad50861..c2aa530fcb 100644 --- a/flank-bash/scripts/ios/buildFtl.main.kts +++ b/flank-bash/scripts/ios/buildFtl.main.kts @@ -5,7 +5,7 @@ @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) -@file:Import("xcPretty.main.kts") +@file:Import("../util/downloadSoftware.main.kts") @file:Import("../util/archive.main.kts") @file:Import("../util/PathHelper.kt") diff --git a/flank-bash/scripts/updateLibs/updateAtomic.main.kts b/flank-bash/scripts/updateLibs/updateAtomic.main.kts index 556bf16a0a..124044a657 100644 --- a/flank-bash/scripts/updateLibs/updateAtomic.main.kts +++ b/flank-bash/scripts/updateLibs/updateAtomic.main.kts @@ -3,10 +3,8 @@ @file:Import("../util/downloadFiles.main.kts") @file:Import("../util/archive.main.kts") -import java.io.File import java.nio.file.Files import java.nio.file.Paths -import java.nio.file.StandardCopyOption import java.util.stream.Collectors private val currentPath = Paths.get("") diff --git a/flank-bash/scripts/updateLibs/updateBinaries.main.kts b/flank-bash/scripts/updateLibs/updateBinaries.main.kts index 50c7be5604..b7e1d26b7f 100644 --- a/flank-bash/scripts/updateLibs/updateBinaries.main.kts +++ b/flank-bash/scripts/updateLibs/updateBinaries.main.kts @@ -1,24 +1,9 @@ -@file:Repository("https://repo1.maven.org/maven2/org/rauschig/jarchivelib/") -@file:DependsOn("org.rauschig:jarchivelib:1.1.0") -@file:DependsOn("org.tukaani:xz:1.0") - -@file:Repository("https://dl.bintray.com/kittinunf/maven/com/github/kittinunf/fuel/fuel/") -@file:DependsOn("com.github.kittinunf.fuel:fuel:2.3.0") -@file:DependsOn("com.github.kittinunf.fuel:fuel-coroutines:2.3.0") - @file:Import("updateAtomic.main.kts") @file:Import("updateLlvm.main.kts") @file:Import("updateSwift.main.kts") -@file:DependsOn("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9") - -import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.launch - -runBlocking { - launch { updateAtomic() } - launch { updateLlvm() } - launch { updateSwift() } -} +updateAtomic() +updateLlvm() +updateSwift() println("Binaries updated!") diff --git a/flank-bash/scripts/updateLibs/updateLlvm.main.kts b/flank-bash/scripts/updateLibs/updateLlvm.main.kts index 6f95aaba51..26e31c6be5 100644 --- a/flank-bash/scripts/updateLibs/updateLlvm.main.kts +++ b/flank-bash/scripts/updateLibs/updateLlvm.main.kts @@ -36,7 +36,7 @@ fun updateLlvmNonWindows() { if (llvmTarXz.toFile().exists()) { println("LLVM exists") } else { - println("Downloading LLVM for Windows...") + println("Downloading LLVM...") llvmPath.toFile().mkdirs() downloadFile( url = "http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz", diff --git a/flank-bash/scripts/updateLibs/updateSwift.main.kts b/flank-bash/scripts/updateLibs/updateSwift.main.kts index 60e6676ef4..08aa28f268 100644 --- a/flank-bash/scripts/updateLibs/updateSwift.main.kts +++ b/flank-bash/scripts/updateLibs/updateSwift.main.kts @@ -17,7 +17,7 @@ fun updateSwiftWindows() { if (swiftExe.toFile().exists()) { println("Swift exists") } else { - println("Downloading swift") + println("Downloading swift for Windows") swiftPath.toFile().mkdirs() downloadFile( url = "https://swift.org/builds/swift-5.3-release/windows10/swift-5.3-RELEASE/swift-5.3-RELEASE-windows10.exe", diff --git a/flank-bash/scripts/util/downloadSoftware.main.kts b/flank-bash/scripts/util/downloadSoftware.main.kts index 3242b05fd0..1b66a4407a 100644 --- a/flank-bash/scripts/util/downloadSoftware.main.kts +++ b/flank-bash/scripts/util/downloadSoftware.main.kts @@ -9,7 +9,6 @@ import eu.jrie.jetbrains.kotlinshell.shell.Shell import eu.jrie.jetbrains.kotlinshell.shell.shell import java.io.File import java.nio.file.Path -import java.nio.file.Paths suspend fun Shell.commandExitCode(command: String) = runCatching { command().pcb.exitCode }.getOrDefault(1) From dd3986abe8447b1cfaa379bd5c6d7161629ac19e Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 14 Oct 2020 11:51:19 +0200 Subject: [PATCH 33/95] Update ios.ops.main.kts --- flank-bash/scripts/ios.ops.main.kts | 34 ++++++++++++----------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/flank-bash/scripts/ios.ops.main.kts b/flank-bash/scripts/ios.ops.main.kts index 1c54a4106f..9ff847e65f 100644 --- a/flank-bash/scripts/ios.ops.main.kts +++ b/flank-bash/scripts/ios.ops.main.kts @@ -30,15 +30,17 @@ enum class TestType { OBJECTIVE_C } - suspend fun Shell.generateIos() = takeUnless { isWindows }?.let { downloadCocoaPodsIfNeeded() installPods(Paths.get(iOSTestProjectsPath, earlGreyExample)) downloadXcPrettyIfNeeded() - createDirectories() + createDirectoryInFixture(directoryName = "objc") + createDirectoryInFixture(directoryName = "swift") buildEarlGreyExample() } +fun createDirectoryInFixture(directoryName: String): Path = Files.createDirectories(Paths.get(flankFixturesTmpPath, directoryName)) + suspend fun buildEarlGreyExample() = buildDirectoryPath.runBuilds().resolve("Products").apply { filterFilesToCopy().copyIosProductFiles() }.copyTestFiles() @@ -46,17 +48,6 @@ suspend fun buildEarlGreyExample() = buildDirectoryPath.runBuilds().resolve("Pro val buildDirectoryPath = Paths.get(iOSTestProjectsPath, earlGreyExample, buildDirectory) -fun Path.copyTestFiles() = toString().let { productsDirectory -> - copyTestFile(productsDirectory, earlGreyExampleTests, TestType.OBJECTIVE_C) - copyTestFile(productsDirectory, earlGreyExampleSwiftTests, TestType.SWIFT) -} - -fun copyTestFile(productsDirectory: String, name: String, type: TestType) = Files.copy( - Paths.get(productsDirectory, *pluginsDirectory, "$name.xctest", name), - Paths.get(flankFixturesTmpPath, type.toString().toLowerCase(), name), - StandardCopyOption.REPLACE_EXISTING -) - suspend fun Path.runBuilds() = toFile().let { projectPath -> projectPath.deleteRecursively() shell { @@ -72,16 +63,19 @@ suspend fun Path.runBuilds() = toFile().let { projectPath -> this } -fun createDirectories() { - createDirectoryInFixture(directoryName = "objc") - createDirectoryInFixture(directoryName = "swift") -} - -fun createDirectoryInFixture(directoryName: String): Path = Files.createDirectories(Paths.get(flankFixturesTmpPath, directoryName)) - fun Path.filterFilesToCopy() = toFile().walk().filter { it.nameWithoutExtension.endsWith("-iphoneos") || it.extension == "xctestrun" } fun Sequence.copyIosProductFiles() = forEach { if (it.isDirectory) it.copyRecursively(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) else it.copyTo(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) } +fun Path.copyTestFiles() = toString().let { productsDirectory -> + copyTestFile(productsDirectory, earlGreyExampleTests, TestType.OBJECTIVE_C) + copyTestFile(productsDirectory, earlGreyExampleSwiftTests, TestType.SWIFT) +} + +fun copyTestFile(productsDirectory: String, name: String, type: TestType) = Files.copy( + Paths.get(productsDirectory, *pluginsDirectory, "$name.xctest", name), + Paths.get(flankFixturesTmpPath, type.toString().toLowerCase(), name), + StandardCopyOption.REPLACE_EXISTING +) From f22a5ff220d0ec46f22c1f4fe46eee1c5b3a0b38 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 14 Oct 2020 13:38:34 +0200 Subject: [PATCH 34/95] Add go build execution to ops --- flank-bash/scripts/buildGo.main.kts | 6 ++++-- flank-bash/scripts/ops.main.kts | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/flank-bash/scripts/buildGo.main.kts b/flank-bash/scripts/buildGo.main.kts index 277c6c2a18..d010b4f44b 100644 --- a/flank-bash/scripts/buildGo.main.kts +++ b/flank-bash/scripts/buildGo.main.kts @@ -37,7 +37,9 @@ fun createExecutable(os: GoOS) { } } -goHelloBinDirectoryPath.toFile().deleteRecursively() +fun generateGoArtifacts() { + goHelloBinDirectoryPath.toFile().deleteRecursively() + GoOS.values().forEach { createExecutable(it) } +} -GoOS.values().forEach { createExecutable(it) } diff --git a/flank-bash/scripts/ops.main.kts b/flank-bash/scripts/ops.main.kts index 2d1a32845c..05aaacf73f 100644 --- a/flank-bash/scripts/ops.main.kts +++ b/flank-bash/scripts/ops.main.kts @@ -3,6 +3,7 @@ @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") @file:Import("android.ops.main.kts") @file:Import("ios.ops.main.kts") +@file:Import("buildGo.main.kts") @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) @@ -19,6 +20,7 @@ shell { when (it) { OpsOptions.ANDROID.toString() -> generateApkAndTests() OpsOptions.IOS.toString() -> generateIos() + OpsOptions.GO.toString() -> generateGoArtifacts() } } } From 6a2169cfa172d54fd1d485a7933546b09f51896f Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Wed, 14 Oct 2020 15:15:17 +0200 Subject: [PATCH 35/95] added shell and bat script for firebase api --- firebase_apis/update_api_json.bat | 1 + firebase_apis/update_api_json.sh | 19 +------------------ flank-bash/scripts/ios/runFtlLocal.main.kts | 1 - .../generateJavaClient.main.kts | 4 ++-- .../scripts/util/downloadSoftware.main.kts | 18 +++++++----------- 5 files changed, 11 insertions(+), 32 deletions(-) create mode 100755 firebase_apis/update_api_json.bat diff --git a/firebase_apis/update_api_json.bat b/firebase_apis/update_api_json.bat new file mode 100755 index 0000000000..67721889e3 --- /dev/null +++ b/firebase_apis/update_api_json.bat @@ -0,0 +1 @@ +kotlin ../flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts diff --git a/firebase_apis/update_api_json.sh b/firebase_apis/update_api_json.sh index f1635105cc..67721889e3 100755 --- a/firebase_apis/update_api_json.sh +++ b/firebase_apis/update_api_json.sh @@ -1,18 +1 @@ -#!/usr/bin/env bash - -# npm -g install sort-json - -# Note: API discovery JSON is out of date. Check the gcloud CLI repo for most recent JSON. -# https://github.com/bootstraponline/gcloud_cli/blob/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/testing_v1.json - -cd json - -TOOL_RESULTS=toolresults_v1beta3.json -rm "$TOOL_RESULTS" -curl -o "$TOOL_RESULTS" https://www.googleapis.com/discovery/v1/apis/toolresults/v1beta3/rest -sort-json "$TOOL_RESULTS" - -TESTING=testing_v1.json -rm "$TESTING" -curl -o "$TESTING" https://www.googleapis.com/discovery/v1/apis/testing/v1/rest -sort-json "$TESTING" +kotlin ../flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts diff --git a/flank-bash/scripts/ios/runFtlLocal.main.kts b/flank-bash/scripts/ios/runFtlLocal.main.kts index 8fed0e31fe..837d92deb8 100644 --- a/flank-bash/scripts/ios/runFtlLocal.main.kts +++ b/flank-bash/scripts/ios/runFtlLocal.main.kts @@ -1,4 +1,3 @@ - @file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") diff --git a/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts b/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts index bc2e43d229..731e49f966 100644 --- a/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts +++ b/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts @@ -12,8 +12,8 @@ import java.nio.file.Files import java.nio.file.Paths import java.nio.file.StandardCopyOption -downloadPipIfNeeded() - +checkIfPipInstalled() +print("X1112") shell { "pip install google-apis-client-generator"() } diff --git a/flank-bash/scripts/util/downloadSoftware.main.kts b/flank-bash/scripts/util/downloadSoftware.main.kts index 1b66a4407a..0029c7e595 100644 --- a/flank-bash/scripts/util/downloadSoftware.main.kts +++ b/flank-bash/scripts/util/downloadSoftware.main.kts @@ -9,6 +9,7 @@ import eu.jrie.jetbrains.kotlinshell.shell.Shell import eu.jrie.jetbrains.kotlinshell.shell.shell import java.io.File import java.nio.file.Path +import kotlin.system.exitProcess suspend fun Shell.commandExitCode(command: String) = runCatching { command().pcb.exitCode }.getOrDefault(1) @@ -39,17 +40,12 @@ suspend fun Shell.installPods(path: Path) { kotlin.runCatching { "pod install --project-directory=$path --verbose"() } } -fun downloadPipIfNeeded() { - - checkAndInstall("pip -V") { - val pipOutputFile = File("get-pip.py") - downloadFile( - url = "https://bootstrap.pypa.io/get-pip.py", - destinationPath = pipOutputFile.absolutePath - ) - "python get-pip.py"() - - pipOutputFile.delete() +fun checkIfPipInstalled() { + shell { + if(commandExitCode("pip3 -V") != 0) { + println("You need pip fot this script. To install it follow https://pip.pypa.io/en/stable/installing/") + exitProcess(1) + } } } From 1415eeb3c34d9571d199a2f98d9014f52b644ab3 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Wed, 14 Oct 2020 16:01:14 +0200 Subject: [PATCH 36/95] added shell for generate java client --- firebase_apis/generate_java_client.bat | 1 + firebase_apis/generate_java_client.sh | 33 +------------------ .../generateJavaClient.main.kts | 6 +--- .../scripts/util/downloadSoftware.main.kts | 13 ++++++-- 4 files changed, 14 insertions(+), 39 deletions(-) create mode 100755 firebase_apis/generate_java_client.bat diff --git a/firebase_apis/generate_java_client.bat b/firebase_apis/generate_java_client.bat new file mode 100755 index 0000000000..ac21832c2a --- /dev/null +++ b/firebase_apis/generate_java_client.bat @@ -0,0 +1 @@ +kotlin ../flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts diff --git a/firebase_apis/generate_java_client.sh b/firebase_apis/generate_java_client.sh index 08cc4b5f61..ac21832c2a 100755 --- a/firebase_apis/generate_java_client.sh +++ b/firebase_apis/generate_java_client.sh @@ -1,32 +1 @@ -#!/bin/bash - -# Note: Must have already installed google-apis-client-generator from the master branch. PIP release will not work! - -# git clone https://github.com/google/apis-client-generator.git -# xcode-select --install -# brew install python@2 -# export PATH="/usr/local/opt/python@2/libexec/bin:$PATH" -# pip install --upgrade pip setuptools -# pip install . - -# Generate only the testing library since the others are published officially already. - -# generate_library \ -# --input=./storage_v1.json \ -# --language=java \ -# --output_dir=./storage - -rm -rf "./test_api/src/" - - generate_library \ - --input=./json/testing_v1.json \ - --language=java \ - --package_path=api/services \ - --output_dir=./test_api/src/main/java - -mv ./test_api/src/main/java/pom.xml ./test_api/pom.xml - -# generate_library \ -# --input=./toolresults_v1beta3.json \ -# --language=java \ -# --output_dir=./apis/toolresults +kotlin ../flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts diff --git a/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts b/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts index 731e49f966..0420b2f125 100644 --- a/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts +++ b/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts @@ -12,11 +12,7 @@ import java.nio.file.Files import java.nio.file.Paths import java.nio.file.StandardCopyOption -checkIfPipInstalled() -print("X1112") -shell { - "pip install google-apis-client-generator"() -} +installClientGeneratorIfNeeded() val apiPath = Paths.get("test_api").toString() val outputDirectory = Paths.get(apiPath, "src", "main", "java").toString() val testingJsonInput = Paths.get("json", "testing_v1.json").toString() diff --git a/flank-bash/scripts/util/downloadSoftware.main.kts b/flank-bash/scripts/util/downloadSoftware.main.kts index 0029c7e595..1982a4f3fd 100644 --- a/flank-bash/scripts/util/downloadSoftware.main.kts +++ b/flank-bash/scripts/util/downloadSoftware.main.kts @@ -7,7 +7,6 @@ import eu.jrie.jetbrains.kotlinshell.shell.Shell import eu.jrie.jetbrains.kotlinshell.shell.shell -import java.io.File import java.nio.file.Path import kotlin.system.exitProcess @@ -42,7 +41,7 @@ suspend fun Shell.installPods(path: Path) { fun checkIfPipInstalled() { shell { - if(commandExitCode("pip3 -V") != 0) { + if(commandExitCode("pip -V") != 0) { println("You need pip fot this script. To install it follow https://pip.pypa.io/en/stable/installing/") exitProcess(1) } @@ -54,3 +53,13 @@ fun downloadSortJsonIfNeeded() { "npm -g install sort-json"() } } + +fun installClientGeneratorIfNeeded() { + val isWindows = System.getProperty("os.name").startsWith("Windows") + val generateLibraryCheckCommand = (if(isWindows) "where " else "command -v ") + "generate_library" + + checkAndInstall(generateLibraryCheckCommand) { + checkIfPipInstalled() + "pip install google-apis-client-generator"() + } +} From 0cf94a63b0a237bf2096135aa82bfc5003c98561 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Wed, 14 Oct 2020 17:27:38 +0200 Subject: [PATCH 37/95] refactor gradle helper --- flank-bash/scripts/android.ops.main.kts | 35 ++++++++----------- flank-bash/scripts/buildFlankScripts.main.kts | 11 +++--- flank-bash/scripts/buildGo.main.kts | 2 +- flank-bash/scripts/updateFlank.main.kts | 11 +++--- flank-bash/scripts/util/GradleCommand.kt | 9 +++-- flank-bash/scripts/util/PathHelper.kt | 20 ++++++----- 6 files changed, 42 insertions(+), 46 deletions(-) diff --git a/flank-bash/scripts/android.ops.main.kts b/flank-bash/scripts/android.ops.main.kts index 4d113acd24..36fa14df63 100644 --- a/flank-bash/scripts/android.ops.main.kts +++ b/flank-bash/scripts/android.ops.main.kts @@ -22,10 +22,9 @@ suspend fun Shell.generateApkAndTests() { } suspend fun Shell.baseAppApk() { - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, "app:assemble") - )() + shell(dir = rootDirectoryFile) { + createGradleCommand("app:assemble")() + } val outputDir = Paths.get(flankFixturesTmpPath, "apk", "app-debug.apk") if (!outputDir.parent.toFile().exists()) Files.createDirectories(outputDir.parent) val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "singleSuccess", "debug", "app-single-success-debug.apk") @@ -34,10 +33,9 @@ suspend fun Shell.baseAppApk() { } suspend fun Shell.baseTesApks() { - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, "app:assembleAndroidTest") - )() + shell(dir = rootDirectoryFile) { + createGradleCommand("app:assembleAndroidTest")() + } val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "androidTest") File(assembleDirectory.toString()).findApks().forEach { Files.copy(it.toPath(), Paths.get(flankFixturesTmpPath, "apk", it.name), StandardCopyOption.REPLACE_EXISTING) @@ -46,10 +44,9 @@ suspend fun Shell.baseTesApks() { suspend fun Shell.duplicatedNamesApks() { val modules = (0..3).map { "dir$it" } - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath) + modules.map { "$it:testModule:assembleAndroidTest" } - )() + shell(dir = rootDirectoryFile) { + createGradleCommand(modules.map { "$it:testModule:assembleAndroidTest" })() + } val outputDir = Paths.get(flankFixturesTmpPath, "apk", "duplicated_names") if (!outputDir.toFile().exists()) Files.createDirectories(outputDir) @@ -66,20 +63,18 @@ fun File.copyApkToDirectory(output: Path) = toPath().let { sourceFile -> } suspend fun Shell.multiModulesApks() { - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, ":multi-modules:multiapp:assemble") + (1..20).map { ":multi-modules:testModule$it:assembleAndroidTest" } - )() + shell(dir = rootDirectoryFile) { + createGradleCommand(listOf(":multi-modules:multiapp:assemble") + (1..20).map { ":multi-modules:testModule$it:assembleAndroidTest" })() + } val outputDir = Paths.get(flankFixturesTmpPath, "apk", "multi-modules").toString() Paths.get(androidTestProjectsPath, "multi-modules").toFile().findApks() .forEach { it.copyApkToDirectory(Paths.get(outputDir, it.name)) } } suspend fun Shell.cucumberSampleApp() { - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, "cucumber_sample_app:cukeulator:assembleDebug", ":cucumber_sample_app:cukeulator:assembleAndroidTest") - )() + shell(dir = rootDirectoryFile) { + createGradleCommand("cucumber_sample_app:cukeulator:assembleDebug", ":cucumber_sample_app:cukeulator:assembleAndroidTest")() + } val outputDir = Paths.get(flankFixturesTmpPath, "apk", "cucumber_sample_app").toString() Paths.get(androidTestProjectsPath, "cucumber_sample_app").toFile().findApks().copyApksToPath(outputDir) } diff --git a/flank-bash/scripts/buildFlankScripts.main.kts b/flank-bash/scripts/buildFlankScripts.main.kts index ca40fee67e..fa8052b39a 100644 --- a/flank-bash/scripts/buildFlankScripts.main.kts +++ b/flank-bash/scripts/buildFlankScripts.main.kts @@ -10,15 +10,12 @@ import eu.jrie.jetbrains.kotlinshell.shell.* import java.nio.file.Path import java.nio.file.Paths -val gradleCommand = createGradleCommand( - workingDir = rootDirectoryPath, - options = listOf(":flank-scripts:clean", ":flank-scripts:assemble", ":flank-scripts:shadowJar") -) - -val flankScriptsDirectory: Path = Paths.get(rootDirectoryPath, "flank-scripts") +val flankScriptsDirectory: Path = Paths.get(rootDirectoryPathString, "flank-scripts") shell { - gradleCommand() + shell(dir = rootDirectoryFile) { + createGradleCommand(":flank-scripts:clean", ":flank-scripts:assemble", ":flank-scripts:shadowJar")() + } } Paths.get(flankScriptsDirectory.toString(), "build", "libs", "flankScripts.jar").toFile() diff --git a/flank-bash/scripts/buildGo.main.kts b/flank-bash/scripts/buildGo.main.kts index d010b4f44b..1aa991a351 100644 --- a/flank-bash/scripts/buildGo.main.kts +++ b/flank-bash/scripts/buildGo.main.kts @@ -22,7 +22,7 @@ enum class GoOS( } private val goHelloDirectory = - (if (args.isNotEmpty()) Paths.get(args.first()) else Paths.get(rootDirectoryPath, "test_project", "gohello")) + (if (args.isNotEmpty()) Paths.get(args.first()) else Paths.get(rootDirectoryPathString, "test_project", "gohello")) .toString() private val goHelloBinDirectoryPath = Paths.get(goHelloDirectory, "bin") diff --git a/flank-bash/scripts/updateFlank.main.kts b/flank-bash/scripts/updateFlank.main.kts index 2d527b027b..484f8d17e5 100644 --- a/flank-bash/scripts/updateFlank.main.kts +++ b/flank-bash/scripts/updateFlank.main.kts @@ -12,15 +12,12 @@ import eu.jrie.jetbrains.kotlinshell.shell.* import java.nio.file.Path import java.nio.file.Paths -val gradleCommand = createGradleCommand( - workingDir = rootDirectoryPath, - options = listOf(":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar") -) - -val flankDirectory: Path = Paths.get(rootDirectoryPath, "test_runner") +val flankDirectory: Path = Paths.get(rootDirectoryPathString, "test_runner") shell { - gradleCommand() + shell(dir = rootDirectoryFile) { + createGradleCommand(":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar")() + } } Paths.get(flankDirectory.toString(), "build", "libs", "flank.jar").toFile() diff --git a/flank-bash/scripts/util/GradleCommand.kt b/flank-bash/scripts/util/GradleCommand.kt index 3ebd010c0a..12a645c8de 100644 --- a/flank-bash/scripts/util/GradleCommand.kt +++ b/flank-bash/scripts/util/GradleCommand.kt @@ -1,11 +1,14 @@ import java.nio.file.Paths fun createGradleCommand( - workingDir: String, + vararg options: String +) = createGradleCommand(options.asList()) + +fun createGradleCommand( options: List -) = "${Paths.get(workingDir, gradleExecutable).toString()} ${options.joinToString(" ")}" +) = "$gradleExecutable ${options.joinToString(" ")}" private val gradleExecutable: String - get() = if(isWindows) "gradlew.bat" else "gradlew" + get() = if (isWindows) "gradlew.bat" else "./gradlew" val isWindows = System.getProperty("os.name").startsWith("Windows") diff --git a/flank-bash/scripts/util/PathHelper.kt b/flank-bash/scripts/util/PathHelper.kt index bfc6ba5eb6..458e3f3983 100644 --- a/flank-bash/scripts/util/PathHelper.kt +++ b/flank-bash/scripts/util/PathHelper.kt @@ -1,15 +1,19 @@ +import java.nio.file.Files import java.nio.file.Paths - -val rootDirectoryPath = Paths - .get("") - .toAbsolutePath() - .parent - .toString() +import java.nio.file.Path val currentPath = Paths.get("") +val rootDirectoryPath = goToRoot(currentPath) +val rootDirectoryFile = rootDirectoryPath.toFile() +val rootDirectoryPathString = rootDirectoryPath.toString() + +fun goToRoot(startPath: Path): Path = + if (startPath.isRoot()) startPath else goToRoot(startPath.toAbsolutePath().parent) + +fun Path.isRoot() = Files.exists(Paths.get(toString(), "settings.gradle.kts")) -val testProjectsPath = Paths.get(rootDirectoryPath, "test_projects").toString() +val testProjectsPath = Paths.get(rootDirectoryPathString, "test_projects").toString() val androidTestProjectsPath = Paths.get(testProjectsPath, "android").toString() val iOSTestProjectsPath = Paths.get(testProjectsPath, "ios").toString() val flankFixturesTmpPath = - Paths.get(rootDirectoryPath, "test_runner", "src", "test", "kotlin", "ftl", "fixtures", "tmp").toString() + Paths.get(rootDirectoryPathString, "test_runner", "src", "test", "kotlin", "ftl", "fixtures", "tmp").toString() From 801163f7c0734b79058a132b628414178e3798ec Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 14 Oct 2020 17:32:53 +0200 Subject: [PATCH 38/95] Update buildGo.main.kts --- flank-bash/scripts/buildGo.main.kts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/flank-bash/scripts/buildGo.main.kts b/flank-bash/scripts/buildGo.main.kts index 1aa991a351..96067203c8 100644 --- a/flank-bash/scripts/buildGo.main.kts +++ b/flank-bash/scripts/buildGo.main.kts @@ -8,8 +8,10 @@ @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) +import eu.jrie.jetbrains.kotlinshell.processes.process.ProcessSendChannel import java.nio.file.Paths import eu.jrie.jetbrains.kotlinshell.shell.* +import java.io.File enum class GoOS( val goName: String, @@ -21,23 +23,25 @@ enum class GoOS( WINDOWS("windows", "bin/win", ".exe"), } -private val goHelloDirectory = - (if (args.isNotEmpty()) Paths.get(args.first()) else Paths.get(rootDirectoryPathString, "test_project", "gohello")) +val goHelloDirectory = + (if (args.isNotEmpty()) Paths.get(args.first()) else Paths.get(rootDirectoryPath, "test_projects", "gohello")) .toString() private val goHelloBinDirectoryPath = Paths.get(goHelloDirectory, "bin") -fun createExecutable(os: GoOS) { +suspend fun createExecutable(os: GoOS) { Paths.get(goHelloBinDirectoryPath.toString(), *os.directory.split('/').toTypedArray()) .toFile() .mkdirs() - shell { - "GOOS=${os.goName}"() - "GOARCH=amd64"() - "go build -o ./${os.directory}/gohello${os.extension}"() + + shell(dir = Paths.get(rootDirectoryPath, "test_projects", "gohello").toFile()) { + export("GOOS" to os.goName) + export("GOARCH" to "amd64") + "go build -o $flankFixturesTmpPath/gohello/${os.directory}/gohello${os.extension}"() } + } -fun generateGoArtifacts() { +suspend fun generateGoArtifacts() { goHelloBinDirectoryPath.toFile().deleteRecursively() GoOS.values().forEach { createExecutable(it) } } From 3737a4a59335ca5bea0f20ce0e3cd8057910e2f9 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 14 Oct 2020 17:54:17 +0200 Subject: [PATCH 39/95] Update buildGo.main.kts --- flank-bash/scripts/buildGo.main.kts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/flank-bash/scripts/buildGo.main.kts b/flank-bash/scripts/buildGo.main.kts index 96067203c8..7b1a9dcdc9 100644 --- a/flank-bash/scripts/buildGo.main.kts +++ b/flank-bash/scripts/buildGo.main.kts @@ -8,10 +8,8 @@ @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) -import eu.jrie.jetbrains.kotlinshell.processes.process.ProcessSendChannel import java.nio.file.Paths import eu.jrie.jetbrains.kotlinshell.shell.* -import java.io.File enum class GoOS( val goName: String, @@ -24,7 +22,7 @@ enum class GoOS( } val goHelloDirectory = - (if (args.isNotEmpty()) Paths.get(args.first()) else Paths.get(rootDirectoryPath, "test_projects", "gohello")) + (if (args.isNotEmpty()) Paths.get(args.first()) else Paths.get(testProjectsPath, "gohello")) .toString() private val goHelloBinDirectoryPath = Paths.get(goHelloDirectory, "bin") @@ -33,14 +31,15 @@ suspend fun createExecutable(os: GoOS) { .toFile() .mkdirs() - shell(dir = Paths.get(rootDirectoryPath, "test_projects", "gohello").toFile()) { + shell(dir = Paths.get(testProjectsPath, "gohello").toFile()) { export("GOOS" to os.goName) export("GOARCH" to "amd64") - "go build -o $flankFixturesTmpPath/gohello/${os.directory}/gohello${os.extension}"() + "go build -o ${createPathForBinary(os)}"() } - } +fun createPathForBinary(os: GoOS) = Paths.get(flankFixturesTmpPath, "gohello", os.directory, "gohello${os.extension}") + suspend fun generateGoArtifacts() { goHelloBinDirectoryPath.toFile().deleteRecursively() GoOS.values().forEach { createExecutable(it) } From cde29b84cb5cb71d9c518f589115258e54f342ad Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Wed, 14 Oct 2020 17:57:45 +0200 Subject: [PATCH 40/95] add scripts for update flank and build flank scripts --- firebase_apis/generate_java_client.bat | 2 +- firebase_apis/update_api_json.bat | 2 +- flank-scripts/bash/buildFlankScripts.bat | 9 +-------- flank-scripts/bash/buildFlankScripts.sh | 9 +-------- test_runner/bash/update_flank.bat | 8 +------- test_runner/bash/update_flank.sh | 10 +--------- 6 files changed, 6 insertions(+), 34 deletions(-) diff --git a/firebase_apis/generate_java_client.bat b/firebase_apis/generate_java_client.bat index ac21832c2a..43a4f6c1f6 100755 --- a/firebase_apis/generate_java_client.bat +++ b/firebase_apis/generate_java_client.bat @@ -1 +1 @@ -kotlin ../flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts +kotlin ..\flank-bash\scripts\updateFirebaseApi\generateJavaClient.main.kts diff --git a/firebase_apis/update_api_json.bat b/firebase_apis/update_api_json.bat index 67721889e3..137f28f844 100755 --- a/firebase_apis/update_api_json.bat +++ b/firebase_apis/update_api_json.bat @@ -1 +1 @@ -kotlin ../flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts +kotlin ..\flank-bash\scripts\updateFirebaseApi\updateApiJson.main.kts diff --git a/flank-scripts/bash/buildFlankScripts.bat b/flank-scripts/bash/buildFlankScripts.bat index 7c701773a2..418fe685ff 100755 --- a/flank-scripts/bash/buildFlankScripts.bat +++ b/flank-scripts/bash/buildFlankScripts.bat @@ -1,8 +1 @@ -Rem REPLACE with #1246 -SET DIR=%~dp0 - -SET FLANK_SCRIPTS=%DIR%\.. -SET GRADLE_EXECUTABLE_PATH=%FLANK_SCRIPTS%\.. - -%GRADLE_EXECUTABLE_PATH%\gradlew.bat flank-scripts:clean flank-scripts:assemble flank-scripts:shadowJar -copy %FLANK_SCRIPTS%\build\libs\flankScripts.jar %DIR%\flankScripts.jar +kotlin ..\..\flank-bash\scripts\buildFlankScripts.main.kts diff --git a/flank-scripts/bash/buildFlankScripts.sh b/flank-scripts/bash/buildFlankScripts.sh index dcf74fa19f..5c2ac3080e 100755 --- a/flank-scripts/bash/buildFlankScripts.sh +++ b/flank-scripts/bash/buildFlankScripts.sh @@ -1,8 +1 @@ -#!/usr/bin/env bash - -DIR=`dirname "$BASH_SOURCE"` - -FLANK_SCRIPTS="$DIR/.." - -"$FLANK_SCRIPTS/../gradlew" :flank-scripts:clean :flank-scripts:assemble :flank-scripts:shadowJar -cp "$FLANK_SCRIPTS"/build/libs/flankScripts.jar "$DIR/flankScripts.jar" +kotlin ../../flank-bash/scripts/buildFlankScripts.main.kts diff --git a/test_runner/bash/update_flank.bat b/test_runner/bash/update_flank.bat index 6f4d73a8c5..418fe685ff 100644 --- a/test_runner/bash/update_flank.bat +++ b/test_runner/bash/update_flank.bat @@ -1,7 +1 @@ - -for %%F in (%filename%) do set dirname=%%~dpF -echo "%dirname%" -cd .. -cd .. -call gradlew.bat clean assemble shadowjar -cd test_runner\bash +kotlin ..\..\flank-bash\scripts\buildFlankScripts.main.kts diff --git a/test_runner/bash/update_flank.sh b/test_runner/bash/update_flank.sh index 471ab34ed6..5c2ac3080e 100755 --- a/test_runner/bash/update_flank.sh +++ b/test_runner/bash/update_flank.sh @@ -1,9 +1 @@ -#!/usr/bin/env bash - -DIR=`dirname "$BASH_SOURCE"` - -FLANK="$DIR/.." - -"$FLANK/../gradlew" -p "$FLANK" clean assemble shadowJar - -cp "$FLANK"/build/libs/flank.jar "$DIR/flank.jar" +kotlin ../../flank-bash/scripts/buildFlankScripts.main.kts From feb212544211f2ecd02701e8c94ff112188cf765 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 15 Oct 2020 12:01:53 +0200 Subject: [PATCH 41/95] refractor --- flank-bash/scripts/android.ops.main.kts | 24 ++++++++++--------- .../{buildGo.main.kts => go.ops.main.kts} | 2 -- flank-bash/scripts/ios.ops.main.kts | 2 +- flank-bash/scripts/ios/IosBuildCommand.kt | 7 ++++++ flank-bash/scripts/ios/buildExample.main.kts | 2 +- flank-bash/scripts/ios/buildFtl.main.kts | 10 +++----- .../scripts/ios/util/IosBuildCommand.kt | 7 ------ flank-bash/scripts/ops.main.kts | 2 +- 8 files changed, 26 insertions(+), 30 deletions(-) rename flank-bash/scripts/{buildGo.main.kts => go.ops.main.kts} (99%) create mode 100644 flank-bash/scripts/ios/IosBuildCommand.kt delete mode 100644 flank-bash/scripts/ios/util/IosBuildCommand.kt diff --git a/flank-bash/scripts/android.ops.main.kts b/flank-bash/scripts/android.ops.main.kts index 36fa14df63..28fde84395 100644 --- a/flank-bash/scripts/android.ops.main.kts +++ b/flank-bash/scripts/android.ops.main.kts @@ -14,25 +14,27 @@ import java.nio.file.Path import java.nio.file.StandardCopyOption suspend fun Shell.generateApkAndTests() { - baseAppApk() - baseTesApks() - duplicatedNamesApks() - multiModulesApks() - cucumberSampleApp() + buildBaseApp() + buildBaseTestApk() + buildDuplicatedNamesApks() + buildMultiModulesApks() + buildCucumberSampleApp() } -suspend fun Shell.baseAppApk() { +suspend fun Shell.buildBaseApp() { shell(dir = rootDirectoryFile) { createGradleCommand("app:assemble")() } + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "app-debug.apk") + if (!outputDir.parent.toFile().exists()) Files.createDirectories(outputDir.parent) + val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "singleSuccess", "debug", "app-single-success-debug.apk") Files.copy(assembleDirectory, outputDir, StandardCopyOption.REPLACE_EXISTING) - } -suspend fun Shell.baseTesApks() { +suspend fun Shell.buildBaseTestApk() { shell(dir = rootDirectoryFile) { createGradleCommand("app:assembleAndroidTest")() } @@ -42,7 +44,7 @@ suspend fun Shell.baseTesApks() { } } -suspend fun Shell.duplicatedNamesApks() { +suspend fun Shell.buildDuplicatedNamesApks() { val modules = (0..3).map { "dir$it" } shell(dir = rootDirectoryFile) { createGradleCommand(modules.map { "$it:testModule:assembleAndroidTest" })() @@ -62,7 +64,7 @@ fun File.copyApkToDirectory(output: Path) = toPath().let { sourceFile -> Files.copy(sourceFile, output, StandardCopyOption.REPLACE_EXISTING) } -suspend fun Shell.multiModulesApks() { +suspend fun Shell.buildMultiModulesApks() { shell(dir = rootDirectoryFile) { createGradleCommand(listOf(":multi-modules:multiapp:assemble") + (1..20).map { ":multi-modules:testModule$it:assembleAndroidTest" })() } @@ -71,7 +73,7 @@ suspend fun Shell.multiModulesApks() { .forEach { it.copyApkToDirectory(Paths.get(outputDir, it.name)) } } -suspend fun Shell.cucumberSampleApp() { +suspend fun Shell.buildCucumberSampleApp() { shell(dir = rootDirectoryFile) { createGradleCommand("cucumber_sample_app:cukeulator:assembleDebug", ":cucumber_sample_app:cukeulator:assembleAndroidTest")() } diff --git a/flank-bash/scripts/buildGo.main.kts b/flank-bash/scripts/go.ops.main.kts similarity index 99% rename from flank-bash/scripts/buildGo.main.kts rename to flank-bash/scripts/go.ops.main.kts index 7b1a9dcdc9..44121a0ace 100644 --- a/flank-bash/scripts/buildGo.main.kts +++ b/flank-bash/scripts/go.ops.main.kts @@ -44,5 +44,3 @@ suspend fun generateGoArtifacts() { goHelloBinDirectoryPath.toFile().deleteRecursively() GoOS.values().forEach { createExecutable(it) } } - - diff --git a/flank-bash/scripts/ios.ops.main.kts b/flank-bash/scripts/ios.ops.main.kts index 9ff847e65f..e10a3d05ce 100644 --- a/flank-bash/scripts/ios.ops.main.kts +++ b/flank-bash/scripts/ios.ops.main.kts @@ -3,7 +3,7 @@ @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") @file:Import("util/GradleCommand.kt") @file:Import("util/PathHelper.kt") -@file:Import("ios/util/IosBuildCommand.kt") +@file:Import("ios/IosBuildCommand.kt") @file:Import("util/downloadSoftware.main.kts") @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) diff --git a/flank-bash/scripts/ios/IosBuildCommand.kt b/flank-bash/scripts/ios/IosBuildCommand.kt new file mode 100644 index 0000000000..38d8d297b2 --- /dev/null +++ b/flank-bash/scripts/ios/IosBuildCommand.kt @@ -0,0 +1,7 @@ +fun createIosBuildCommand(buildDir: String, workspace: String, scheme: String) = + "xcodebuild build-for-testing" + + " -allowProvisioningUpdates" + + " -workspace $workspace" + + " -scheme $scheme" + + " -derivedDataPath $buildDir" + + " -sdk iphoneos" diff --git a/flank-bash/scripts/ios/buildExample.main.kts b/flank-bash/scripts/ios/buildExample.main.kts index 89a5b3c8fa..41e073ff23 100644 --- a/flank-bash/scripts/ios/buildExample.main.kts +++ b/flank-bash/scripts/ios/buildExample.main.kts @@ -9,7 +9,7 @@ @file:Import("../util/archive.main.kts") @file:Import("../util/downloadSoftware.main.kts") @file:Import("../util/PathHelper.kt") -@file:Import("util/IosBuildCommand.kt") +@file:Import("IosBuildCommand.kt") import eu.jrie.jetbrains.kotlinshell.shell.shell import java.nio.file.Files diff --git a/flank-bash/scripts/ios/buildFtl.main.kts b/flank-bash/scripts/ios/buildFtl.main.kts index c2aa530fcb..d32e7169b9 100644 --- a/flank-bash/scripts/ios/buildFtl.main.kts +++ b/flank-bash/scripts/ios/buildFtl.main.kts @@ -8,6 +8,7 @@ @file:Import("../util/downloadSoftware.main.kts") @file:Import("../util/archive.main.kts") @file:Import("../util/PathHelper.kt") +@file:Import("IosBuildCommand.kt") import eu.jrie.jetbrains.kotlinshell.shell.shell import java.nio.file.Files @@ -24,18 +25,13 @@ val buildProductPath = Paths.get(dataPath.toString(), "Build", "Products") downloadXcPrettyIfNeeded() shell { - val xcodeCommand = "xcodebuild build-for-testing" + - " -allowProvisioningUpdates" + - " -workspace ./EarlGreyExample.xcworkspace" + - " -scheme \"EarlGreyExampleSwiftTests\"" + - " -derivedDataPath $dataPath" + - " -sdk iphoneos".process() + val xcodeCommand = createIosBuildCommand(dataPath, "./EarlGreyExample.xcworkspace", "\"EarlGreyExampleSwiftTests\"").process() val xcPrettyCommand = "xcpretty".process() pipeline { xcodeCommand pipe xcPrettyCommand } Files.walk(Paths.get("")) - .filter { it.fileName.toString().endsWith("-iphoneos") || it.fileName.toString().endsWith(".xctestrun") } + .filter { it.fileName.toString().endsWith("-iphoneos") || it.fileName.toString().endsWith(".xctestrun") } .map { it.toFile() } .collect(Collectors.toList()) .archive(archiveFileName, currentPath.toFile()) diff --git a/flank-bash/scripts/ios/util/IosBuildCommand.kt b/flank-bash/scripts/ios/util/IosBuildCommand.kt deleted file mode 100644 index 42b72f61a2..0000000000 --- a/flank-bash/scripts/ios/util/IosBuildCommand.kt +++ /dev/null @@ -1,7 +0,0 @@ -fun createIosBuildCommand(buildDir: String, workspace: String, scheme: String) = - "xcodebuild build-for-testing " + - "-allowProvisioningUpdates " + - "-workspace $workspace " + - "-scheme $scheme " + - "-derivedDataPath $buildDir " + - "-sdk iphoneos" diff --git a/flank-bash/scripts/ops.main.kts b/flank-bash/scripts/ops.main.kts index 05aaacf73f..21c6201265 100644 --- a/flank-bash/scripts/ops.main.kts +++ b/flank-bash/scripts/ops.main.kts @@ -3,7 +3,7 @@ @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") @file:Import("android.ops.main.kts") @file:Import("ios.ops.main.kts") -@file:Import("buildGo.main.kts") +@file:Import("go.ops.main.kts") @file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) From 4f32ae53da24a68e7f74059d2cb580f56d3445af Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Thu, 15 Oct 2020 14:59:28 +0200 Subject: [PATCH 42/95] added scripts for go --- test_projects/gohello/build.bat | 1 + test_projects/gohello/build.sh | 11 +---------- 2 files changed, 2 insertions(+), 10 deletions(-) create mode 100644 test_projects/gohello/build.bat diff --git a/test_projects/gohello/build.bat b/test_projects/gohello/build.bat new file mode 100644 index 0000000000..424b6eb6e3 --- /dev/null +++ b/test_projects/gohello/build.bat @@ -0,0 +1 @@ + kotlin ..\..\flank-bash\scripts\go.ops.main.kts diff --git a/test_projects/gohello/build.sh b/test_projects/gohello/build.sh index a7e383a006..90e1e00517 100755 --- a/test_projects/gohello/build.sh +++ b/test_projects/gohello/build.sh @@ -1,10 +1 @@ -#!/bin/bash - -rm -rf "./bin/" -mkdir -p bin/win -mkdir -p bin/linux -mkdir -p bin/mac - -GOOS=windows GOARCH=amd64 go build -o ./bin/win/gohello.exe -GOOS=linux GOARCH=amd64 go build -o ./bin/linux/gohello -GOOS=darwin GOARCH=amd64 go build -o ./bin/mac/gohello +kotlin ../../flank-bash/scripts/go.ops.main.kts From 38972fb0847cd8a4ed45a1420002751cd94c9256 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Thu, 15 Oct 2020 15:57:36 +0200 Subject: [PATCH 43/95] added directory to scripts --- firebase_apis/generate_java_client.bat | 3 +- firebase_apis/generate_java_client.sh | 3 +- firebase_apis/update_api_json.bat | 3 +- firebase_apis/update_api_json.sh | 3 +- flank-bash/scripts/buildFlankScripts.main.kts | 1 + flank-bash/scripts/ios/buildFtl.main.kts | 2 +- flank-bash/scripts/util/PathHelper.kt | 2 +- flank-scripts/bash/buildFlankScripts.bat | 3 +- flank-scripts/bash/buildFlankScripts.sh | 4 ++- test_projects/gohello/build.bat | 3 +- test_projects/gohello/build.sh | 3 +- .../ios/EarlGreyExample/build_example.sh | 35 ++----------------- .../ios/EarlGreyExample/build_ftl.sh | 28 ++------------- .../ios/EarlGreyExample/run_ftl_local.sh | 17 ++------- test_runner/bash/update_flank.bat | 3 +- test_runner/bash/update_flank.sh | 4 ++- 16 files changed, 31 insertions(+), 86 deletions(-) diff --git a/firebase_apis/generate_java_client.bat b/firebase_apis/generate_java_client.bat index 43a4f6c1f6..a2c7bd40b2 100755 --- a/firebase_apis/generate_java_client.bat +++ b/firebase_apis/generate_java_client.bat @@ -1 +1,2 @@ -kotlin ..\flank-bash\scripts\updateFirebaseApi\generateJavaClient.main.kts +SET DIR=%~dp0 +kotlin $DIR\..\flank-bash\scripts\updateFirebaseApi\generateJavaClient.main.kts diff --git a/firebase_apis/generate_java_client.sh b/firebase_apis/generate_java_client.sh index ac21832c2a..298797b1e2 100755 --- a/firebase_apis/generate_java_client.sh +++ b/firebase_apis/generate_java_client.sh @@ -1 +1,2 @@ -kotlin ../flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts +DIR=`dirname "$BASH_SOURCE"` +kotlin $DIR/../flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts diff --git a/firebase_apis/update_api_json.bat b/firebase_apis/update_api_json.bat index 137f28f844..08f382005b 100755 --- a/firebase_apis/update_api_json.bat +++ b/firebase_apis/update_api_json.bat @@ -1 +1,2 @@ -kotlin ..\flank-bash\scripts\updateFirebaseApi\updateApiJson.main.kts +SET DIR=%~dp0 +kotlin $DIR\..\flank-bash\scripts\updateFirebaseApi\updateApiJson.main.kts diff --git a/firebase_apis/update_api_json.sh b/firebase_apis/update_api_json.sh index 67721889e3..a034be4e70 100755 --- a/firebase_apis/update_api_json.sh +++ b/firebase_apis/update_api_json.sh @@ -1 +1,2 @@ -kotlin ../flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts +DIR=`dirname "$BASH_SOURCE"` +kotlin $DIR/../flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts diff --git a/flank-bash/scripts/buildFlankScripts.main.kts b/flank-bash/scripts/buildFlankScripts.main.kts index fa8052b39a..d2341be307 100644 --- a/flank-bash/scripts/buildFlankScripts.main.kts +++ b/flank-bash/scripts/buildFlankScripts.main.kts @@ -12,6 +12,7 @@ import java.nio.file.Paths val flankScriptsDirectory: Path = Paths.get(rootDirectoryPathString, "flank-scripts") +println("XXX") shell { shell(dir = rootDirectoryFile) { createGradleCommand(":flank-scripts:clean", ":flank-scripts:assemble", ":flank-scripts:shadowJar")() diff --git a/flank-bash/scripts/ios/buildFtl.main.kts b/flank-bash/scripts/ios/buildFtl.main.kts index d32e7169b9..4c9fc48f77 100644 --- a/flank-bash/scripts/ios/buildFtl.main.kts +++ b/flank-bash/scripts/ios/buildFtl.main.kts @@ -25,7 +25,7 @@ val buildProductPath = Paths.get(dataPath.toString(), "Build", "Products") downloadXcPrettyIfNeeded() shell { - val xcodeCommand = createIosBuildCommand(dataPath, "./EarlGreyExample.xcworkspace", "\"EarlGreyExampleSwiftTests\"").process() + val xcodeCommand = createIosBuildCommand(dataPath.toString(), "./EarlGreyExample.xcworkspace", "\"EarlGreyExampleSwiftTests\"").process() val xcPrettyCommand = "xcpretty".process() pipeline { xcodeCommand pipe xcPrettyCommand } diff --git a/flank-bash/scripts/util/PathHelper.kt b/flank-bash/scripts/util/PathHelper.kt index 458e3f3983..a39a049d07 100644 --- a/flank-bash/scripts/util/PathHelper.kt +++ b/flank-bash/scripts/util/PathHelper.kt @@ -8,7 +8,7 @@ val rootDirectoryFile = rootDirectoryPath.toFile() val rootDirectoryPathString = rootDirectoryPath.toString() fun goToRoot(startPath: Path): Path = - if (startPath.isRoot()) startPath else goToRoot(startPath.toAbsolutePath().parent) + if (startPath.isRoot()) startPath.toAbsolutePath() else goToRoot(startPath.toAbsolutePath().parent) fun Path.isRoot() = Files.exists(Paths.get(toString(), "settings.gradle.kts")) diff --git a/flank-scripts/bash/buildFlankScripts.bat b/flank-scripts/bash/buildFlankScripts.bat index 418fe685ff..32f940dc7c 100755 --- a/flank-scripts/bash/buildFlankScripts.bat +++ b/flank-scripts/bash/buildFlankScripts.bat @@ -1 +1,2 @@ -kotlin ..\..\flank-bash\scripts\buildFlankScripts.main.kts +SET DIR=%~dp0 +kotlin $DIR\..\..\flank-bash\scripts\buildFlankScripts.main.kts diff --git a/flank-scripts/bash/buildFlankScripts.sh b/flank-scripts/bash/buildFlankScripts.sh index 5c2ac3080e..03e5a4ede5 100755 --- a/flank-scripts/bash/buildFlankScripts.sh +++ b/flank-scripts/bash/buildFlankScripts.sh @@ -1 +1,3 @@ -kotlin ../../flank-bash/scripts/buildFlankScripts.main.kts + +DIR=`dirname "$BASH_SOURCE"` +kotlin $DIR/../../flank-bash/scripts/buildFlankScripts.main.kts diff --git a/test_projects/gohello/build.bat b/test_projects/gohello/build.bat index 424b6eb6e3..a3c5d89c04 100644 --- a/test_projects/gohello/build.bat +++ b/test_projects/gohello/build.bat @@ -1 +1,2 @@ - kotlin ..\..\flank-bash\scripts\go.ops.main.kts +SET DIR=%~dp0 +kotlin $DIR\..\..\flank-bash\scripts\go.ops.main.kts diff --git a/test_projects/gohello/build.sh b/test_projects/gohello/build.sh index 90e1e00517..6e9e8709e1 100755 --- a/test_projects/gohello/build.sh +++ b/test_projects/gohello/build.sh @@ -1 +1,2 @@ -kotlin ../../flank-bash/scripts/go.ops.main.kts +DIR=`dirname "$BASH_SOURCE"` +kotlin $DIR/../../flank-bash/scripts/go.ops.main.kts diff --git a/test_projects/ios/EarlGreyExample/build_example.sh b/test_projects/ios/EarlGreyExample/build_example.sh index df03cd26e0..7626b91dc2 100755 --- a/test_projects/ios/EarlGreyExample/build_example.sh +++ b/test_projects/ios/EarlGreyExample/build_example.sh @@ -1,33 +1,2 @@ -#!/bin/bash - -set -euxo pipefail - -if ! [ -x "$(command -v xcpretty)" ]; then - gem install xcpretty -fi - -DD="dd_tmp" -ZIP="earlgrey_example.zip" - -rm -rf "$DD" - -xcodebuild build-for-testing \ - -allowProvisioningUpdates \ - -workspace ./EarlGreyExample.xcworkspace \ - -scheme "EarlGreyExampleSwiftTests" \ - -derivedDataPath "$DD" \ - -sdk iphoneos \ - | xcpretty - -xcodebuild build-for-testing \ - -allowProvisioningUpdates \ - -workspace ./EarlGreyExample.xcworkspace \ - -scheme "EarlGreyExampleTests" \ - -derivedDataPath "$DD" \ - -sdk iphoneos \ - | xcpretty - -pushd "$DD/Build/Products" -zip -r "$ZIP" *-iphoneos *.xctestrun -popd -mv "$DD/Build/Products/$ZIP" . +DIR=`dirname "$BASH_SOURCE"` +kotlin $DIR/../../../flank-bash/scripts/ios/buildExample.main.kts diff --git a/test_projects/ios/EarlGreyExample/build_ftl.sh b/test_projects/ios/EarlGreyExample/build_ftl.sh index 36c2dd7a32..40cb3ab2aa 100755 --- a/test_projects/ios/EarlGreyExample/build_ftl.sh +++ b/test_projects/ios/EarlGreyExample/build_ftl.sh @@ -1,26 +1,2 @@ -#!/bin/bash - -set -euxo pipefail - -if ! [ -x "$(command -v xcpretty)" ]; then - gem install xcpretty -fi - -DD="dd_tmp" -SCHEME="EarlGreyExampleSwiftTests" -ZIP="ios_earlgrey2.zip" - -rm -rf "$DD" - -xcodebuild build-for-testing \ - -allowProvisioningUpdates \ - -workspace ./EarlGreyExample.xcworkspace \ - -scheme "$SCHEME" \ - -derivedDataPath "$DD" \ - -sdk iphoneos \ - | xcpretty - -pushd "$DD/Build/Products" -zip -r "$ZIP" *-iphoneos *.xctestrun -popd -mv "$DD/Build/Products/$ZIP" . +DIR=`dirname "$BASH_SOURCE"` +kotlin $DIR/../../../flank-bash/scripts/ios/buildFtl.main.kts diff --git a/test_projects/ios/EarlGreyExample/run_ftl_local.sh b/test_projects/ios/EarlGreyExample/run_ftl_local.sh index 600117bfb9..768b6f8edb 100755 --- a/test_projects/ios/EarlGreyExample/run_ftl_local.sh +++ b/test_projects/ios/EarlGreyExample/run_ftl_local.sh @@ -1,15 +1,2 @@ -#!/bin/bash - -set -euxo pipefail - -DD="dd_tmp" -SCHEME="appUITests" -ZIP="ios_earlgrey2.zip" - -# Firebase test lab runs using -xctestrun -xcodebuild test-without-building \ - -xctestrun $DD/Build/Products/*.xctestrun \ - -derivedDataPath "$DD" \ - -destination 'id=ADD_YOUR_ID_HERE' - -# get device identifier in Xcode -> Window -> Devices and Simulators +DIR=`dirname "$BASH_SOURCE"` +kotlin $DIR/../../../flank-bash/scripts/ios/runFtlLocal.main.kts diff --git a/test_runner/bash/update_flank.bat b/test_runner/bash/update_flank.bat index 418fe685ff..32f940dc7c 100644 --- a/test_runner/bash/update_flank.bat +++ b/test_runner/bash/update_flank.bat @@ -1 +1,2 @@ -kotlin ..\..\flank-bash\scripts\buildFlankScripts.main.kts +SET DIR=%~dp0 +kotlin $DIR\..\..\flank-bash\scripts\buildFlankScripts.main.kts diff --git a/test_runner/bash/update_flank.sh b/test_runner/bash/update_flank.sh index 5c2ac3080e..e24874b2ff 100755 --- a/test_runner/bash/update_flank.sh +++ b/test_runner/bash/update_flank.sh @@ -1 +1,3 @@ -kotlin ../../flank-bash/scripts/buildFlankScripts.main.kts + +DIR=`dirname "$BASH_SOURCE"` +kotlin $DIR/../../flank-bash/scripts/updateFlank.main.kts From b9fe9395af034a56ef38322daf77aa0fd6ebded3 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Thu, 15 Oct 2020 16:23:49 +0200 Subject: [PATCH 44/95] added script fo unversal framework --- .../EarlGreyExample/universal_framework.sh | 28 ++----------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/test_projects/ios/EarlGreyExample/universal_framework.sh b/test_projects/ios/EarlGreyExample/universal_framework.sh index f703753799..10cd25e27d 100755 --- a/test_projects/ios/EarlGreyExample/universal_framework.sh +++ b/test_projects/ios/EarlGreyExample/universal_framework.sh @@ -1,26 +1,2 @@ -#!/bin/bash - -set -euxo pipefail - -COMBO="./ios-frameworks" -DEVICE="$COMBO/Debug-iphoneos" -SIM="$COMBO/Debug-iphonesimulator" - -lipo -create $DEVICE/libChannelLib.a $SIM/libChannelLib.a -output $COMBO/libChannelLib.a -lipo -create $DEVICE/libCommonLib.a $SIM/libCommonLib.a -output $COMBO/libCommonLib.a -lipo -create $DEVICE/libeDistantObject.a $SIM/libeDistantObject.a -output $COMBO/libeDistantObject.a -lipo -create $DEVICE/libTestLib.a $SIM/libTestLib.a -output $COMBO/libTestLib.a -lipo -create $DEVICE/libUILib.a $SIM/libUILib.a -output $COMBO/libUILib.a - -cp -RL $DEVICE/AppFramework.framework $COMBO/AppFramework.framework -DEVICE_FRAMEWORK="$DEVICE/AppFramework.framework/AppFramework" -SIM_FRAMEWORK="$SIM/AppFramework.framework/AppFramework" -UNI_FRAMEWORK="$COMBO/AppFramework.framework/AppFramework" - -lipo -create \ - "$DEVICE_FRAMEWORK" \ - "$SIM_FRAMEWORK" \ - -output "$UNI_FRAMEWORK" - -dsymutil "$UNI_FRAMEWORK" \ - --out "$COMBO/AppFramework.framework.dSYM" +DIR=`dirname "$BASH_SOURCE"` +kotlin $DIR/../../../flank-bash/scripts/ios/universalFramework.main.kts From f268981fde9158a2da1de4e297b408634d564770 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Thu, 15 Oct 2020 17:22:19 +0200 Subject: [PATCH 45/95] clean up --- flank-bash/build.gradle.kts | 11 ----------- flank-bash/scripts/updateLibs/updateSwift.main.kts | 1 - flank-bash/scripts/util/downloadFiles.main.kts | 1 - settings.gradle.kts | 1 - 4 files changed, 14 deletions(-) delete mode 100644 flank-bash/build.gradle.kts diff --git a/flank-bash/build.gradle.kts b/flank-bash/build.gradle.kts deleted file mode 100644 index 57c4f2d185..0000000000 --- a/flank-bash/build.gradle.kts +++ /dev/null @@ -1,11 +0,0 @@ -plugins { - kotlin("jvm") -} - -dependencies { - implementation("org.jetbrains.kotlin:kotlin-scripting-common:${Versions.KOTLIN}") - implementation("org.jetbrains.kotlin:kotlin-scripting-jvm:${Versions.KOTLIN}") - implementation("org.jetbrains.kotlin:kotlin-scripting-jvm-host:${Versions.KOTLIN}") - implementation("org.jetbrains.kotlin:kotlin-scripting-dependencies:${Versions.KOTLIN}") - implementation("org.apache.ivy:ivy:2.5.0") -} diff --git a/flank-bash/scripts/updateLibs/updateSwift.main.kts b/flank-bash/scripts/updateLibs/updateSwift.main.kts index 08aa28f268..7f9ddb6b6d 100644 --- a/flank-bash/scripts/updateLibs/updateSwift.main.kts +++ b/flank-bash/scripts/updateLibs/updateSwift.main.kts @@ -6,7 +6,6 @@ import java.nio.file.Files import java.nio.file.Paths -import java.nio.file.StandardCopyOption private val currentPath = Paths.get("") private val swiftPath = Paths.get(currentPath.toString(), "swift") diff --git a/flank-bash/scripts/util/downloadFiles.main.kts b/flank-bash/scripts/util/downloadFiles.main.kts index de0ca1e7b1..e27d2ff6ba 100644 --- a/flank-bash/scripts/util/downloadFiles.main.kts +++ b/flank-bash/scripts/util/downloadFiles.main.kts @@ -22,4 +22,3 @@ fun downloadFile( } .response() } - diff --git a/settings.gradle.kts b/settings.gradle.kts index c0a5acaea3..1bf1e0bb4d 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -4,7 +4,6 @@ include( ":test_runner", ":firebase_apis:test_api", ":flank-scripts", - ":flank-bash", ":integration_tests", "samples:gradle-export-api", "test_projects:android" From eca5b7ff31eee4b3153f05a65d250aac3e4c33dd Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 15 Oct 2020 17:32:18 +0200 Subject: [PATCH 46/95] Gradle compability with windows --- flank-bash/scripts/android.ops.main.kts | 34 +++++++++++++------ flank-bash/scripts/buildFlankScripts.main.kts | 7 ++-- flank-bash/scripts/updateFlank.main.kts | 7 ++-- flank-bash/scripts/util/GradleCommand.kt | 6 ++-- 4 files changed, 36 insertions(+), 18 deletions(-) diff --git a/flank-bash/scripts/android.ops.main.kts b/flank-bash/scripts/android.ops.main.kts index 28fde84395..4a6c0d56ca 100644 --- a/flank-bash/scripts/android.ops.main.kts +++ b/flank-bash/scripts/android.ops.main.kts @@ -22,8 +22,11 @@ suspend fun Shell.generateApkAndTests() { } suspend fun Shell.buildBaseApp() { - shell(dir = rootDirectoryFile) { - createGradleCommand("app:assemble")() + shell { + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, "app:assemble") + )() } val outputDir = Paths.get(flankFixturesTmpPath, "apk", "app-debug.apk") @@ -35,8 +38,11 @@ suspend fun Shell.buildBaseApp() { } suspend fun Shell.buildBaseTestApk() { - shell(dir = rootDirectoryFile) { - createGradleCommand("app:assembleAndroidTest")() + shell { + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, "app:assembleAndroidTest") + )() } val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "androidTest") File(assembleDirectory.toString()).findApks().forEach { @@ -46,8 +52,11 @@ suspend fun Shell.buildBaseTestApk() { suspend fun Shell.buildDuplicatedNamesApks() { val modules = (0..3).map { "dir$it" } - shell(dir = rootDirectoryFile) { - createGradleCommand(modules.map { "$it:testModule:assembleAndroidTest" })() + shell { + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath) + modules.map { "$it:testModule:assembleAndroidTest" }.toList() + )() } val outputDir = Paths.get(flankFixturesTmpPath, "apk", "duplicated_names") if (!outputDir.toFile().exists()) Files.createDirectories(outputDir) @@ -65,8 +74,10 @@ fun File.copyApkToDirectory(output: Path) = toPath().let { sourceFile -> } suspend fun Shell.buildMultiModulesApks() { - shell(dir = rootDirectoryFile) { - createGradleCommand(listOf(":multi-modules:multiapp:assemble") + (1..20).map { ":multi-modules:testModule$it:assembleAndroidTest" })() + shell { + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf(":multi-modules:multiapp:assemble") + (1..20).map { ":multi-modules:testModule$it:assembleAndroidTest" })() } val outputDir = Paths.get(flankFixturesTmpPath, "apk", "multi-modules").toString() Paths.get(androidTestProjectsPath, "multi-modules").toFile().findApks() @@ -74,8 +85,11 @@ suspend fun Shell.buildMultiModulesApks() { } suspend fun Shell.buildCucumberSampleApp() { - shell(dir = rootDirectoryFile) { - createGradleCommand("cucumber_sample_app:cukeulator:assembleDebug", ":cucumber_sample_app:cukeulator:assembleAndroidTest")() + shell { + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("cucumber_sample_app:cukeulator:assembleDebug", ":cucumber_sample_app:cukeulator:assembleAndroidTest") + )() } val outputDir = Paths.get(flankFixturesTmpPath, "apk", "cucumber_sample_app").toString() Paths.get(androidTestProjectsPath, "cucumber_sample_app").toFile().findApks().copyApksToPath(outputDir) diff --git a/flank-bash/scripts/buildFlankScripts.main.kts b/flank-bash/scripts/buildFlankScripts.main.kts index d2341be307..a994a35569 100644 --- a/flank-bash/scripts/buildFlankScripts.main.kts +++ b/flank-bash/scripts/buildFlankScripts.main.kts @@ -12,10 +12,11 @@ import java.nio.file.Paths val flankScriptsDirectory: Path = Paths.get(rootDirectoryPathString, "flank-scripts") -println("XXX") shell { - shell(dir = rootDirectoryFile) { - createGradleCommand(":flank-scripts:clean", ":flank-scripts:assemble", ":flank-scripts:shadowJar")() + shell { + createGradleCommand( + workingDir = rootDirectoryPathString, + options = ":flank-scripts:clean", ":flank-scripts:assemble", ":flank-scripts:shadowJar")() } } diff --git a/flank-bash/scripts/updateFlank.main.kts b/flank-bash/scripts/updateFlank.main.kts index 484f8d17e5..0be026c6c5 100644 --- a/flank-bash/scripts/updateFlank.main.kts +++ b/flank-bash/scripts/updateFlank.main.kts @@ -15,9 +15,10 @@ import java.nio.file.Paths val flankDirectory: Path = Paths.get(rootDirectoryPathString, "test_runner") shell { - shell(dir = rootDirectoryFile) { - createGradleCommand(":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar")() - } + createGradleCommand( + workingDir = rootDirectoryPathString, + options = ":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar")() + } Paths.get(flankDirectory.toString(), "build", "libs", "flank.jar").toFile() diff --git a/flank-bash/scripts/util/GradleCommand.kt b/flank-bash/scripts/util/GradleCommand.kt index 12a645c8de..c924ee8bdb 100644 --- a/flank-bash/scripts/util/GradleCommand.kt +++ b/flank-bash/scripts/util/GradleCommand.kt @@ -1,12 +1,14 @@ import java.nio.file.Paths fun createGradleCommand( + workingDir: String, vararg options: String -) = createGradleCommand(options.asList()) +) = createGradleCommand(workingDir, options.asList()) fun createGradleCommand( + workingDir: String, options: List -) = "$gradleExecutable ${options.joinToString(" ")}" +) = "${Paths.get(workingDir, gradleExecutable).toString()} ${options.joinToString(" ")}" private val gradleExecutable: String get() = if (isWindows) "gradlew.bat" else "./gradlew" From b4b68cd75ef5830999640c10dbe4abbc87757543 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Thu, 15 Oct 2020 17:38:37 +0200 Subject: [PATCH 47/95] fix execution --- flank-bash/scripts/buildFlankScripts.main.kts | 9 ++++----- flank-bash/scripts/updateFlank.main.kts | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/flank-bash/scripts/buildFlankScripts.main.kts b/flank-bash/scripts/buildFlankScripts.main.kts index a994a35569..3964d5319c 100644 --- a/flank-bash/scripts/buildFlankScripts.main.kts +++ b/flank-bash/scripts/buildFlankScripts.main.kts @@ -13,11 +13,10 @@ import java.nio.file.Paths val flankScriptsDirectory: Path = Paths.get(rootDirectoryPathString, "flank-scripts") shell { - shell { - createGradleCommand( - workingDir = rootDirectoryPathString, - options = ":flank-scripts:clean", ":flank-scripts:assemble", ":flank-scripts:shadowJar")() - } + createGradleCommand( + workingDir = rootDirectoryPathString, + ":flank-scripts:clean", ":flank-scripts:assemble", ":flank-scripts:shadowJar" + )() } Paths.get(flankScriptsDirectory.toString(), "build", "libs", "flankScripts.jar").toFile() diff --git a/flank-bash/scripts/updateFlank.main.kts b/flank-bash/scripts/updateFlank.main.kts index 0be026c6c5..a97d23bb9e 100644 --- a/flank-bash/scripts/updateFlank.main.kts +++ b/flank-bash/scripts/updateFlank.main.kts @@ -17,7 +17,7 @@ val flankDirectory: Path = Paths.get(rootDirectoryPathString, "test_runner") shell { createGradleCommand( workingDir = rootDirectoryPathString, - options = ":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar")() + ":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar")() } From 88ad0b729935c0ecb4c336184b775e67e72c9d1e Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 15 Oct 2020 17:37:17 +0200 Subject: [PATCH 48/95] Update android script --- flank-bash/scripts/android.ops.main.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flank-bash/scripts/android.ops.main.kts b/flank-bash/scripts/android.ops.main.kts index 4a6c0d56ca..7f1caa05aa 100644 --- a/flank-bash/scripts/android.ops.main.kts +++ b/flank-bash/scripts/android.ops.main.kts @@ -77,7 +77,7 @@ suspend fun Shell.buildMultiModulesApks() { shell { createGradleCommand( workingDir = androidTestProjectsPath, - options = listOf(":multi-modules:multiapp:assemble") + (1..20).map { ":multi-modules:testModule$it:assembleAndroidTest" })() + options = listOf("-p", androidTestProjectsPath, ":multi-modules:multiapp:assemble") + (1..20).map { ":multi-modules:testModule$it:assembleAndroidTest" })() } val outputDir = Paths.get(flankFixturesTmpPath, "apk", "multi-modules").toString() Paths.get(androidTestProjectsPath, "multi-modules").toFile().findApks() @@ -88,7 +88,7 @@ suspend fun Shell.buildCucumberSampleApp() { shell { createGradleCommand( workingDir = androidTestProjectsPath, - options = listOf("cucumber_sample_app:cukeulator:assembleDebug", ":cucumber_sample_app:cukeulator:assembleAndroidTest") + options = listOf("-p", androidTestProjectsPath, "cucumber_sample_app:cukeulator:assembleDebug", ":cucumber_sample_app:cukeulator:assembleAndroidTest") )() } val outputDir = Paths.get(flankFixturesTmpPath, "apk", "cucumber_sample_app").toString() From b5ff48fae942ad582c4330b5137b215e9c2203b5 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 15 Oct 2020 17:54:37 +0200 Subject: [PATCH 49/95] Update updateFlank.main.kts --- flank-bash/scripts/updateFlank.main.kts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/flank-bash/scripts/updateFlank.main.kts b/flank-bash/scripts/updateFlank.main.kts index a97d23bb9e..ebb339b4fb 100644 --- a/flank-bash/scripts/updateFlank.main.kts +++ b/flank-bash/scripts/updateFlank.main.kts @@ -17,8 +17,7 @@ val flankDirectory: Path = Paths.get(rootDirectoryPathString, "test_runner") shell { createGradleCommand( workingDir = rootDirectoryPathString, - ":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar")() - + "-p", rootDirectoryPathString, ":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar")() } Paths.get(flankDirectory.toString(), "build", "libs", "flank.jar").toFile() From d84990ba8ddcac76af21b0948bbb577d975f3473 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 15 Oct 2020 17:56:56 +0200 Subject: [PATCH 50/95] Windows compability for build/update flank --- flank-bash/scripts/buildFlankScripts.main.kts | 1 + flank-bash/scripts/updateFlank.main.kts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/flank-bash/scripts/buildFlankScripts.main.kts b/flank-bash/scripts/buildFlankScripts.main.kts index 3964d5319c..3b1a3f2a2d 100644 --- a/flank-bash/scripts/buildFlankScripts.main.kts +++ b/flank-bash/scripts/buildFlankScripts.main.kts @@ -15,6 +15,7 @@ val flankScriptsDirectory: Path = Paths.get(rootDirectoryPathString, "flank-scri shell { createGradleCommand( workingDir = rootDirectoryPathString, + "-p", rootDirectoryPathString, ":flank-scripts:clean", ":flank-scripts:assemble", ":flank-scripts:shadowJar" )() } diff --git a/flank-bash/scripts/updateFlank.main.kts b/flank-bash/scripts/updateFlank.main.kts index ebb339b4fb..da4c1d63f5 100644 --- a/flank-bash/scripts/updateFlank.main.kts +++ b/flank-bash/scripts/updateFlank.main.kts @@ -17,7 +17,8 @@ val flankDirectory: Path = Paths.get(rootDirectoryPathString, "test_runner") shell { createGradleCommand( workingDir = rootDirectoryPathString, - "-p", rootDirectoryPathString, ":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar")() + "-p", rootDirectoryPathString, + ":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar")() } Paths.get(flankDirectory.toString(), "build", "libs", "flank.jar").toFile() From 27a3fa58b3f5b3c8ad37e2e13773bb1deed7a8af Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 15 Oct 2020 17:58:57 +0200 Subject: [PATCH 51/95] Update formating --- flank-bash/scripts/buildFlankScripts.main.kts | 3 +-- flank-bash/scripts/updateFlank.main.kts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/flank-bash/scripts/buildFlankScripts.main.kts b/flank-bash/scripts/buildFlankScripts.main.kts index 3b1a3f2a2d..242e038af6 100644 --- a/flank-bash/scripts/buildFlankScripts.main.kts +++ b/flank-bash/scripts/buildFlankScripts.main.kts @@ -15,8 +15,7 @@ val flankScriptsDirectory: Path = Paths.get(rootDirectoryPathString, "flank-scri shell { createGradleCommand( workingDir = rootDirectoryPathString, - "-p", rootDirectoryPathString, - ":flank-scripts:clean", ":flank-scripts:assemble", ":flank-scripts:shadowJar" + "-p", rootDirectoryPathString, ":flank-scripts:clean", ":flank-scripts:assemble", ":flank-scripts:shadowJar" )() } diff --git a/flank-bash/scripts/updateFlank.main.kts b/flank-bash/scripts/updateFlank.main.kts index da4c1d63f5..ebb339b4fb 100644 --- a/flank-bash/scripts/updateFlank.main.kts +++ b/flank-bash/scripts/updateFlank.main.kts @@ -17,8 +17,7 @@ val flankDirectory: Path = Paths.get(rootDirectoryPathString, "test_runner") shell { createGradleCommand( workingDir = rootDirectoryPathString, - "-p", rootDirectoryPathString, - ":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar")() + "-p", rootDirectoryPathString, ":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar")() } Paths.get(flankDirectory.toString(), "build", "libs", "flank.jar").toFile() From 3b18d5cc6e07eac50784c3bded3d30d6ac3d087c Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Thu, 15 Oct 2020 18:33:18 +0200 Subject: [PATCH 52/95] fast fail on mac only scripts --- flank-bash/scripts/ios/buildExample.main.kts | 7 +++++++ flank-bash/scripts/ios/buildFtl.main.kts | 6 ++++++ flank-bash/scripts/ios/runFtlLocal.main.kts | 8 +++++++- flank-bash/scripts/ios/universalFramework.main.kts | 7 +++++++ flank-bash/scripts/updateLibs/updateLlvm.main.kts | 2 +- flank-bash/scripts/updateLibs/updateSwift.main.kts | 2 +- .../update.constants.kts => util/OsHelper.kts} | 0 7 files changed, 29 insertions(+), 3 deletions(-) rename flank-bash/scripts/{updateLibs/update.constants.kts => util/OsHelper.kts} (100%) diff --git a/flank-bash/scripts/ios/buildExample.main.kts b/flank-bash/scripts/ios/buildExample.main.kts index 41e073ff23..208f2a7be2 100644 --- a/flank-bash/scripts/ios/buildExample.main.kts +++ b/flank-bash/scripts/ios/buildExample.main.kts @@ -9,6 +9,7 @@ @file:Import("../util/archive.main.kts") @file:Import("../util/downloadSoftware.main.kts") @file:Import("../util/PathHelper.kt") +@file:Import("../util/OsHelper.kts") @file:Import("IosBuildCommand.kt") import eu.jrie.jetbrains.kotlinshell.shell.shell @@ -17,6 +18,12 @@ import java.nio.file.Path import java.nio.file.Paths import java.nio.file.StandardCopyOption import java.util.stream.Collectors +import kotlin.system.exitProcess + +if(isWindows) { + println("This script does not work on Windows") + exitProcess(1) +} val dataPath: Path = Paths.get(currentPath.toString(), "dd_tmp") dataPath.toFile().deleteRecursively() diff --git a/flank-bash/scripts/ios/buildFtl.main.kts b/flank-bash/scripts/ios/buildFtl.main.kts index 4c9fc48f77..59e482e2ab 100644 --- a/flank-bash/scripts/ios/buildFtl.main.kts +++ b/flank-bash/scripts/ios/buildFtl.main.kts @@ -16,6 +16,12 @@ import java.nio.file.Path import java.nio.file.Paths import java.nio.file.StandardCopyOption import java.util.stream.Collectors +import kotlin.system.exitProcess + +if(isWindows) { + println("This script does not work on Windows") + exitProcess(1) +} val currentPath = Paths.get("") val dataPath: Path = Paths.get("", "dd_tmp") diff --git a/flank-bash/scripts/ios/runFtlLocal.main.kts b/flank-bash/scripts/ios/runFtlLocal.main.kts index 837d92deb8..4ee76edea2 100644 --- a/flank-bash/scripts/ios/runFtlLocal.main.kts +++ b/flank-bash/scripts/ios/runFtlLocal.main.kts @@ -6,6 +6,7 @@ @file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) @file:Import("../util/PathHelper.kt") +@file:Import("../util/OsHelper.kts") import eu.jrie.jetbrains.kotlinshell.shell.shell import java.nio.file.Path @@ -17,7 +18,12 @@ val id = args.firstOrNull() ?: { exitProcess(1) } -val dataPath: Path = Paths.get(currentPath.toString(), "dd_tmp", "Build" , "Products") +if (isWindows) { + println("This script does not work on Windows") + exitProcess(1) +} + +val dataPath: Path = Paths.get(currentPath.toString(), "dd_tmp", "Build", "Products") val xcodeCommand = "xcodebuild test-without-building " + " -xctestrun $dataPath/*.xctestrun " + diff --git a/flank-bash/scripts/ios/universalFramework.main.kts b/flank-bash/scripts/ios/universalFramework.main.kts index d4b428238c..92bb9eb0f9 100644 --- a/flank-bash/scripts/ios/universalFramework.main.kts +++ b/flank-bash/scripts/ios/universalFramework.main.kts @@ -7,9 +7,16 @@ @file:Import("LipoHelper.kt") @file:Import("../util/PathHelper.kt") +@file:Import("../util/OsHelper.kts") import eu.jrie.jetbrains.kotlinshell.shell.shell import java.nio.file.Paths +import kotlin.system.exitProcess + +if (isWindows) { + println("This script does not work on Windows") + exitProcess(1) +} val comboPath = Paths.get(currentPath.toString(), "ios-frameworks").toString() val devicePath = Paths.get(comboPath, "Debug-iphoneos").toString() diff --git a/flank-bash/scripts/updateLibs/updateLlvm.main.kts b/flank-bash/scripts/updateLibs/updateLlvm.main.kts index 26e31c6be5..69a647ead8 100644 --- a/flank-bash/scripts/updateLibs/updateLlvm.main.kts +++ b/flank-bash/scripts/updateLibs/updateLlvm.main.kts @@ -2,7 +2,7 @@ @file:Import("../util/downloadFiles.main.kts") @file:Import("../util/archive.main.kts") -@file:Import("update.constants.kts") +@file:Import("../util/OsHelper.kts") import java.nio.file.Files import java.nio.file.Paths diff --git a/flank-bash/scripts/updateLibs/updateSwift.main.kts b/flank-bash/scripts/updateLibs/updateSwift.main.kts index 7f9ddb6b6d..6baee8afe3 100644 --- a/flank-bash/scripts/updateLibs/updateSwift.main.kts +++ b/flank-bash/scripts/updateLibs/updateSwift.main.kts @@ -2,7 +2,7 @@ @file:Import("../util/downloadFiles.main.kts") @file:Import("../util/archive.main.kts") -@file:Import("update.constants.kts") +@file:Import("../util/OsHelper.kts") import java.nio.file.Files import java.nio.file.Paths diff --git a/flank-bash/scripts/updateLibs/update.constants.kts b/flank-bash/scripts/util/OsHelper.kts similarity index 100% rename from flank-bash/scripts/updateLibs/update.constants.kts rename to flank-bash/scripts/util/OsHelper.kts From 8fd0d9c0f9a54d81387e5be781f0607859c75364 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Fri, 16 Oct 2020 13:13:23 +0200 Subject: [PATCH 53/95] Added section to web page --- mkdocs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/mkdocs.yml b/mkdocs.yml index ac2083f114..1567f63522 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -35,6 +35,7 @@ nav: - Dependencies update: dependencies_update_process.md - Secrets: flank_secrets.md - Releasing: release_process.md + - Kotlin scripts hints: development_kotlin_scripts.md theme: name: material From b447e8b6c5c495054fe26761e9414b8f202ad83f Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Fri, 16 Oct 2020 17:23:31 +0200 Subject: [PATCH 54/95] fix windows scripts --- firebase_apis/generate_java_client.bat | 2 +- firebase_apis/update_api_json.bat | 2 +- flank-scripts/bash/buildFlankScripts.bat | 2 +- test_projects/gohello/build.bat | 2 +- test_runner/bash/update_flank.bat | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/firebase_apis/generate_java_client.bat b/firebase_apis/generate_java_client.bat index a2c7bd40b2..2b1df39b91 100755 --- a/firebase_apis/generate_java_client.bat +++ b/firebase_apis/generate_java_client.bat @@ -1,2 +1,2 @@ SET DIR=%~dp0 -kotlin $DIR\..\flank-bash\scripts\updateFirebaseApi\generateJavaClient.main.kts +kotlin %DIR%\..\flank-bash\scripts\updateFirebaseApi\generateJavaClient.main.kts diff --git a/firebase_apis/update_api_json.bat b/firebase_apis/update_api_json.bat index 08f382005b..b06fb35ae5 100755 --- a/firebase_apis/update_api_json.bat +++ b/firebase_apis/update_api_json.bat @@ -1,2 +1,2 @@ SET DIR=%~dp0 -kotlin $DIR\..\flank-bash\scripts\updateFirebaseApi\updateApiJson.main.kts +kotlin %DIR%\..\flank-bash\scripts\updateFirebaseApi\updateApiJson.main.kts diff --git a/flank-scripts/bash/buildFlankScripts.bat b/flank-scripts/bash/buildFlankScripts.bat index 32f940dc7c..2971d19d61 100755 --- a/flank-scripts/bash/buildFlankScripts.bat +++ b/flank-scripts/bash/buildFlankScripts.bat @@ -1,2 +1,2 @@ SET DIR=%~dp0 -kotlin $DIR\..\..\flank-bash\scripts\buildFlankScripts.main.kts +kotlin %DIR%\..\..\flank-bash\scripts\buildFlankScripts.main.kts diff --git a/test_projects/gohello/build.bat b/test_projects/gohello/build.bat index a3c5d89c04..c5a390e38a 100644 --- a/test_projects/gohello/build.bat +++ b/test_projects/gohello/build.bat @@ -1,2 +1,2 @@ SET DIR=%~dp0 -kotlin $DIR\..\..\flank-bash\scripts\go.ops.main.kts +kotlin %DIR%\..\..\flank-bash\scripts\go.ops.main.kts diff --git a/test_runner/bash/update_flank.bat b/test_runner/bash/update_flank.bat index 32f940dc7c..2971d19d61 100644 --- a/test_runner/bash/update_flank.bat +++ b/test_runner/bash/update_flank.bat @@ -1,2 +1,2 @@ SET DIR=%~dp0 -kotlin $DIR\..\..\flank-bash\scripts\buildFlankScripts.main.kts +kotlin %DIR%\..\..\flank-bash\scripts\buildFlankScripts.main.kts From 9e0994ac5e49e9934d723b39ae2ef689864eeb5e Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 19 Oct 2020 15:24:17 +0200 Subject: [PATCH 55/95] Add build option for standalone run --- flank-bash/scripts/android.ops.main.kts | 4 ++++ flank-bash/scripts/go.ops.main.kts | 4 ++++ flank-bash/scripts/ios.ops.main.kts | 4 ++++ test_projects/gohello/build.bat | 2 +- test_projects/gohello/build.sh | 2 +- 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/flank-bash/scripts/android.ops.main.kts b/flank-bash/scripts/android.ops.main.kts index 7f1caa05aa..83dad78650 100644 --- a/flank-bash/scripts/android.ops.main.kts +++ b/flank-bash/scripts/android.ops.main.kts @@ -13,6 +13,10 @@ import eu.jrie.jetbrains.kotlinshell.shell.* import java.nio.file.Path import java.nio.file.StandardCopyOption +shell { + if(args.contains("build")) generateApkAndTests() +} + suspend fun Shell.generateApkAndTests() { buildBaseApp() buildBaseTestApk() diff --git a/flank-bash/scripts/go.ops.main.kts b/flank-bash/scripts/go.ops.main.kts index 44121a0ace..43bedc07a2 100644 --- a/flank-bash/scripts/go.ops.main.kts +++ b/flank-bash/scripts/go.ops.main.kts @@ -44,3 +44,7 @@ suspend fun generateGoArtifacts() { goHelloBinDirectoryPath.toFile().deleteRecursively() GoOS.values().forEach { createExecutable(it) } } + +shell { + if(args.contains("build")) generateGoArtifacts() +} diff --git a/flank-bash/scripts/ios.ops.main.kts b/flank-bash/scripts/ios.ops.main.kts index e10a3d05ce..316e563881 100644 --- a/flank-bash/scripts/ios.ops.main.kts +++ b/flank-bash/scripts/ios.ops.main.kts @@ -30,6 +30,10 @@ enum class TestType { OBJECTIVE_C } +shell { + if(args.contains("build")) generateIos() +} + suspend fun Shell.generateIos() = takeUnless { isWindows }?.let { downloadCocoaPodsIfNeeded() installPods(Paths.get(iOSTestProjectsPath, earlGreyExample)) diff --git a/test_projects/gohello/build.bat b/test_projects/gohello/build.bat index c5a390e38a..7d8fafe676 100644 --- a/test_projects/gohello/build.bat +++ b/test_projects/gohello/build.bat @@ -1,2 +1,2 @@ SET DIR=%~dp0 -kotlin %DIR%\..\..\flank-bash\scripts\go.ops.main.kts +kotlin %DIR%\..\..\flank-bash\scripts\go.ops.main.kts build diff --git a/test_projects/gohello/build.sh b/test_projects/gohello/build.sh index 6e9e8709e1..3c920dec5b 100755 --- a/test_projects/gohello/build.sh +++ b/test_projects/gohello/build.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../../flank-bash/scripts/go.ops.main.kts +kotlin $DIR/../../flank-bash/scripts/go.ops.main.kts build From 67f28b91a38c0780a0079ec6ab9dc0b166af7ca0 Mon Sep 17 00:00:00 2001 From: piotradamczyk5 <65554637+piotradamczyk5@users.noreply.github.com> Date: Mon, 19 Oct 2020 15:30:23 +0200 Subject: [PATCH 56/95] remove unused environment declaration --- flank-bash/scripts/go.ops.main.kts | 2 -- 1 file changed, 2 deletions(-) diff --git a/flank-bash/scripts/go.ops.main.kts b/flank-bash/scripts/go.ops.main.kts index 43bedc07a2..2934f07c6e 100644 --- a/flank-bash/scripts/go.ops.main.kts +++ b/flank-bash/scripts/go.ops.main.kts @@ -1,5 +1,3 @@ -#!/usr/bin/env kotlin - @file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") From 3eb7a881ed08c0e494d045fa7ab44f2173d6cb5f Mon Sep 17 00:00:00 2001 From: adamfilipow92 <64852261+adamfilipow92@users.noreply.github.com> Date: Mon, 19 Oct 2020 15:46:10 +0200 Subject: [PATCH 57/95] Update flank-bash/scripts/android.ops.main.kts Co-authored-by: piotradamczyk5 <65554637+piotradamczyk5@users.noreply.github.com> --- flank-bash/scripts/android.ops.main.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flank-bash/scripts/android.ops.main.kts b/flank-bash/scripts/android.ops.main.kts index 83dad78650..cabb6a9939 100644 --- a/flank-bash/scripts/android.ops.main.kts +++ b/flank-bash/scripts/android.ops.main.kts @@ -49,7 +49,7 @@ suspend fun Shell.buildBaseTestApk() { )() } val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "androidTest") - File(assembleDirectory.toString()).findApks().forEach { + assembleDirectory.toFile().findApks().forEach { Files.copy(it.toPath(), Paths.get(flankFixturesTmpPath, "apk", it.name), StandardCopyOption.REPLACE_EXISTING) } } From 7cca63fe198ef758772f8318a594ea23d4b0eb8f Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 19 Oct 2020 16:10:35 +0200 Subject: [PATCH 58/95] code formating --- flank-bash/scripts/android.ops.main.kts | 2 +- flank-bash/scripts/go.ops.main.kts | 2 +- flank-bash/scripts/ios.ops.main.kts | 3 ++- flank-bash/scripts/ios/LipoHelper.kt | 1 - flank-bash/scripts/ios/buildExample.main.kts | 9 ++++----- flank-bash/scripts/ios/buildFtl.main.kts | 2 +- flank-bash/scripts/ios/universalFramework.main.kts | 2 +- .../updateFirebaseApi/generateJavaClient.main.kts | 3 +-- flank-bash/scripts/util/OsHelper.kts | 6 +++--- flank-bash/scripts/util/downloadSoftware.main.kts | 4 ++-- 10 files changed, 16 insertions(+), 18 deletions(-) diff --git a/flank-bash/scripts/android.ops.main.kts b/flank-bash/scripts/android.ops.main.kts index cabb6a9939..2892b5e577 100644 --- a/flank-bash/scripts/android.ops.main.kts +++ b/flank-bash/scripts/android.ops.main.kts @@ -14,7 +14,7 @@ import java.nio.file.Path import java.nio.file.StandardCopyOption shell { - if(args.contains("build")) generateApkAndTests() + if (args.contains("build")) generateApkAndTests() } suspend fun Shell.generateApkAndTests() { diff --git a/flank-bash/scripts/go.ops.main.kts b/flank-bash/scripts/go.ops.main.kts index 2934f07c6e..90554c868d 100644 --- a/flank-bash/scripts/go.ops.main.kts +++ b/flank-bash/scripts/go.ops.main.kts @@ -44,5 +44,5 @@ suspend fun generateGoArtifacts() { } shell { - if(args.contains("build")) generateGoArtifacts() + if (args.contains("build")) generateGoArtifacts() } diff --git a/flank-bash/scripts/ios.ops.main.kts b/flank-bash/scripts/ios.ops.main.kts index 316e563881..c2c13844b0 100644 --- a/flank-bash/scripts/ios.ops.main.kts +++ b/flank-bash/scripts/ios.ops.main.kts @@ -31,7 +31,7 @@ enum class TestType { } shell { - if(args.contains("build")) generateIos() + if (args.contains("build")) generateIos() } suspend fun Shell.generateIos() = takeUnless { isWindows }?.let { @@ -73,6 +73,7 @@ fun Sequence.copyIosProductFiles() = forEach { if (it.isDirectory) it.copyRecursively(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) else it.copyTo(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) } + fun Path.copyTestFiles() = toString().let { productsDirectory -> copyTestFile(productsDirectory, earlGreyExampleTests, TestType.OBJECTIVE_C) copyTestFile(productsDirectory, earlGreyExampleSwiftTests, TestType.SWIFT) diff --git a/flank-bash/scripts/ios/LipoHelper.kt b/flank-bash/scripts/ios/LipoHelper.kt index 3b12b2032d..549e90b92b 100644 --- a/flank-bash/scripts/ios/LipoHelper.kt +++ b/flank-bash/scripts/ios/LipoHelper.kt @@ -1,4 +1,3 @@ - fun createLipoCommand( outputPath: String, vararg files: String diff --git a/flank-bash/scripts/ios/buildExample.main.kts b/flank-bash/scripts/ios/buildExample.main.kts index 208f2a7be2..96a52b650a 100644 --- a/flank-bash/scripts/ios/buildExample.main.kts +++ b/flank-bash/scripts/ios/buildExample.main.kts @@ -1,4 +1,3 @@ - @file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") @file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") @file:DependsOn("org.slf4j:slf4j-simple:1.7.28") @@ -20,7 +19,7 @@ import java.nio.file.StandardCopyOption import java.util.stream.Collectors import kotlin.system.exitProcess -if(isWindows) { +if (isWindows) { println("This script does not work on Windows") exitProcess(1) } @@ -33,17 +32,17 @@ downloadXcPrettyIfNeeded() shell { - val xcodeCommandSwiftTests = createIosBuildCommand(dataPath.toString(),"./EarlGreyExample.xcworkspace", "EarlGreyExampleSwiftTests") + val xcodeCommandSwiftTests = createIosBuildCommand(dataPath.toString(), "./EarlGreyExample.xcworkspace", "EarlGreyExampleSwiftTests") val xcPrettyCommand = "xcpretty".process() pipeline { xcodeCommandSwiftTests pipe xcPrettyCommand } - val xcodeCommandTests = createIosBuildCommand(dataPath.toString(),"./EarlGreyExample.xcworkspace", "EarlGreyExampleTests") + val xcodeCommandTests = createIosBuildCommand(dataPath.toString(), "./EarlGreyExample.xcworkspace", "EarlGreyExampleTests") pipeline { xcodeCommandTests pipe xcPrettyCommand } } Files.walk(Paths.get("")) - .filter { it.fileName.toString().endsWith("-iphoneos") || it.fileName.toString().endsWith(".xctestrun") } + .filter { it.fileName.toString().endsWith("-iphoneos") || it.fileName.toString().endsWith(".xctestrun") } .map { it.toFile() } .collect(Collectors.toList()) .archive(archiveFileName, currentPath.toFile()) diff --git a/flank-bash/scripts/ios/buildFtl.main.kts b/flank-bash/scripts/ios/buildFtl.main.kts index 59e482e2ab..258ffefaf3 100644 --- a/flank-bash/scripts/ios/buildFtl.main.kts +++ b/flank-bash/scripts/ios/buildFtl.main.kts @@ -18,7 +18,7 @@ import java.nio.file.StandardCopyOption import java.util.stream.Collectors import kotlin.system.exitProcess -if(isWindows) { +if (isWindows) { println("This script does not work on Windows") exitProcess(1) } diff --git a/flank-bash/scripts/ios/universalFramework.main.kts b/flank-bash/scripts/ios/universalFramework.main.kts index 92bb9eb0f9..56c23f9909 100644 --- a/flank-bash/scripts/ios/universalFramework.main.kts +++ b/flank-bash/scripts/ios/universalFramework.main.kts @@ -31,7 +31,7 @@ val universalFilesNames = listOf( ) shell { - universalFilesNames.forEach {fileName -> + universalFilesNames.forEach { fileName -> createLipoCommand( outputPath = Paths.get(comboPath, fileName).toString(), Paths.get(devicePath, fileName).toString(), Paths.get(simPath, fileName).toString() diff --git a/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts b/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts index 0420b2f125..c1c2b631eb 100644 --- a/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts +++ b/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts @@ -21,13 +21,12 @@ shell { val generateLibraryCommand = "generate_library " + "--input=$testingJsonInput " + "--language=java " + - "--package_path=api/services " + "--output_dir=$outputDirectory" generateLibraryCommand() } Files.move( Paths.get(outputDirectory, "pom.xml"), - Paths.get(apiPath, "pom.xml"), + Paths.get(apiPath, "pom.xml"), StandardCopyOption.REPLACE_EXISTING ) diff --git a/flank-bash/scripts/util/OsHelper.kts b/flank-bash/scripts/util/OsHelper.kts index 471651fecf..2bed72f57b 100644 --- a/flank-bash/scripts/util/OsHelper.kts +++ b/flank-bash/scripts/util/OsHelper.kts @@ -1,3 +1,3 @@ - val isWindows = System.getProperty("os.name").startsWith("Windows") - val isMacOS = System.getProperty("os.name").indexOf("mac") >= 0 - val isLinux = !isWindows && !isMacOS \ No newline at end of file +val isWindows = System.getProperty("os.name").startsWith("Windows") +val isMacOS = System.getProperty("os.name").indexOf("mac") >= 0 +val isLinux = !isWindows && !isMacOS diff --git a/flank-bash/scripts/util/downloadSoftware.main.kts b/flank-bash/scripts/util/downloadSoftware.main.kts index 1982a4f3fd..ab636c5c69 100644 --- a/flank-bash/scripts/util/downloadSoftware.main.kts +++ b/flank-bash/scripts/util/downloadSoftware.main.kts @@ -41,7 +41,7 @@ suspend fun Shell.installPods(path: Path) { fun checkIfPipInstalled() { shell { - if(commandExitCode("pip -V") != 0) { + if (commandExitCode("pip -V") != 0) { println("You need pip fot this script. To install it follow https://pip.pypa.io/en/stable/installing/") exitProcess(1) } @@ -56,7 +56,7 @@ fun downloadSortJsonIfNeeded() { fun installClientGeneratorIfNeeded() { val isWindows = System.getProperty("os.name").startsWith("Windows") - val generateLibraryCheckCommand = (if(isWindows) "where " else "command -v ") + "generate_library" + val generateLibraryCheckCommand = (if (isWindows) "where " else "command -v ") + "generate_library" checkAndInstall(generateLibraryCheckCommand) { checkIfPipInstalled() From 307ef1cf0047d5f03fba09e5eaa0a97955e0dd97 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Mon, 19 Oct 2020 15:53:30 +0200 Subject: [PATCH 59/95] code style changes --- flank-bash/scripts/ios.ops.main.kts | 2 -- flank-bash/scripts/ios/buildExample.main.kts | 1 - flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts | 2 -- flank-bash/scripts/util/archive.main.kts | 4 ++-- flank-bash/scripts/util/downloadSoftware.main.kts | 2 +- 5 files changed, 3 insertions(+), 8 deletions(-) diff --git a/flank-bash/scripts/ios.ops.main.kts b/flank-bash/scripts/ios.ops.main.kts index c2c13844b0..2719e26f83 100644 --- a/flank-bash/scripts/ios.ops.main.kts +++ b/flank-bash/scripts/ios.ops.main.kts @@ -15,7 +15,6 @@ import java.nio.file.Path import java.nio.file.Paths import java.nio.file.StandardCopyOption - val debugIphoneOs = "Debug-iphoneos" val earlGreyExampleSwift = "EarlGreyExampleSwift.app" val plugins = "PlugIns" @@ -49,7 +48,6 @@ suspend fun buildEarlGreyExample() = buildDirectoryPath.runBuilds().resolve("Pro filterFilesToCopy().copyIosProductFiles() }.copyTestFiles() - val buildDirectoryPath = Paths.get(iOSTestProjectsPath, earlGreyExample, buildDirectory) suspend fun Path.runBuilds() = toFile().let { projectPath -> diff --git a/flank-bash/scripts/ios/buildExample.main.kts b/flank-bash/scripts/ios/buildExample.main.kts index 96a52b650a..3704955460 100644 --- a/flank-bash/scripts/ios/buildExample.main.kts +++ b/flank-bash/scripts/ios/buildExample.main.kts @@ -31,7 +31,6 @@ val buildProductPath = Paths.get(dataPath.toString(), "Build", "Products") downloadXcPrettyIfNeeded() shell { - val xcodeCommandSwiftTests = createIosBuildCommand(dataPath.toString(), "./EarlGreyExample.xcworkspace", "EarlGreyExampleSwiftTests") val xcPrettyCommand = "xcpretty".process() diff --git a/flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts b/flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts index 3c3de57212..6839eb85c3 100644 --- a/flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts +++ b/flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts @@ -34,5 +34,3 @@ shell { "sort-json $testingV1Path"() "sort-json $testingV1Beta3Path"() } - - diff --git a/flank-bash/scripts/util/archive.main.kts b/flank-bash/scripts/util/archive.main.kts index 850dcfe838..32c5ab58c8 100644 --- a/flank-bash/scripts/util/archive.main.kts +++ b/flank-bash/scripts/util/archive.main.kts @@ -16,7 +16,7 @@ fun File.extract( } else { ArchiverFactory.createArchiver(archiveFormat) } - kotlin.runCatching { + runCatching { archiver.extract(this, destination) }.onFailure { println("There was an error when unpacking $name - $it") @@ -34,7 +34,7 @@ fun File.extract( } else { ArchiverFactory.createArchiver(archiveFormat) } - kotlin.runCatching { + runCatching { archiver.extract(this, destination) }.onFailure { println("There was an error when unpacking $name - $it") diff --git a/flank-bash/scripts/util/downloadSoftware.main.kts b/flank-bash/scripts/util/downloadSoftware.main.kts index ab636c5c69..1db0d59a2c 100644 --- a/flank-bash/scripts/util/downloadSoftware.main.kts +++ b/flank-bash/scripts/util/downloadSoftware.main.kts @@ -36,7 +36,7 @@ fun downloadCocoaPodsIfNeeded() { } suspend fun Shell.installPods(path: Path) { - kotlin.runCatching { "pod install --project-directory=$path --verbose"() } + runCatching { "pod install --project-directory=$path --verbose"() } } fun checkIfPipInstalled() { From 51ecdaa686969adb972af5e58de1c09ea150c4c6 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 20 Oct 2020 14:48:57 +0200 Subject: [PATCH 60/95] Add check and install command --- .../flank/scripts/firebase/FirebaseCommand.kt | 17 +++++++++++++++++ .../scripts/firebase/GenerateJavaClient.kt | 18 ++++++++++++++++++ .../src/main/kotlin/flank/scripts/utils/Env.kt | 2 ++ .../kotlin/flank/scripts/utils/ShellExecute.kt | 6 ++++++ 4 files changed, 43 insertions(+) create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/firebase/FirebaseCommand.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/firebase/GenerateJavaClient.kt diff --git a/flank-scripts/src/main/kotlin/flank/scripts/firebase/FirebaseCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/firebase/FirebaseCommand.kt new file mode 100644 index 0000000000..30b2cc01b4 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/firebase/FirebaseCommand.kt @@ -0,0 +1,17 @@ +package flank.scripts.firebase + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.subcommands + +class FirebaseCommand : CliktCommand(name = "firebase", help = "Contains all firebase commands") { + + init { + subcommands( + GenerateJavaClient() + ) + } + + @Suppress("EmptyFunctionBlock") + override fun run() { + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/firebase/GenerateJavaClient.kt b/flank-scripts/src/main/kotlin/flank/scripts/firebase/GenerateJavaClient.kt new file mode 100644 index 0000000000..fc3ebf2a82 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/firebase/GenerateJavaClient.kt @@ -0,0 +1,18 @@ +package flank.scripts.firebase + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.utils.checkAndInstallIfNeed + +class GenerateJavaClient : CliktCommand(name = "generateJavaClient", help = "Generate Java Client") { + override fun run() { + installClientGeneratorIfNeeded() + } +} + +fun installClientGeneratorIfNeeded() { + val isWindows = System.getProperty("os.name").startsWith("Windows") + val generateLibraryCheckCommand = (if (isWindows) "where " else "command -v ") + "generate_library" + generateLibraryCheckCommand.checkAndInstallIfNeed("pip install google-apis-client-generator") +} + + diff --git a/flank-scripts/src/main/kotlin/flank/scripts/utils/Env.kt b/flank-scripts/src/main/kotlin/flank/scripts/utils/Env.kt index f865ca96dc..589a505f3d 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/utils/Env.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/utils/Env.kt @@ -2,3 +2,5 @@ package flank.scripts.utils fun getEnv(key: String): String = System.getenv(key) ?: throw RuntimeException("Environment variable '$key' not found!") + +val isWindows: Boolean = getEnv("os.name").startsWith("Windows") diff --git a/flank-scripts/src/main/kotlin/flank/scripts/utils/ShellExecute.kt b/flank-scripts/src/main/kotlin/flank/scripts/utils/ShellExecute.kt index b8e1403308..1ff4fce133 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/utils/ShellExecute.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/utils/ShellExecute.kt @@ -24,6 +24,12 @@ fun String.runForOutput(retryCount: Int = 0): String = File file.readText() } +fun String.checkCommandExists() = (if (isWindows) "where " else "command -v ").plus(this).runCommand() == 0 + +fun String.checkAndInstallIfNeed(installCommand: String) = checkCommandExists().takeUnless { it }?.let { + installCommand.runCommand() +} + internal fun ProcessBuilder.startWithRetry(retryCount: Int): Int { var retryTries = 0 var processResponse: Int From 060756b2df1554b86cedd8b1b8902b130695f5ef Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 20 Oct 2020 15:39:36 +0200 Subject: [PATCH 61/95] Add download software --- .../scripts/firebase/GenerateJavaClient.kt | 31 ++++++++++++++----- .../flank/scripts/utils/DownloadSoftware.kt | 30 ++++++++++++++++++ .../main/kotlin/flank/scripts/utils/Env.kt | 2 +- .../flank/scripts/utils/ShellExecute.kt | 4 +++ 4 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/utils/DownloadSoftware.kt diff --git a/flank-scripts/src/main/kotlin/flank/scripts/firebase/GenerateJavaClient.kt b/flank-scripts/src/main/kotlin/flank/scripts/firebase/GenerateJavaClient.kt index fc3ebf2a82..d82db46e20 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/firebase/GenerateJavaClient.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/firebase/GenerateJavaClient.kt @@ -1,18 +1,35 @@ package flank.scripts.firebase import com.github.ajalt.clikt.core.CliktCommand -import flank.scripts.utils.checkAndInstallIfNeed +import flank.scripts.utils.installClientGeneratorIfNeeded +import flank.scripts.utils.runCommand +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.StandardCopyOption class GenerateJavaClient : CliktCommand(name = "generateJavaClient", help = "Generate Java Client") { + override fun run() { installClientGeneratorIfNeeded() - } -} + val apiPath = Paths.get("test_api").toString() + val outputDirectory = Paths.get(apiPath, "src", "main", "java").toString() + val testingJsonInput = Paths.get("json", "testing_v1.json").toString() + Paths.get(apiPath, "src").toFile().deleteRecursively() -fun installClientGeneratorIfNeeded() { - val isWindows = System.getProperty("os.name").startsWith("Windows") - val generateLibraryCheckCommand = (if (isWindows) "where " else "command -v ") + "generate_library" - generateLibraryCheckCommand.checkAndInstallIfNeed("pip install google-apis-client-generator") + val generateLibraryCommand = "generate_library " + + "--input=$testingJsonInput " + + "--language=java " + + "--output_dir=$outputDirectory" + + val result = generateLibraryCommand.runCommand() + if (result != 0) throw Exception() + + Files.move( + Paths.get(outputDirectory, "pom.xml"), + Paths.get(apiPath, "pom.xml"), + StandardCopyOption.REPLACE_EXISTING + ) + } } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/utils/DownloadSoftware.kt b/flank-scripts/src/main/kotlin/flank/scripts/utils/DownloadSoftware.kt new file mode 100644 index 0000000000..ca67f9a98d --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/utils/DownloadSoftware.kt @@ -0,0 +1,30 @@ +package flank.scripts.utils + +import java.nio.file.Path + +fun downloadXcPrettyIfNeeded() { + "xcpretty".checkAndInstallIfNeed("gem install xcpretty") +} + +fun downloadCocoaPodsIfNeeded() { + "xcpretty".checkAndInstallIfNeed("gem install cocoapods -v 1.9.3") +} + +fun installPods(path: Path) { + "pod install --project-directory=$path --verbose".runCommand() +} + +fun checkIfPipInstalled() { + "pip".commandInstalledOr { + println("You need pip fot this script. To install it follow https://pip.pypa.io/en/stable/installing/") + } +} + +fun downloadSortJsonIfNeeded() { + "sort-json".checkAndInstallIfNeed("npm -g install sort-json") +} + +fun installClientGeneratorIfNeeded() { + val generateLibraryCheckCommand = (if (isWindows) "where " else "command -v ") + "generate_library" + generateLibraryCheckCommand.checkAndInstallIfNeed("pip install google-apis-client-generator") +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/utils/Env.kt b/flank-scripts/src/main/kotlin/flank/scripts/utils/Env.kt index 589a505f3d..68ec960e1d 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/utils/Env.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/utils/Env.kt @@ -3,4 +3,4 @@ package flank.scripts.utils fun getEnv(key: String): String = System.getenv(key) ?: throw RuntimeException("Environment variable '$key' not found!") -val isWindows: Boolean = getEnv("os.name").startsWith("Windows") +val isWindows: Boolean = System.getProperty("os.name").startsWith("Windows") diff --git a/flank-scripts/src/main/kotlin/flank/scripts/utils/ShellExecute.kt b/flank-scripts/src/main/kotlin/flank/scripts/utils/ShellExecute.kt index 1ff4fce133..2e4a9ee4f1 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/utils/ShellExecute.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/utils/ShellExecute.kt @@ -30,6 +30,10 @@ fun String.checkAndInstallIfNeed(installCommand: String) = checkCommandExists(). installCommand.runCommand() } +fun String.commandInstalledOr(orAction: () -> Unit) = checkCommandExists().takeUnless { it }?.let { + orAction() +} + internal fun ProcessBuilder.startWithRetry(retryCount: Int): Int { var retryTries = 0 var processResponse: Int From af9f4c0c4baf511cb3cce638a2c73c8e9034e9f7 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Tue, 20 Oct 2020 15:41:43 +0200 Subject: [PATCH 62/95] rewrite updateBinaries to flankScripts --- buildSrc/src/main/kotlin/Dependencies.kt | 2 + buildSrc/src/main/kotlin/Versions.kt | 2 + flank-scripts/build.gradle.kts | 2 + .../flank/scripts/shell/UpdateAtomic.kt | 52 +++++++++++++ .../scripts/shell/UpdateBinariesCommand.kt | 21 +++++ .../kotlin/flank/scripts/shell/UpdateLlvm.kt | 75 ++++++++++++++++++ .../kotlin/flank/scripts/shell/UpdateSwift.kt | 76 +++++++++++++++++++ .../testartifacts/core/DownloadFixtures.kt | 4 +- .../kotlin/flank/scripts/utils/Archive.kt | 56 ++++++++++++++ .../kotlin/flank/scripts/utils/Download.kt | 6 +- 10 files changed, 291 insertions(+), 5 deletions(-) create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateAtomic.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateBinariesCommand.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateLlvm.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateSwift.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/utils/Archive.kt diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index 38a627e763..0b5dea3838 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -54,6 +54,8 @@ object Dependencies { const val KOTLIN_SERIALIZATION = "org.jetbrains.kotlinx:kotlinx-serialization-json:${Versions.KOTLIN_SERIALIZATION}" //region flank-scripts + const val ARCHIVE_LIB = "org.rauschig:jarchivelib:${Versions.ARCHIVE_LIB}" + const val TUKAANI_XZ = "org.tukaani:xz:${Versions.TUKAANI_XZ}" const val CLIKT = "com.github.ajalt:clikt:${Versions.CLIKT}" const val JCABI_GITHUB = "com.jcabi:jcabi-github:${Versions.JCABI_GITHUB}" const val SLF4J_NOP = "org.slf4j:slf4j-nop:${Versions.SLF4J_NOP}" diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 837a6222c6..b2dae80325 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -88,6 +88,8 @@ object Versions { const val PROGUARD = "7.0.0" // ============== flank-scripts ============== + const val ARCHIVE_LIB = "1.1.0" + const val TUKAANI_XZ = "1.0" const val KOTLIN_SERIALIZATION = "1.0.0" const val FUEL = "2.3.0" const val CLIKT = "2.8.0" diff --git a/flank-scripts/build.gradle.kts b/flank-scripts/build.gradle.kts index b4f2c6c6fc..e89b908efe 100644 --- a/flank-scripts/build.gradle.kts +++ b/flank-scripts/build.gradle.kts @@ -74,6 +74,8 @@ dependencies { implementation(Dependencies.JCABI_GITHUB) implementation(Dependencies.SLF4J_NOP) implementation(Dependencies.GLASSFISH_JSON) + implementation(Dependencies.ARCHIVE_LIB) + implementation(Dependencies.TUKAANI_XZ) detektPlugins(Dependencies.DETEKT_FORMATTING) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateAtomic.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateAtomic.kt new file mode 100644 index 0000000000..937b86a489 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateAtomic.kt @@ -0,0 +1,52 @@ +package flank.scripts.shell + +import flank.scripts.utils.downloadFile +import flank.scripts.utils.extract +import java.nio.file.Files +import java.nio.file.Paths +import java.util.stream.Collectors + +private val currentPath = Paths.get("") +private val atomicPath = Paths.get(currentPath.toString(), "libatomic") + +fun updateAtomic() { + val atomicDeb = Paths.get(atomicPath.toString(), "libatomic.deb").toFile() + val atomicDataTarXz = Paths.get(atomicPath.toString(), "data.tar.xz").toFile() + + if (atomicDeb.exists()) { + println("Atomic exists") + } else { + println("Downloading Atomic...") + atomicPath.toFile().mkdirs() + downloadFile( + srcUrl = "http://mirrors.kernel.org/ubuntu/pool/main/g/gcc-8/libatomic1_8-20180414-1ubuntu2_amd64.deb", + destinationPath = atomicDeb.toString() + ) + } + + atomicDeb.extract(atomicPath.toFile(), "ar") + atomicDataTarXz.extract(atomicPath.toFile(), "tar", "xz") + findAndCopyAtomicLicense() + findAndCopyAtomicFiles() + atomicPath.toFile().deleteRecursively() +} + +private fun findAndCopyAtomicLicense() { + val licenseOutputFile = Paths.get(currentPath.toString(), "libatomic.txt").toFile() + + downloadFile( + "http://changelogs.ubuntu.com/changelogs/pool/main/g/gcc-8/gcc-8_8-20180414-1ubuntu2/copyright", + licenseOutputFile.toString() + ) +} + +private fun findAndCopyAtomicFiles() { + println("Copying atomic files ...") + val list = Files.walk(atomicPath) + .filter { it.toString().endsWith("libatomic.so.1") || it.toString().endsWith("libatomic.so.1.2.0") } + .collect(Collectors.toList()) + + list.forEach { + it.toFile().copyTo(Paths.get(currentPath.toString(), it.fileName.toString()).toFile(), true) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateBinariesCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateBinariesCommand.kt new file mode 100644 index 0000000000..dbcc8e0d2d --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateBinariesCommand.kt @@ -0,0 +1,21 @@ +package flank.scripts.shell + +import com.github.ajalt.clikt.core.CliktCommand +import kotlinx.coroutines.async +import kotlinx.coroutines.awaitAll +import kotlinx.coroutines.runBlocking + +object UpdateBinariesCommand : CliktCommand(name = "updateBinaries", help = "Update binaries used by Flank") { + + override fun run() { + runBlocking { + listOf( + async { updateAtomic() }, + async { updateLlvm() }, + async { updateSwift() } + ).awaitAll() + + println("Binaries updated") + } + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateLlvm.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateLlvm.kt new file mode 100644 index 0000000000..bb03d82c09 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateLlvm.kt @@ -0,0 +1,75 @@ +package flank.scripts.shell + +import flank.scripts.utils.downloadFile +import flank.scripts.utils.extract +import flank.scripts.utils.isWindows +import java.nio.file.Files +import java.nio.file.Paths + +private val currentPath = Paths.get("") +private val llvmPath = Paths.get(currentPath.toString(), "llvm") + +fun updateLlvm() = if (isWindows) updateLlvmWindows() else updateLlvmNonWindows() + +private fun updateLlvmWindows() { + val llvmExe = Paths.get(llvmPath.toString(), "LLVM-win64.exe") + if (llvmExe.toFile().exists()) { + println("LLVM exists") + } else { + println("Downloading Windows LLVM...") + llvmPath.toFile().mkdirs() + downloadFile( + srcUrl = "https://releases.llvm.org/8.0.0/LLVM-8.0.0-win64.exe", + destinationPath = llvmExe.toString() + ) + } + + llvmExe.toFile().extract(llvmPath.toFile(), "zip", "xz") + findAndCopyLlvmLicense() + findAndCopyLlvmNmFile() + llvmPath.toFile().deleteRecursively() +} + +private fun updateLlvmNonWindows() { + val llvmTarXz = Paths.get(llvmPath.toString(), "llvm.tar.xz") + + if (llvmTarXz.toFile().exists()) { + println("LLVM exists") + } else { + println("Downloading LLVM...") + llvmPath.toFile().mkdirs() + downloadFile( + srcUrl = "http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz", + destinationPath = llvmTarXz.toString() + ) + } + + llvmTarXz.toFile().extract(llvmPath.toFile(), "tar", "xz") + findAndCopyLlvmLicense() + findAndCopyLlvmLicense() + llvmPath.toFile().deleteRecursively() +} + +private fun findAndCopyLlvmLicense() { + val licensePathSuffix = Paths.get("include", "llvm", "Support", "LICENSE.TXT").toString() + val licenseOutputFile = Paths.get(currentPath.toString(), "llvm.txt").toFile() + + println("Copying license ...") + Files.walk(llvmPath) + .filter { it.toString().endsWith(licensePathSuffix) } + .findFirst() + .takeIf { it.isPresent } + ?.run { get().toFile().copyTo(licenseOutputFile, overwrite = true) } +} + +private fun findAndCopyLlvmNmFile() { + val llvmNmSuffix = Paths.get("bin", "llvm-nm").toString() + val llvmNmOutputFile = Paths.get(currentPath.toString(), "nm").toFile() + + println("Copying llvm nm ...") + Files.walk(llvmPath) + .filter { it.toString().endsWith(llvmNmSuffix) } + .findFirst() + .takeIf { it.isPresent } + ?.run { get().toFile().copyTo(llvmNmOutputFile, overwrite = true) } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateSwift.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateSwift.kt new file mode 100644 index 0000000000..83ec330341 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateSwift.kt @@ -0,0 +1,76 @@ +package flank.scripts.shell + +import flank.scripts.utils.downloadFile +import flank.scripts.utils.extract +import flank.scripts.utils.isWindows +import java.nio.file.Files +import java.nio.file.Paths + +private val currentPath = Paths.get("") +private val swiftPath = Paths.get(currentPath.toString(), "swift") + +fun updateSwift() = if (isWindows) updateSwiftWindows() else updateSwiftOther() + +private fun updateSwiftWindows() { + val swiftExe = Paths.get(swiftPath.toString(), "swift.exe") + + if (swiftExe.toFile().exists()) { + println("Swift exists") + } else { + println("Downloading swift for Windows") + swiftPath.toFile().mkdirs() + downloadFile( + srcUrl = "https://swift.org/builds/swift-5.3-release/windows10/swift-5.3-RELEASE/swift-5.3-RELEASE-windows10.exe", + destinationPath = swiftExe.toString() + ) + } + + swiftExe.toFile().extract(swiftPath.toFile(), "zip", "gz") + findAndCopySwiftLicense() + findAndCopySwiftDemangleFile() + swiftPath.toFile().deleteRecursively() +} + +private fun updateSwiftOther() { + val swiftTarGz = Paths.get(swiftPath.toString(), "swift.tar.gz") + + if (swiftTarGz.toFile().exists()) { + println("Swift exists") + } else { + println("Downloading swift") + swiftPath.toFile().mkdirs() + downloadFile( + srcUrl = "https://swift.org/builds/swift-5.0.1-release/ubuntu1604/swift-5.0.1-RELEASE/swift-5.0.1-RELEASE-ubuntu16.04.tar.gz", + destinationPath = swiftTarGz.toString() + ) + } + + swiftTarGz.toFile().extract(swiftPath.toFile(), "tar", "gz") + findAndCopySwiftLicense() + findAndCopySwiftDemangleFile() + swiftPath.toFile().deleteRecursively() +} + +private fun findAndCopySwiftLicense() { + val licenseFileSuffix = Paths.get("usr", "share", "swift", "LICENSE.txt").toString() + val licenseOutputFile = Paths.get(currentPath.toString(), "swift.txt").toFile() + + println("Copying license ...") + Files.walk(swiftPath) + .filter { it.toString().endsWith(licenseFileSuffix) } + .findFirst() + .takeIf { it.isPresent } + ?.run { get().toFile().copyTo(licenseOutputFile, overwrite = true) } +} + +private fun findAndCopySwiftDemangleFile() { + val switftDemangleFileSuffix = Paths.get("usr", "bin", "swift-demangle").toString() + val switftDemangleOutputFile = Paths.get(currentPath.toString(), "swift-demangle").toFile() + + println("Copying swift-demangle ...") + Files.walk(swiftPath) + .filter { it.toString().endsWith(switftDemangleFileSuffix) } + .findFirst() + .takeIf { it.isPresent } + ?.run { get().toFile().copyTo(switftDemangleOutputFile, overwrite = true) } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/DownloadFixtures.kt b/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/DownloadFixtures.kt index 1291654cf6..3186f43c75 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/DownloadFixtures.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/DownloadFixtures.kt @@ -2,7 +2,7 @@ package flank.scripts.testartifacts.core import com.jcabi.github.Release import flank.scripts.github.getRelease -import flank.scripts.utils.download +import flank.scripts.utils.downloadFile import java.io.File fun Context.downloadFixtures( @@ -28,7 +28,7 @@ private fun Context.downloadFixtures( ).fullName ).run { if (exists() && overwrite) delete() - if (!exists()) download(url, absolutePath).also { println("OK") } + if (!exists()) downloadFile(url, absolutePath).also { println("OK") } else println("ABORTED (already exists)") } } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/utils/Archive.kt b/flank-scripts/src/main/kotlin/flank/scripts/utils/Archive.kt new file mode 100644 index 0000000000..ab71d3db41 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/utils/Archive.kt @@ -0,0 +1,56 @@ +package flank.scripts.utils + +import org.rauschig.jarchivelib.ArchiveFormat +import org.rauschig.jarchivelib.ArchiverFactory +import org.rauschig.jarchivelib.CompressionType +import java.io.File + +fun File.extract( + destination: File, + archiveFormat: ArchiveFormat = ArchiveFormat.AR, + compressFormat: CompressionType? = null +) { + println("Unpacking...$name") + val archiver = if (compressFormat != null) { + ArchiverFactory.createArchiver(archiveFormat, compressFormat) + } else { + ArchiverFactory.createArchiver(archiveFormat) + } + runCatching { + archiver.extract(this, destination) + }.onFailure { + println("There was an error when unpacking $name - $it") + } +} + +fun File.extract( + destination: File, + archiveFormat: String, + compressFormat: String? = null +) { + println("Unpacking...$name") + val archiver = if (compressFormat != null) { + ArchiverFactory.createArchiver(archiveFormat, compressFormat) + } else { + ArchiverFactory.createArchiver(archiveFormat) + } + runCatching { + archiver.extract(this, destination) + }.onFailure { + println("There was an error when unpacking $name - $it") + } +} + +fun List.archive( + destinationFileName: String, + destinationDirectory: File, + archiveFormat: ArchiveFormat = ArchiveFormat.ZIP +) { + println("Packing...$destinationFileName") + val archiver = ArchiverFactory.createArchiver(archiveFormat) + runCatching { + archiver.create(destinationFileName, destinationDirectory, *toTypedArray()) + }.onFailure { + println("There was an error when packing ${destinationDirectory.absolutePath}${File.separator}$destinationFileName - $it") + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/utils/Download.kt b/flank-scripts/src/main/kotlin/flank/scripts/utils/Download.kt index e21c666720..ddc4686644 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/utils/Download.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/utils/Download.kt @@ -3,11 +3,11 @@ package flank.scripts.utils import com.github.kittinunf.fuel.Fuel import java.io.File -fun download( +fun downloadFile( srcUrl: String, - dstFile: String + destinationPath: String ) { Fuel.download(srcUrl) - .fileDestination { _, _ -> File(dstFile) } + .fileDestination { _, _ -> File(destinationPath) } .responseString() } From dd12e15015c82fdebcf99baab78005e9480488d0 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Tue, 20 Oct 2020 15:41:43 +0200 Subject: [PATCH 63/95] rewrite updateBinaries to flankScripts --- .../main/kotlin/flank/scripts/firebase/GenerateJavaClient.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/firebase/GenerateJavaClient.kt b/flank-scripts/src/main/kotlin/flank/scripts/firebase/GenerateJavaClient.kt index d82db46e20..12ef479579 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/firebase/GenerateJavaClient.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/firebase/GenerateJavaClient.kt @@ -31,5 +31,3 @@ class GenerateJavaClient : CliktCommand(name = "generateJavaClient", help = "Gen ) } } - - From d7dc97ad8096bb6c4215990e798a7f6fd18d7dac Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Tue, 20 Oct 2020 15:46:11 +0200 Subject: [PATCH 64/95] rewrite updateBinaries to flankScripts --- .../flank/scripts/shell/{ => updatebinaries}/UpdateAtomic.kt | 2 +- .../scripts/shell/{ => updatebinaries}/UpdateBinariesCommand.kt | 2 +- .../flank/scripts/shell/{ => updatebinaries}/UpdateLlvm.kt | 2 +- .../flank/scripts/shell/{ => updatebinaries}/UpdateSwift.kt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename flank-scripts/src/main/kotlin/flank/scripts/shell/{ => updatebinaries}/UpdateAtomic.kt (97%) rename flank-scripts/src/main/kotlin/flank/scripts/shell/{ => updatebinaries}/UpdateBinariesCommand.kt (92%) rename flank-scripts/src/main/kotlin/flank/scripts/shell/{ => updatebinaries}/UpdateLlvm.kt (98%) rename flank-scripts/src/main/kotlin/flank/scripts/shell/{ => updatebinaries}/UpdateSwift.kt (98%) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateAtomic.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateAtomic.kt similarity index 97% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateAtomic.kt rename to flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateAtomic.kt index 937b86a489..e4ef86440b 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateAtomic.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateAtomic.kt @@ -1,4 +1,4 @@ -package flank.scripts.shell +package flank.scripts.shell.updatebinaries import flank.scripts.utils.downloadFile import flank.scripts.utils.extract diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateBinariesCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateBinariesCommand.kt similarity index 92% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateBinariesCommand.kt rename to flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateBinariesCommand.kt index dbcc8e0d2d..ebc1711efe 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateBinariesCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateBinariesCommand.kt @@ -1,4 +1,4 @@ -package flank.scripts.shell +package flank.scripts.shell.updatebinaries import com.github.ajalt.clikt.core.CliktCommand import kotlinx.coroutines.async diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateLlvm.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateLlvm.kt similarity index 98% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateLlvm.kt rename to flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateLlvm.kt index bb03d82c09..1b70f1d9bd 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateLlvm.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateLlvm.kt @@ -1,4 +1,4 @@ -package flank.scripts.shell +package flank.scripts.shell.updatebinaries import flank.scripts.utils.downloadFile import flank.scripts.utils.extract diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateSwift.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateSwift.kt similarity index 98% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateSwift.kt rename to flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateSwift.kt index 83ec330341..0d63167a2b 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/UpdateSwift.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateSwift.kt @@ -1,4 +1,4 @@ -package flank.scripts.shell +package flank.scripts.shell.updatebinaries import flank.scripts.utils.downloadFile import flank.scripts.utils.extract From 0706fa49fa1f9f9d29023314923cbf35c6e3be87 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 20 Oct 2020 15:52:46 +0200 Subject: [PATCH 65/95] Move firebase to shell --- .../flank/scripts/{ => shell}/firebase/FirebaseCommand.kt | 2 +- .../flank/scripts/{ => shell}/firebase/GenerateJavaClient.kt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) rename flank-scripts/src/main/kotlin/flank/scripts/{ => shell}/firebase/FirebaseCommand.kt (90%) rename flank-scripts/src/main/kotlin/flank/scripts/{ => shell}/firebase/GenerateJavaClient.kt (90%) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/firebase/FirebaseCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/FirebaseCommand.kt similarity index 90% rename from flank-scripts/src/main/kotlin/flank/scripts/firebase/FirebaseCommand.kt rename to flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/FirebaseCommand.kt index 30b2cc01b4..90c1b39781 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/firebase/FirebaseCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/FirebaseCommand.kt @@ -1,4 +1,4 @@ -package flank.scripts.firebase +package flank.scripts.shell.firebase import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.subcommands diff --git a/flank-scripts/src/main/kotlin/flank/scripts/firebase/GenerateJavaClient.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClient.kt similarity index 90% rename from flank-scripts/src/main/kotlin/flank/scripts/firebase/GenerateJavaClient.kt rename to flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClient.kt index 12ef479579..39e0eb6851 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/firebase/GenerateJavaClient.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClient.kt @@ -1,6 +1,7 @@ -package flank.scripts.firebase +package flank.scripts.shell.firebase import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.utils.checkIfPipInstalled import flank.scripts.utils.installClientGeneratorIfNeeded import flank.scripts.utils.runCommand import java.nio.file.Files @@ -10,6 +11,7 @@ import java.nio.file.StandardCopyOption class GenerateJavaClient : CliktCommand(name = "generateJavaClient", help = "Generate Java Client") { override fun run() { + checkIfPipInstalled() installClientGeneratorIfNeeded() val apiPath = Paths.get("test_api").toString() val outputDirectory = Paths.get(apiPath, "src", "main", "java").toString() From 3d3555ff386d744d2cfbe1c5540cca53ff1adc74 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 20 Oct 2020 16:32:58 +0200 Subject: [PATCH 66/95] Add custom error on generate java client --- .../flank/scripts/exceptions/FlankScriptsExceptions.kt | 6 ++++++ .../flank/scripts/shell/firebase/GenerateJavaClient.kt | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/exceptions/FlankScriptsExceptions.kt b/flank-scripts/src/main/kotlin/flank/scripts/exceptions/FlankScriptsExceptions.kt index 3299901d03..817f6e2c1d 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/exceptions/FlankScriptsExceptions.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/exceptions/FlankScriptsExceptions.kt @@ -16,3 +16,9 @@ class BugsnagException(val body: BugSnagResponse) : FlankScriptsExceptions() { return "Error while doing Bugnsag request, because of ${body.errors.joinToString()}" } } + +class ShellCommandException(private val errorMessage: String) : FlankScriptsExceptions() { + override fun toString(): String { + return "Error while executing shell command, details: $errorMessage" + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClient.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClient.kt index 39e0eb6851..91f3eee629 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClient.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClient.kt @@ -1,6 +1,7 @@ package flank.scripts.shell.firebase import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.exceptions.ShellCommandException import flank.scripts.utils.checkIfPipInstalled import flank.scripts.utils.installClientGeneratorIfNeeded import flank.scripts.utils.runCommand @@ -24,7 +25,7 @@ class GenerateJavaClient : CliktCommand(name = "generateJavaClient", help = "Gen "--output_dir=$outputDirectory" val result = generateLibraryCommand.runCommand() - if (result != 0) throw Exception() + if (result != 0) throw ShellCommandException("Error when execute generate_library command") Files.move( Paths.get(outputDirectory, "pom.xml"), From 4474e0b8e43ce308fac0a038d8117dedb0e8cb74 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Tue, 20 Oct 2020 16:58:16 +0200 Subject: [PATCH 67/95] rewrite ios to flankScripts --- .../flank/scripts/shell/ios/BuildExample.kt | 56 +++++++++++++++++ .../flank/scripts/shell/ios/BuildFtl.kt | 46 ++++++++++++++ .../scripts/shell/ios/FastFailForWindows.kt | 11 ++++ .../scripts/shell/ios/IosBuildCommand.kt | 9 +++ .../flank/scripts/shell/ios/LipoHelper.kt | 6 ++ .../flank/scripts/shell/ios/RunFtlLocal.kt | 31 ++++++++++ .../scripts/shell/ios/UniversalFramework.kt | 60 +++++++++++++++++++ .../flank/scripts/shell/utils/PathHelper.kt | 21 +++++++ .../flank/scripts/shell/utils/ShellHelper.kt | 7 +++ 9 files changed, 247 insertions(+) create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildExample.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildFtl.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ios/FastFailForWindows.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ios/IosBuildCommand.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ios/LipoHelper.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/utils/ShellHelper.kt diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildExample.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildExample.kt new file mode 100644 index 0000000000..70072593a0 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildExample.kt @@ -0,0 +1,56 @@ + +package flank.scripts.shell.ios + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.shell.utils.currentPath +import flank.scripts.shell.utils.pipe +import flank.scripts.utils.archive +import flank.scripts.utils.downloadXcPrettyIfNeeded +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths +import java.nio.file.StandardCopyOption +import java.util.stream.Collectors + +object BuildExampleCommand : CliktCommand(name = "iosBuildExample", help = "build example ios app") { + override fun run() { + failIfWindows() + downloadXcPrettyIfNeeded() + buildExample() + } +} + +private fun buildExample() { + val dataPath: Path = Paths.get(currentPath.toString(), "dd_tmp").apply { + toFile().deleteRecursively() + } + + val xcodeCommandSwiftTests = createIosBuildCommand( + dataPath.toString(), + "./EarlGreyExample.xcworkspace", + "EarlGreyExampleSwiftTests" + ) + xcodeCommandSwiftTests pipe "xcpretty" + + val xcodeCommandTests = createIosBuildCommand(dataPath.toString(), "./EarlGreyExample.xcworkspace", "EarlGreyExampleTests") + xcodeCommandTests pipe "xcpretty" + + copyExampleOutputFiles(dataPath.toString()) +} + +private fun copyExampleOutputFiles(dataPath: String) { + val archiveFileName = "earlgrey_example.zip" + val buildProductPath = Paths.get(dataPath, "Build", "Products") + + Files.walk(Paths.get("")) + .filter { it.fileName.toString().endsWith("-iphoneos") || it.fileName.toString().endsWith(".xctestrun") } + .map { it.toFile() } + .collect(Collectors.toList()) + .archive(archiveFileName, currentPath.toFile()) + + Files.move( + Paths.get("", archiveFileName), + Paths.get(buildProductPath.toString(), archiveFileName), + StandardCopyOption.REPLACE_EXISTING + ) +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildFtl.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildFtl.kt new file mode 100644 index 0000000000..f8ce1b3377 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildFtl.kt @@ -0,0 +1,46 @@ +package flank.scripts.shell.ios + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.shell.utils.pipe +import flank.scripts.utils.archive +import flank.scripts.utils.downloadXcPrettyIfNeeded +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.StandardCopyOption +import java.util.stream.Collectors + +object BuildFtlCommand : CliktCommand(name = "iosBuildFtl", help = "build ftl ios app") { + override fun run() { + failIfWindows() + downloadXcPrettyIfNeeded() + buildFtl() + } +} + +private fun buildFtl() { + val dataPath = Paths.get("", "dd_tmp").apply { + toFile().deleteRecursively() + }.toString() + val xcodeCommand = createIosBuildCommand(dataPath, "./EarlGreyExample.xcworkspace", "\"EarlGreyExampleSwiftTests\"") + + xcodeCommand pipe "xcpretty" + copyFtlOutputFiles(dataPath) +} + +private fun copyFtlOutputFiles(dataPath: String) { + val archiveFileName = "earlgrey_example.zip" + val buildProductPath = Paths.get(dataPath, "Build", "Products") + val currentPath = Paths.get("") + + Files.walk(currentPath) + .filter { it.fileName.toString().endsWith("-iphoneos") || it.fileName.toString().endsWith(".xctestrun") } + .map { it.toFile() } + .collect(Collectors.toList()) + .archive(archiveFileName, currentPath.toFile()) + + Files.move( + Paths.get("", archiveFileName), + Paths.get(buildProductPath.toString(), archiveFileName), + StandardCopyOption.REPLACE_EXISTING + ) +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/FastFailForWindows.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/FastFailForWindows.kt new file mode 100644 index 0000000000..9dcf4f193b --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/FastFailForWindows.kt @@ -0,0 +1,11 @@ +package flank.scripts.shell.ios + +import flank.scripts.utils.isWindows +import kotlin.system.exitProcess + +fun failIfWindows() { + if (isWindows) { + println("This script does not work on Windows") + exitProcess(1) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/IosBuildCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/IosBuildCommand.kt new file mode 100644 index 0000000000..60e66c87df --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/IosBuildCommand.kt @@ -0,0 +1,9 @@ +package flank.scripts.shell.ios + +fun createIosBuildCommand(buildDir: String, workspace: String, scheme: String) = + "xcodebuild build-for-testing" + + " -allowProvisioningUpdates" + + " -workspace $workspace" + + " -scheme $scheme" + + " -derivedDataPath $buildDir" + + " -sdk iphoneos" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/LipoHelper.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/LipoHelper.kt new file mode 100644 index 0000000000..d442ed3176 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/LipoHelper.kt @@ -0,0 +1,6 @@ +package flank.scripts.shell.ios + +fun createLipoCommand( + outputPath: String, + vararg files: String +) = "lipo -create ${files.joinToString(" ")} -output $outputPath" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt new file mode 100644 index 0000000000..b786a8e19d --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt @@ -0,0 +1,31 @@ +package flank.scripts.shell.ios + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.parameters.options.option +import com.github.ajalt.clikt.parameters.options.required +import flank.scripts.shell.utils.currentPath +import flank.scripts.utils.runCommand +import java.nio.file.Path +import java.nio.file.Paths + +object RunFtlLocalCommand : CliktCommand(name = "iosBuildFtl", help = "build ftl ios app") { + + private val deviceId by option(help = "Pass device id. Please take it from Xcode -> Window -> Devices and Simulators") + .required() + + override fun run() { + failIfWindows() + runFtlLocal(deviceId) + } +} + +private fun runFtlLocal(deviceId: String) { + val dataPath: Path = Paths.get(currentPath.toString(), "dd_tmp", "Build", "Products") + + val xcodeCommand = "xcodebuild test-without-building " + + " -xctestrun $dataPath/*.xctestrun " + + "-derivedDataPath $dataPath " + + "-destination 'id=$deviceId'" + + xcodeCommand.runCommand() +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt new file mode 100644 index 0000000000..623babec4d --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt @@ -0,0 +1,60 @@ +package flank.scripts.shell.ios + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.shell.utils.currentPath +import flank.scripts.utils.runCommand +import java.nio.file.Paths + +object UniversalFrameworkCommand : CliktCommand(name = "iosUniversalFramework", help = "??") { + override fun run() { + failIfWindows() + createUniversalFiles() + } +} + +private const val APP_FRAMEWORK_FRAMEWORK = "AppFramework.framework" +private const val APP_FRAMEWORK = "AppFramework" + +private fun createUniversalFiles() { + val comboPath = Paths.get(currentPath.toString(), "ios-frameworks").toString() + val devicePath = Paths.get(comboPath, "Debug-iphoneos").toString() + val simPath = Paths.get(comboPath, "Debug-iphonesimulator").toString() + + listOf( + "libChannelLib.a", + "libCommonLib.a", + "libeDistantObject.a", + "libTestLib.a", + "libUILib.a" + ).map { fileName -> + createLipoCommand( + outputPath = Paths.get(comboPath, fileName).toString(), + Paths.get(devicePath, fileName).toString(), Paths.get(simPath, fileName).toString() + ) + }.forEach { command -> command.runCommand() } + + copyAppFrameworkFiles(devicePath, comboPath) + + runDsym( + universalFileOutput = Paths.get(comboPath, APP_FRAMEWORK_FRAMEWORK, APP_FRAMEWORK).toString(), + comboPath = comboPath, + files = arrayOf( + Paths.get(devicePath, APP_FRAMEWORK_FRAMEWORK, APP_FRAMEWORK).toString(), + Paths.get(simPath, APP_FRAMEWORK_FRAMEWORK, APP_FRAMEWORK).toString() + ) + ) +} + +private fun copyAppFrameworkFiles(fromPath: String, toPath: String) { + Paths.get(fromPath, APP_FRAMEWORK_FRAMEWORK).toFile() + .copyRecursively(Paths.get(toPath, APP_FRAMEWORK_FRAMEWORK).toFile(), overwrite = true) +} + +private fun runDsym( + universalFileOutput: String, + comboPath: String, + files: Array +) { + createLipoCommand(universalFileOutput, *files).runCommand() + "dsymutil $universalFileOutput --out ${Paths.get(comboPath, "AppFramework.framework.dSYM")}".runCommand() +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt new file mode 100644 index 0000000000..29c8c6114b --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt @@ -0,0 +1,21 @@ +package flank.scripts.shell.utils + +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.Path + +val currentPath = Paths.get("") +val rootDirectoryPath = goToRoot(currentPath) +val rootDirectoryFile = rootDirectoryPath.toFile() +val rootDirectoryPathString = rootDirectoryPath.toString() + +fun goToRoot(startPath: Path): Path = + if (startPath.isRoot()) startPath.toAbsolutePath() else goToRoot(startPath.toAbsolutePath().parent) + +fun Path.isRoot() = Files.exists(Paths.get(toString(), "settings.gradle.kts")) + +val testProjectsPath = Paths.get(rootDirectoryPathString, "test_projects").toString() +val androidTestProjectsPath = Paths.get(testProjectsPath, "android").toString() +val iOSTestProjectsPath = Paths.get(testProjectsPath, "ios").toString() +val flankFixturesTmpPath = + Paths.get(rootDirectoryPathString, "test_runner", "src", "test", "kotlin", "ftl", "fixtures", "tmp").toString() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/ShellHelper.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/ShellHelper.kt new file mode 100644 index 0000000000..9faceac91c --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/ShellHelper.kt @@ -0,0 +1,7 @@ +package flank.scripts.shell.utils + +import flank.scripts.utils.runCommand + +infix fun String.pipe(command: String) { + "$this | $command".runCommand() +} From e5a79dbefcc3eac2e20fc93402884e61a0f5bd44 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 20 Oct 2020 17:03:29 +0200 Subject: [PATCH 68/95] Add UpdateApiJsonCommand --- .../scripts/shell/firebase/FirebaseCommand.kt | 3 +- ...Client.kt => GenerateJavaClientCommand.kt} | 2 +- .../shell/firebase/UpdateApiJsonCommand.kt | 31 +++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) rename flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/{GenerateJavaClient.kt => GenerateJavaClientCommand.kt} (91%) create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/UpdateApiJsonCommand.kt diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/FirebaseCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/FirebaseCommand.kt index 90c1b39781..218b7680b4 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/FirebaseCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/FirebaseCommand.kt @@ -7,7 +7,8 @@ class FirebaseCommand : CliktCommand(name = "firebase", help = "Contains all fir init { subcommands( - GenerateJavaClient() + UpdateApiJsonCommand(), + GenerateJavaClientCommand() ) } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClient.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClientCommand.kt similarity index 91% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClient.kt rename to flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClientCommand.kt index 91f3eee629..9c029b3f88 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClient.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClientCommand.kt @@ -9,7 +9,7 @@ import java.nio.file.Files import java.nio.file.Paths import java.nio.file.StandardCopyOption -class GenerateJavaClient : CliktCommand(name = "generateJavaClient", help = "Generate Java Client") { +class GenerateJavaClientCommand : CliktCommand(name = "generate_java_client", help = "Generate Java Client") { override fun run() { checkIfPipInstalled() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/UpdateApiJsonCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/UpdateApiJsonCommand.kt new file mode 100644 index 0000000000..58bb6c52ca --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/UpdateApiJsonCommand.kt @@ -0,0 +1,31 @@ +package flank.scripts.shell.firebase + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.shell.utils.currentPath +import flank.scripts.utils.downloadFile +import flank.scripts.utils.downloadSortJsonIfNeeded +import flank.scripts.utils.runCommand +import java.nio.file.Paths + +class UpdateApiJsonCommand : CliktCommand(name = "update_api_json", help = "Contains all firebase commands") { + override fun run() { + val jsonDirectoryPath = Paths.get(currentPath.toString(), "json") + val testingV1Path = Paths.get(jsonDirectoryPath.toString(), "testing_v1.json").toString() + val testingV1Beta3Path = Paths.get(jsonDirectoryPath.toString(), "toolresults_v1beta3.json").toString() + + downloadFile( + "https://raw.githubusercontent.com/Flank/gcloud_cli/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/testing_v1.json", + testingV1Path + ) + + downloadFile( + "https://raw.githubusercontent.com/Flank/gcloud_cli/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/toolresults_v1beta3.json", + testingV1Beta3Path + ) + + downloadSortJsonIfNeeded() + + "sort-json $testingV1Path".runCommand() + "sort-json $testingV1Beta3Path".runCommand() + } +} From ea7b48247b28176b1a6b648216745e93146f7609 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 20 Oct 2020 17:14:52 +0200 Subject: [PATCH 69/95] Ops commands initial --- .../scripts/shell/ops/AndroidOpsCommand.kt | 10 ++++++++++ .../flank/scripts/shell/ops/GoOpsCommand.kt | 10 ++++++++++ .../flank/scripts/shell/ops/IosOpsCommand.kt | 10 ++++++++++ .../flank/scripts/shell/ops/OpsCommand.kt | 19 +++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt new file mode 100644 index 0000000000..963bc8e0a1 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt @@ -0,0 +1,10 @@ +package flank.scripts.shell.ops + +import com.github.ajalt.clikt.core.CliktCommand + +class AndroidOpsCommand : CliktCommand(name = "android"){ + override fun run() { + TODO("Not yet implemented") + } + +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt new file mode 100644 index 0000000000..6c97c05358 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt @@ -0,0 +1,10 @@ +package flank.scripts.shell.ops + +import com.github.ajalt.clikt.core.CliktCommand + +class GoOpsCommand : CliktCommand(name = "android"){ + override fun run() { + TODO("Not yet implemented") + } + +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt new file mode 100644 index 0000000000..f0c073ecf1 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt @@ -0,0 +1,10 @@ +package flank.scripts.shell.ops + +import com.github.ajalt.clikt.core.CliktCommand + +class IosOpsCommand : CliktCommand(name = "android"){ + override fun run() { + TODO("Not yet implemented") + } + +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt new file mode 100644 index 0000000000..e086557b7a --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt @@ -0,0 +1,19 @@ +package flank.scripts.shell.ops + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.subcommands + +class OpsCommand : CliktCommand(name = "ops", help = "Contains all ops command: android, ios, gp") { + init { + subcommands( + AndroidOpsCommand(), + IosOpsCommand(), + GoOpsCommand() + ) + } + + override fun run() { + + } + +} From 9b443975a048d7559f73a25f412d0882b06814da Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 20 Oct 2020 17:48:48 +0200 Subject: [PATCH 70/95] Add android build --- .../scripts/shell/ops/AndroidOpsCommand.kt | 92 ++++++++++++++++++- .../flank/scripts/shell/ops/IosOpsCommand.kt | 3 +- .../flank/scripts/shell/ops/OpsCommand.kt | 16 ++-- .../scripts/shell/utils/GradleCommand.kt | 17 ++++ 4 files changed, 115 insertions(+), 13 deletions(-) create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/utils/GradleCommand.kt diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt index 963bc8e0a1..1d58dda4dd 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt @@ -1,10 +1,98 @@ package flank.scripts.shell.ops import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.shell.utils.androidTestProjectsPath +import flank.scripts.shell.utils.createGradleCommand +import flank.scripts.shell.utils.flankFixturesTmpPath +import flank.scripts.utils.runCommand +import java.io.File +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths +import java.nio.file.StandardCopyOption -class AndroidOpsCommand : CliktCommand(name = "android"){ +class AndroidOpsCommand : CliktCommand(name = "android", help = "Build android apk's with test's") { override fun run() { - TODO("Not yet implemented") + buildBaseApk() + buildBaseTestApk() + buildDuplicatedNamesApks() + buildMultiModulesApks() + buildCucumberSampleApp() } +} + +private fun buildBaseApk() { + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, "app:assemble") + ).runCommand() + + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "app-debug.apk") + + if (!outputDir.parent.toFile().exists()) Files.createDirectories(outputDir.parent) + + val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "singleSuccess", "debug", "app-single-success-debug.apk") + Files.copy(assembleDirectory, outputDir, StandardCopyOption.REPLACE_EXISTING) +} + +private fun buildBaseTestApk() { + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, "app:assembleAndroidTest") + ).runCommand() + + val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "androidTest") + assembleDirectory.toFile().findApks().forEach { + Files.copy(it.toPath(), Paths.get(flankFixturesTmpPath, "apk", it.name), StandardCopyOption.REPLACE_EXISTING) + } +} + +private fun buildDuplicatedNamesApks() { + val modules = (0..3).map { "dir$it" } + + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath) + modules.map { "$it:testModule:assembleAndroidTest" }.toList() + ).runCommand() + + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "duplicated_names") + if (!outputDir.toFile().exists()) Files.createDirectories(outputDir) + + modules.map { Paths.get(androidTestProjectsPath, it, "testModule", "build", "outputs", "apk").toFile() } + .flatMap { it.findApks().toList() } + .forEachIndexed { index, file -> + file.copyApkToDirectory(Paths.get(outputDir.toString(), modules[index], file.name)) + } +} + +private fun File.copyApkToDirectory(output: Path): Path = toPath().let { sourceFile -> + if (!output.parent.toFile().exists()) Files.createDirectories(output.parent) + Files.copy(sourceFile, output, StandardCopyOption.REPLACE_EXISTING) +} + +private fun buildMultiModulesApks() { + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, + ":multi-modules:multiapp:assemble") + (1..20).map { ":multi-modules:testModule$it:assembleAndroidTest" }).runCommand() + + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "multi-modules").toString() + Paths.get(androidTestProjectsPath, "multi-modules").toFile().findApks() + .forEach { it.copyApkToDirectory(Paths.get(outputDir, it.name)) } +} + +private fun buildCucumberSampleApp() { + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, "cucumber_sample_app:cukeulator:assembleDebug", ":cucumber_sample_app:cukeulator:assembleAndroidTest") + ).runCommand() + + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "cucumber_sample_app").toString() + Paths.get(androidTestProjectsPath, "cucumber_sample_app").toFile().findApks().copyApksToPath(outputDir) +} + +private fun File.findApks() = walk().filter { it.extension == "apk" } +private fun Sequence.copyApksToPath(outputDirectory: String) = forEach { + it.copyApkToDirectory(Paths.get(outputDirectory, it.name)) } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt index f0c073ecf1..2a420d8983 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt @@ -2,9 +2,8 @@ package flank.scripts.shell.ops import com.github.ajalt.clikt.core.CliktCommand -class IosOpsCommand : CliktCommand(name = "android"){ +class IosOpsCommand : CliktCommand(name = "android") { override fun run() { TODO("Not yet implemented") } - } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt index e086557b7a..6e6716725c 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt @@ -4,16 +4,14 @@ import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.subcommands class OpsCommand : CliktCommand(name = "ops", help = "Contains all ops command: android, ios, gp") { - init { - subcommands( - AndroidOpsCommand(), - IosOpsCommand(), - GoOpsCommand() - ) - } + init { + subcommands( + AndroidOpsCommand(), + IosOpsCommand(), + GoOpsCommand() + ) + } override fun run() { - } - } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/GradleCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/GradleCommand.kt new file mode 100644 index 0000000000..c4021fe718 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/GradleCommand.kt @@ -0,0 +1,17 @@ +package flank.scripts.shell.utils + +import flank.scripts.utils.isWindows +import java.nio.file.Paths + +fun createGradleCommand( + workingDir: String, + vararg options: String +) = createGradleCommand(workingDir, options.asList()) + +fun createGradleCommand( + workingDir: String, + options: List +) = "${Paths.get(workingDir, gradleExecutable)} ${options.joinToString(" ")}" + +private val gradleExecutable: String + get() = if (isWindows) "gradlew.bat" else "./gradlew" From ad985494a2f7ddf3ee7b0ff473892a909efdf7f0 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Tue, 20 Oct 2020 17:49:01 +0200 Subject: [PATCH 71/95] rewrite buildFlank, testFilter and goops to flankScripts --- .../kotlin/flank/scripts/shell/BuildFlank.kt | 27 +++++++++++++++++ .../kotlin/flank/scripts/shell/ops/GoOS.kt | 11 +++++++ .../flank/scripts/shell/ops/GoOpsCommand.kt | 30 +++++++++++++++++-- .../flank/scripts/shell/utils/TestFilters.kt | 28 +++++++++++++++++ .../flank/scripts/utils/ShellExecute.kt | 15 +++++++--- 5 files changed, 105 insertions(+), 6 deletions(-) create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/BuildFlank.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOS.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/utils/TestFilters.kt diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/BuildFlank.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/BuildFlank.kt new file mode 100644 index 0000000000..6060905ef7 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/BuildFlank.kt @@ -0,0 +1,27 @@ +package flank.scripts.shell + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.shell.utils.createGradleCommand +import flank.scripts.shell.utils.rootDirectoryPathString +import java.nio.file.Paths + +object BuildFlankCommand : CliktCommand(name = "buildFlank", help = "Build Flank") { + override fun run() { + buildFlank() + } +} + +private fun buildFlank() { + createGradleCommand( + workingDir = rootDirectoryPathString, + "-p", rootDirectoryPathString, ":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar") + + copyFlankOutputFile() +} + +private fun copyFlankOutputFile() { + val flankDirectory = Paths.get(rootDirectoryPathString, "test_runner").toString() + + Paths.get(flankDirectory, "build", "libs", "flank.jar").toFile() + .copyTo(Paths.get(flankDirectory, "bash", "flank.jar").toFile(), overwrite = true) +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOS.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOS.kt new file mode 100644 index 0000000000..a68d806cfa --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOS.kt @@ -0,0 +1,11 @@ +package flank.scripts.shell.ops + +enum class GoOS( + val goName: String, + val directory: String, + val extension: String = "" +) { + LINUX("linux", "bin/linux"), + MAC("darwin", "bin/mac"), + WINDOWS("windows", "bin/win", ".exe"), +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt index 6c97c05358..9cae32206c 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt @@ -1,10 +1,36 @@ package flank.scripts.shell.ops import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.shell.utils.flankFixturesTmpPath +import flank.scripts.shell.utils.testProjectsPath +import flank.scripts.utils.runCommand +import java.nio.file.Path +import java.nio.file.Paths -class GoOpsCommand : CliktCommand(name = "android"){ +class GoOpsCommand : CliktCommand(name = "buildGoApps", help = "build go sample apps") { override fun run() { - TODO("Not yet implemented") + generateGoArtifacts() } + private fun generateGoArtifacts() { + val goHelloBinDirectoryPath = Paths.get(testProjectsPath, "gohello", "bin").apply { + toFile().deleteRecursively() + } + GoOS.values().forEach { createExecutable(it, goHelloBinDirectoryPath) } + } + + private fun createExecutable(os: GoOS, goHelloBinDirectoryPath: Path) { + Paths.get(goHelloBinDirectoryPath.toString(), *os.directory.split('/').toTypedArray()) + .toFile() + .mkdirs() + "go build -o ${os.createOutputPathForBinary()}".runCommand( + environmentVariables = mapOf( + "GOOS" to os.goName, + "GOARCH" to "amd64" + ) + ) + } + + private fun GoOS.createOutputPathForBinary() = + Paths.get(flankFixturesTmpPath, "gohello", directory, "gohello$extension") } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/TestFilters.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/TestFilters.kt new file mode 100644 index 0000000000..7a18faeeea --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/TestFilters.kt @@ -0,0 +1,28 @@ +package flank.scripts.shell.utils + +private const val PACKAGE = "com.example.test_app" +private const val PACKAGE_FOO = "com.example.test_app.foo" +private const val PACKAGE_BAR = "com.example.test_app.bar" + +private const val ANNOTATION = "$PACKAGE.Annotation" + +private const val CLASS = "$PACKAGE.InstrumentedTest" +private const val CLASS_FOO = "$PACKAGE_FOO.FooInstrumentedTest" +private const val CLASS_BAR = "$PACKAGE_BAR.BarInstrumentedTest" + +private const val METHOD_1 = "$CLASS#test1" +private const val METHOD_FOO = "$CLASS_FOO#testFoo" + +private const val RUNNER = "com.example.test_app.test/androidx.test.runner.AndroidJUnitRunner" + +val runAllTestsShellCommand: String + get() = "adb shell am instrument -r -w \$@ $RUNNER" + +val filterPackageBarClassFooMethod1Command: String + get() = "$runAllTestsShellCommand -e package $PACKAGE_BAR -e class $CLASS_FOO -e class $METHOD_1" + +val filterAnnotationMethodFooCommand: String + get() = "$runAllTestsShellCommand -e annotation $ANNOTATION -e class $METHOD_FOO" + +val filterNotPackageFooNotClassBarCommand: String + get() = "$runAllTestsShellCommand -e notPackage $PACKAGE_FOO -e notClass $CLASS_BAR" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/utils/ShellExecute.kt b/flank-scripts/src/main/kotlin/flank/scripts/utils/ShellExecute.kt index 2e4a9ee4f1..f9e6f953ef 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/utils/ShellExecute.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/utils/ShellExecute.kt @@ -2,8 +2,12 @@ package flank.scripts.utils import java.io.File -fun List.runCommand(retryCount: Int = 0, fileForOutput: File? = null) = - ProcessBuilder(this).apply { +fun List.runCommand( + retryCount: Int = 0, + fileForOutput: File? = null, + environmentVariables: Map = mapOf() +) = ProcessBuilder(this).apply { + environment().putAll(environmentVariables) if (fileForOutput != null) { redirectOutput(fileForOutput) redirectError(fileForOutput) @@ -14,8 +18,11 @@ fun List.runCommand(retryCount: Int = 0, fileForOutput: File? = null) = } .startWithRetry(retryCount) -fun String.runCommand(retryCount: Int = 0, fileForOutput: File? = null) = - split(" ").toList().runCommand(retryCount, fileForOutput) +fun String.runCommand( + retryCount: Int = 0, + fileForOutput: File? = null, + environmentVariables: Map = mapOf() +) = split(" ").toList().runCommand(retryCount, fileForOutput, environmentVariables) fun String.runForOutput(retryCount: Int = 0): String = File .createTempFile(hashCode().toString(), "") From 9f4f17a7c5e79869556a750f7ce9fb3d0199a377 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 20 Oct 2020 18:00:54 +0200 Subject: [PATCH 72/95] Change classes to objects --- flank-scripts/src/main/kotlin/flank/scripts/Main.kt | 2 +- .../kotlin/flank/scripts/shell/firebase/FirebaseCommand.kt | 6 +++--- .../scripts/shell/firebase/GenerateJavaClientCommand.kt | 2 +- .../flank/scripts/shell/firebase/UpdateApiJsonCommand.kt | 2 +- .../kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt | 2 +- .../src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt | 2 +- .../src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt | 6 +++--- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/Main.kt b/flank-scripts/src/main/kotlin/flank/scripts/Main.kt index 082ff2dabd..3381518f3e 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/Main.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/Main.kt @@ -17,6 +17,6 @@ fun main(args: Array) { ReleaseCommand(), CiCommand(), DependenciesCommand, - TestArtifactsCommand() + TestArtifactsCommand(), ).main(args) } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/FirebaseCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/FirebaseCommand.kt index 218b7680b4..80d68d6377 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/FirebaseCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/FirebaseCommand.kt @@ -3,12 +3,12 @@ package flank.scripts.shell.firebase import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.subcommands -class FirebaseCommand : CliktCommand(name = "firebase", help = "Contains all firebase commands") { +object FirebaseCommand : CliktCommand(name = "firebase", help = "Contains all firebase commands") { init { subcommands( - UpdateApiJsonCommand(), - GenerateJavaClientCommand() + UpdateApiJsonCommand, + GenerateJavaClientCommand ) } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClientCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClientCommand.kt index 9c029b3f88..2c331533f0 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClientCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClientCommand.kt @@ -9,7 +9,7 @@ import java.nio.file.Files import java.nio.file.Paths import java.nio.file.StandardCopyOption -class GenerateJavaClientCommand : CliktCommand(name = "generate_java_client", help = "Generate Java Client") { +object GenerateJavaClientCommand : CliktCommand(name = "generate_java_client", help = "Generate Java Client") { override fun run() { checkIfPipInstalled() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/UpdateApiJsonCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/UpdateApiJsonCommand.kt index 58bb6c52ca..3453ccb4bd 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/UpdateApiJsonCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/UpdateApiJsonCommand.kt @@ -7,7 +7,7 @@ import flank.scripts.utils.downloadSortJsonIfNeeded import flank.scripts.utils.runCommand import java.nio.file.Paths -class UpdateApiJsonCommand : CliktCommand(name = "update_api_json", help = "Contains all firebase commands") { +object UpdateApiJsonCommand : CliktCommand(name = "update_api_json", help = "Contains all firebase commands") { override fun run() { val jsonDirectoryPath = Paths.get(currentPath.toString(), "json") val testingV1Path = Paths.get(jsonDirectoryPath.toString(), "testing_v1.json").toString() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt index 1d58dda4dd..177ff90b14 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt @@ -11,7 +11,7 @@ import java.nio.file.Path import java.nio.file.Paths import java.nio.file.StandardCopyOption -class AndroidOpsCommand : CliktCommand(name = "android", help = "Build android apk's with test's") { +object AndroidOpsCommand : CliktCommand(name = "android", help = "Build android apk's with test's") { override fun run() { buildBaseApk() buildBaseTestApk() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt index 9cae32206c..9bfc214ffd 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt @@ -7,7 +7,7 @@ import flank.scripts.utils.runCommand import java.nio.file.Path import java.nio.file.Paths -class GoOpsCommand : CliktCommand(name = "buildGoApps", help = "build go sample apps") { +object GoOpsCommand : CliktCommand(name = "buildGoApps", help = "build go sample apps") { override fun run() { generateGoArtifacts() } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt index 6e6716725c..2914183d78 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt @@ -3,12 +3,12 @@ package flank.scripts.shell.ops import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.subcommands -class OpsCommand : CliktCommand(name = "ops", help = "Contains all ops command: android, ios, gp") { +object OpsCommand : CliktCommand(name = "ops", help = "Contains all ops command: android, ios, gp") { init { subcommands( - AndroidOpsCommand(), + AndroidOpsCommand, IosOpsCommand(), - GoOpsCommand() + GoOpsCommand ) } From 21ffcd188c57a9f8ac7ea2ee8e053f848da397bf Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Tue, 20 Oct 2020 18:29:41 +0200 Subject: [PATCH 73/95] added ios ops and make some code and documentation changes --- .../kotlin/flank/scripts/shell/BuildFlank.kt | 14 ++- .../flank/scripts/shell/ios/BuildExample.kt | 3 +- .../flank/scripts/shell/ios/BuildFtl.kt | 3 +- .../flank/scripts/shell/ios/RunFtlLocal.kt | 3 +- .../scripts/shell/ios/UniversalFramework.kt | 1 + .../flank/scripts/shell/ops/GoOpsCommand.kt | 2 +- .../flank/scripts/shell/ops/IosOpsCommand.kt | 88 ++++++++++++++++++- .../flank/scripts/shell/ops/OpsCommand.kt | 6 +- .../updatebinaries/UpdateBinariesCommand.kt | 12 +-- .../{ios => utils}/FastFailForWindows.kt | 2 +- .../flank/scripts/shell/utils/PathHelper.kt | 1 - 11 files changed, 115 insertions(+), 20 deletions(-) rename flank-scripts/src/main/kotlin/flank/scripts/shell/{ios => utils}/FastFailForWindows.kt (85%) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/BuildFlank.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/BuildFlank.kt index 6060905ef7..c8fe356b00 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/BuildFlank.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/BuildFlank.kt @@ -3,7 +3,10 @@ package flank.scripts.shell import com.github.ajalt.clikt.core.CliktCommand import flank.scripts.shell.utils.createGradleCommand import flank.scripts.shell.utils.rootDirectoryPathString +import flank.scripts.utils.runCommand +import java.nio.file.Files import java.nio.file.Paths +import java.nio.file.StandardCopyOption object BuildFlankCommand : CliktCommand(name = "buildFlank", help = "Build Flank") { override fun run() { @@ -14,7 +17,9 @@ object BuildFlankCommand : CliktCommand(name = "buildFlank", help = "Build Flank private fun buildFlank() { createGradleCommand( workingDir = rootDirectoryPathString, - "-p", rootDirectoryPathString, ":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar") + "-p", rootDirectoryPathString, ":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar" + ) + .runCommand() copyFlankOutputFile() } @@ -22,6 +27,9 @@ private fun buildFlank() { private fun copyFlankOutputFile() { val flankDirectory = Paths.get(rootDirectoryPathString, "test_runner").toString() - Paths.get(flankDirectory, "build", "libs", "flank.jar").toFile() - .copyTo(Paths.get(flankDirectory, "bash", "flank.jar").toFile(), overwrite = true) + Files.copy( + Paths.get(flankDirectory, "build", "libs", "flank.jar"), + Paths.get(flankDirectory, "bash", "flank.jar"), + StandardCopyOption.REPLACE_EXISTING + ) } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildExample.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildExample.kt index 70072593a0..bdbf611155 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildExample.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildExample.kt @@ -3,6 +3,7 @@ package flank.scripts.shell.ios import com.github.ajalt.clikt.core.CliktCommand import flank.scripts.shell.utils.currentPath +import flank.scripts.shell.utils.failIfWindows import flank.scripts.shell.utils.pipe import flank.scripts.utils.archive import flank.scripts.utils.downloadXcPrettyIfNeeded @@ -12,7 +13,7 @@ import java.nio.file.Paths import java.nio.file.StandardCopyOption import java.util.stream.Collectors -object BuildExampleCommand : CliktCommand(name = "iosBuildExample", help = "build example ios app") { +object BuildExampleCommand : CliktCommand(name = "iosBuildExample", help = "Build example ios app") { override fun run() { failIfWindows() downloadXcPrettyIfNeeded() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildFtl.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildFtl.kt index f8ce1b3377..8b355490e0 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildFtl.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildFtl.kt @@ -1,6 +1,7 @@ package flank.scripts.shell.ios import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.shell.utils.failIfWindows import flank.scripts.shell.utils.pipe import flank.scripts.utils.archive import flank.scripts.utils.downloadXcPrettyIfNeeded @@ -9,7 +10,7 @@ import java.nio.file.Paths import java.nio.file.StandardCopyOption import java.util.stream.Collectors -object BuildFtlCommand : CliktCommand(name = "iosBuildFtl", help = "build ftl ios app") { +object BuildFtlCommand : CliktCommand(name = "iosBuildFtl", help = "Build ftl ios app") { override fun run() { failIfWindows() downloadXcPrettyIfNeeded() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt index b786a8e19d..27c40b5134 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt @@ -4,11 +4,12 @@ import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.parameters.options.option import com.github.ajalt.clikt.parameters.options.required import flank.scripts.shell.utils.currentPath +import flank.scripts.shell.utils.failIfWindows import flank.scripts.utils.runCommand import java.nio.file.Path import java.nio.file.Paths -object RunFtlLocalCommand : CliktCommand(name = "iosBuildFtl", help = "build ftl ios app") { +object RunFtlLocalCommand : CliktCommand(name = "iosBuildFtl", help = "Build ftl ios app") { private val deviceId by option(help = "Pass device id. Please take it from Xcode -> Window -> Devices and Simulators") .required() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt index 623babec4d..c024f4c735 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt @@ -2,6 +2,7 @@ package flank.scripts.shell.ios import com.github.ajalt.clikt.core.CliktCommand import flank.scripts.shell.utils.currentPath +import flank.scripts.shell.utils.failIfWindows import flank.scripts.utils.runCommand import java.nio.file.Paths diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt index 9bfc214ffd..761ca0703e 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt @@ -7,7 +7,7 @@ import flank.scripts.utils.runCommand import java.nio.file.Path import java.nio.file.Paths -object GoOpsCommand : CliktCommand(name = "buildGoApps", help = "build go sample apps") { +object GoOpsCommand : CliktCommand(name = "go", help = "Build go app with tests") { override fun run() { generateGoArtifacts() } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt index 2a420d8983..ea28a2e55a 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt @@ -1,9 +1,93 @@ package flank.scripts.shell.ops import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.shell.ios.createIosBuildCommand +import flank.scripts.shell.utils.failIfWindows +import flank.scripts.shell.utils.flankFixturesTmpPath +import flank.scripts.shell.utils.iOSTestProjectsPath +import flank.scripts.shell.utils.pipe +import flank.scripts.utils.downloadCocoaPodsIfNeeded +import flank.scripts.utils.downloadXcPrettyIfNeeded +import flank.scripts.utils.installPods +import java.io.File +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths +import java.nio.file.StandardCopyOption -class IosOpsCommand : CliktCommand(name = "android") { +enum class TestType { + SWIFT, + OBJECTIVE_C +} + +object IosOpsCommand : CliktCommand(name = "ios", help = "Build ios app with tests") { override fun run() { - TODO("Not yet implemented") + failIfWindows() + generateIos() + } + + private fun generateIos() { + downloadCocoaPodsIfNeeded() + installPods(Paths.get(iOSTestProjectsPath, EARL_GREY_EXAMPLE)) + downloadXcPrettyIfNeeded() + createDirectoryInFixture(directoryName = "objc") + createDirectoryInFixture(directoryName = "swift") + buildEarlGreyExample() + } + + private fun createDirectoryInFixture(directoryName: String): Path = + Files.createDirectories(Paths.get(flankFixturesTmpPath, directoryName)) + + private fun buildEarlGreyExample() = Paths.get(iOSTestProjectsPath, EARL_GREY_EXAMPLE, "Build") + .runBuilds() + .resolve("Products") + .apply { filterFilesToCopy().copyIosProductFiles() } + .copyTestFiles() + + private fun Path.runBuilds() = apply { + toFile().deleteRecursively() + val parent = toFile().parent + val swiftCommand = createIosBuildCommand( + parent, + Paths.get(parent, "EarlGreyExample.xcworkspace").toString(), + scheme = EARL_GREY_EXAMPLE_TESTS + ) + swiftCommand pipe "xcpretty" + + val objcCommand = createIosBuildCommand( + parent, + Paths.get(parent, "EarlGreyExample.xcworkspace").toString(), + scheme = EARL_GREY_EXAMPLE_SWIFT_TESTS + ) + objcCommand pipe "xcpretty" + } + + private fun Path.filterFilesToCopy() = + toFile().walk().filter { it.nameWithoutExtension.endsWith("-iphoneos") || it.extension == "xctestrun" } + + private fun Sequence.copyIosProductFiles() = forEach { + if (it.isDirectory) it.copyRecursively(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) + else it.copyTo(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) } + + private fun Path.copyTestFiles() = toString().let { productsDirectory -> + val pluginsDirectory = arrayOf("Debug-iphoneos", "EarlGreyExampleSwift.app", "PlugIns") + copyTestFile(productsDirectory, pluginsDirectory, EARL_GREY_EXAMPLE_TESTS, TestType.OBJECTIVE_C) + copyTestFile(productsDirectory, pluginsDirectory, EARL_GREY_EXAMPLE_SWIFT_TESTS, TestType.SWIFT) + } + + private fun copyTestFile( + productsDirectory: String, + pluginsDirectories: Array, + name: String, + type: TestType + ) = Files.copy( + Paths.get(productsDirectory, *pluginsDirectories, "$name.xctest", name), + Paths.get(flankFixturesTmpPath, type.toString().toLowerCase(), name), + StandardCopyOption.REPLACE_EXISTING + ) } + +private const val EARL_GREY_EXAMPLE = "EarlGreyExample" +private const val EARL_GREY_EXAMPLE_TESTS = "EarlGreyExampleTests" +private const val EARL_GREY_EXAMPLE_SWIFT_TESTS = "EarlGreyExampleSwiftTests" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt index 2914183d78..f97440c252 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt @@ -7,11 +7,11 @@ object OpsCommand : CliktCommand(name = "ops", help = "Contains all ops command: init { subcommands( AndroidOpsCommand, - IosOpsCommand(), + IosOpsCommand, GoOpsCommand ) } - override fun run() { - } + @Suppress("EmptyFunctionBlock") + override fun run() {} } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateBinariesCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateBinariesCommand.kt index ebc1711efe..b42fe638ad 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateBinariesCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateBinariesCommand.kt @@ -1,8 +1,8 @@ package flank.scripts.shell.updatebinaries import com.github.ajalt.clikt.core.CliktCommand -import kotlinx.coroutines.async -import kotlinx.coroutines.awaitAll +import kotlinx.coroutines.joinAll +import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking object UpdateBinariesCommand : CliktCommand(name = "updateBinaries", help = "Update binaries used by Flank") { @@ -10,10 +10,10 @@ object UpdateBinariesCommand : CliktCommand(name = "updateBinaries", help = "Upd override fun run() { runBlocking { listOf( - async { updateAtomic() }, - async { updateLlvm() }, - async { updateSwift() } - ).awaitAll() + launch { updateAtomic() }, + launch { updateLlvm() }, + launch { updateSwift() } + ).joinAll() println("Binaries updated") } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/FastFailForWindows.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/FastFailForWindows.kt similarity index 85% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/ios/FastFailForWindows.kt rename to flank-scripts/src/main/kotlin/flank/scripts/shell/utils/FastFailForWindows.kt index 9dcf4f193b..2aec5874d0 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/FastFailForWindows.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/FastFailForWindows.kt @@ -1,4 +1,4 @@ -package flank.scripts.shell.ios +package flank.scripts.shell.utils import flank.scripts.utils.isWindows import kotlin.system.exitProcess diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt index 29c8c6114b..e6f217c29d 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt @@ -6,7 +6,6 @@ import java.nio.file.Path val currentPath = Paths.get("") val rootDirectoryPath = goToRoot(currentPath) -val rootDirectoryFile = rootDirectoryPath.toFile() val rootDirectoryPathString = rootDirectoryPath.toString() fun goToRoot(startPath: Path): Path = From 1e8bb9bbf3e591ff85c60064717ef215dfdac610 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Tue, 20 Oct 2020 18:30:00 +0200 Subject: [PATCH 74/95] added shell command --- .../src/main/kotlin/flank/scripts/Main.kt | 2 ++ .../flank/scripts/shell/ShellCommand.kt | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ShellCommand.kt diff --git a/flank-scripts/src/main/kotlin/flank/scripts/Main.kt b/flank-scripts/src/main/kotlin/flank/scripts/Main.kt index 3381518f3e..81dfc4fe8f 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/Main.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/Main.kt @@ -5,6 +5,7 @@ import com.github.ajalt.clikt.core.subcommands import flank.scripts.ci.CiCommand import flank.scripts.dependencies.DependenciesCommand import flank.scripts.release.ReleaseCommand +import flank.scripts.shell.ShellCommand import flank.scripts.testartifacts.TestArtifactsCommand class Main : CliktCommand(name = "flankScripts") { @@ -18,5 +19,6 @@ fun main(args: Array) { CiCommand(), DependenciesCommand, TestArtifactsCommand(), + ShellCommand ).main(args) } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ShellCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ShellCommand.kt new file mode 100644 index 0000000000..e69df8b2a0 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ShellCommand.kt @@ -0,0 +1,29 @@ +package flank.scripts.shell + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.subcommands +import flank.scripts.shell.firebase.FirebaseCommand +import flank.scripts.shell.ios.BuildExampleCommand +import flank.scripts.shell.ios.BuildFtlCommand +import flank.scripts.shell.ios.RunFtlLocalCommand +import flank.scripts.shell.ios.UniversalFrameworkCommand +import flank.scripts.shell.ops.OpsCommand +import flank.scripts.shell.updatebinaries.UpdateBinariesCommand + +object ShellCommand : CliktCommand(name = "shell", help = "Task for shell commands") { + init { + subcommands( + FirebaseCommand, + BuildExampleCommand, + BuildFtlCommand, + RunFtlLocalCommand, + UniversalFrameworkCommand, + OpsCommand, + UpdateBinariesCommand, + BuildFlankCommand + ) + } + + @Suppress("EmptyFunctionBlock") + override fun run() {} +} From ba350d1ed97db7f6806ded7c21ef2130cdac281c Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Tue, 20 Oct 2020 18:31:46 +0200 Subject: [PATCH 75/95] fixed scripts for building flankScripts --- flank-scripts/bash/buildFlankScripts.bat | 7 ++++++- flank-scripts/bash/buildFlankScripts.sh | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/flank-scripts/bash/buildFlankScripts.bat b/flank-scripts/bash/buildFlankScripts.bat index 2971d19d61..aeeb65e9c6 100755 --- a/flank-scripts/bash/buildFlankScripts.bat +++ b/flank-scripts/bash/buildFlankScripts.bat @@ -1,2 +1,7 @@ SET DIR=%~dp0 -kotlin %DIR%\..\..\flank-bash\scripts\buildFlankScripts.main.kts + +SET FLANK_SCRIPTS=%DIR%\.. +SET GRADLE_EXECUTABLE_PATH=%FLANK_SCRIPTS%\.. + +%GRADLE_EXECUTABLE_PATH%\gradlew.bat flank-scripts:clean flank-scripts:assemble flank-scripts:shadowJar +copy %FLANK_SCRIPTS%\build\libs\flankScripts.jar %DIR%\flankScripts.jar diff --git a/flank-scripts/bash/buildFlankScripts.sh b/flank-scripts/bash/buildFlankScripts.sh index 03e5a4ede5..dcf74fa19f 100755 --- a/flank-scripts/bash/buildFlankScripts.sh +++ b/flank-scripts/bash/buildFlankScripts.sh @@ -1,3 +1,8 @@ +#!/usr/bin/env bash DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../../flank-bash/scripts/buildFlankScripts.main.kts + +FLANK_SCRIPTS="$DIR/.." + +"$FLANK_SCRIPTS/../gradlew" :flank-scripts:clean :flank-scripts:assemble :flank-scripts:shadowJar +cp "$FLANK_SCRIPTS"/build/libs/flankScripts.jar "$DIR/flankScripts.jar" From e0874910cf4b35f6a0367bbdc5292cb21a03ebae Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Tue, 20 Oct 2020 18:32:11 +0200 Subject: [PATCH 76/95] remove standalon flank bash --- flank-bash/scripts/TestFilters.kt | 27 ----- flank-bash/scripts/android.ops.main.kts | 106 ------------------ flank-bash/scripts/buildFlankScripts.main.kts | 23 ---- flank-bash/scripts/go.ops.main.kts | 48 -------- flank-bash/scripts/ios.ops.main.kts | 84 -------------- flank-bash/scripts/ios/IosBuildCommand.kt | 7 -- flank-bash/scripts/ios/LipoHelper.kt | 4 - flank-bash/scripts/ios/buildExample.main.kts | 53 --------- flank-bash/scripts/ios/buildFtl.main.kts | 50 --------- flank-bash/scripts/ios/runFtlLocal.main.kts | 35 ------ .../scripts/ios/universalFramework.main.kts | 57 ---------- flank-bash/scripts/ops.main.kts | 26 ----- .../generateJavaClient.main.kts | 32 ------ .../updateFirebaseApi/updateApiJson.main.kts | 36 ------ flank-bash/scripts/updateFlank.main.kts | 24 ---- .../scripts/updateLibs/updateAtomic.main.kts | 53 --------- .../updateLibs/updateBinaries.main.kts | 9 -- .../scripts/updateLibs/updateLlvm.main.kts | 77 ------------- .../scripts/updateLibs/updateSwift.main.kts | 77 ------------- flank-bash/scripts/util/GradleCommand.kt | 16 --- flank-bash/scripts/util/OsHelper.kts | 3 - flank-bash/scripts/util/PathHelper.kt | 19 ---- flank-bash/scripts/util/archive.main.kts | 56 --------- .../scripts/util/downloadFiles.main.kts | 24 ---- .../scripts/util/downloadSoftware.main.kts | 65 ----------- 25 files changed, 1011 deletions(-) delete mode 100644 flank-bash/scripts/TestFilters.kt delete mode 100644 flank-bash/scripts/android.ops.main.kts delete mode 100644 flank-bash/scripts/buildFlankScripts.main.kts delete mode 100644 flank-bash/scripts/go.ops.main.kts delete mode 100644 flank-bash/scripts/ios.ops.main.kts delete mode 100644 flank-bash/scripts/ios/IosBuildCommand.kt delete mode 100644 flank-bash/scripts/ios/LipoHelper.kt delete mode 100644 flank-bash/scripts/ios/buildExample.main.kts delete mode 100644 flank-bash/scripts/ios/buildFtl.main.kts delete mode 100644 flank-bash/scripts/ios/runFtlLocal.main.kts delete mode 100644 flank-bash/scripts/ios/universalFramework.main.kts delete mode 100644 flank-bash/scripts/ops.main.kts delete mode 100644 flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts delete mode 100644 flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts delete mode 100644 flank-bash/scripts/updateFlank.main.kts delete mode 100644 flank-bash/scripts/updateLibs/updateAtomic.main.kts delete mode 100644 flank-bash/scripts/updateLibs/updateBinaries.main.kts delete mode 100644 flank-bash/scripts/updateLibs/updateLlvm.main.kts delete mode 100644 flank-bash/scripts/updateLibs/updateSwift.main.kts delete mode 100644 flank-bash/scripts/util/GradleCommand.kt delete mode 100644 flank-bash/scripts/util/OsHelper.kts delete mode 100644 flank-bash/scripts/util/PathHelper.kt delete mode 100644 flank-bash/scripts/util/archive.main.kts delete mode 100644 flank-bash/scripts/util/downloadFiles.main.kts delete mode 100644 flank-bash/scripts/util/downloadSoftware.main.kts diff --git a/flank-bash/scripts/TestFilters.kt b/flank-bash/scripts/TestFilters.kt deleted file mode 100644 index e101d5f1dc..0000000000 --- a/flank-bash/scripts/TestFilters.kt +++ /dev/null @@ -1,27 +0,0 @@ -private const val PACKAGE = "com.example.test_app" -private const val PACKAGE_FOO = "com.example.test_app.foo" -private const val PACKAGE_BAR = "com.example.test_app.bar" - -private const val ANNOTATION = "$PACKAGE.Annotation" - -private const val CLASS = "$PACKAGE.InstrumentedTest" -private const val CLASS_FOO = "$PACKAGE_FOO.FooInstrumentedTest" -private const val CLASS_BAR = "$PACKAGE_BAR.BarInstrumentedTest" - -private const val METHOD_1 = "$CLASS#test1" -private const val METHOD_FOO = "$CLASS_FOO#testFoo" -private const val METHOD_BAR = "$CLASS_BAR#testBar" - -private const val RUNNER = "com.example.test_app.test/androidx.test.runner.AndroidJUnitRunner" - -val runAllTestsShellCommand: String - get() = "adb shell am instrument -r -w \$@ $RUNNER" - -val filterPackageBarClassFooMethod1Command: String - get() = "$runAllTestsShellCommand -e package $PACKAGE_BAR -e class $CLASS_FOO -e class $METHOD_1" - -val filterAnnotationMethodFooCommand: String - get() = "$runAllTestsShellCommand -e annotation $ANNOTATION -e class $METHOD_FOO" - -val filterNotPackageFooNotClassBarCommand: String - get() = "$runAllTestsShellCommand -e notPackage $PACKAGE_FOO -e notClass $CLASS_BAR" diff --git a/flank-bash/scripts/android.ops.main.kts b/flank-bash/scripts/android.ops.main.kts deleted file mode 100644 index 2892b5e577..0000000000 --- a/flank-bash/scripts/android.ops.main.kts +++ /dev/null @@ -1,106 +0,0 @@ -@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") -@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") -@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") -@file:Import("util/GradleCommand.kt") -@file:Import("util/PathHelper.kt") -@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") -@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) - -import java.io.File -import java.nio.file.Files -import java.nio.file.Paths -import eu.jrie.jetbrains.kotlinshell.shell.* -import java.nio.file.Path -import java.nio.file.StandardCopyOption - -shell { - if (args.contains("build")) generateApkAndTests() -} - -suspend fun Shell.generateApkAndTests() { - buildBaseApp() - buildBaseTestApk() - buildDuplicatedNamesApks() - buildMultiModulesApks() - buildCucumberSampleApp() -} - -suspend fun Shell.buildBaseApp() { - shell { - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, "app:assemble") - )() - } - - val outputDir = Paths.get(flankFixturesTmpPath, "apk", "app-debug.apk") - - if (!outputDir.parent.toFile().exists()) Files.createDirectories(outputDir.parent) - - val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "singleSuccess", "debug", "app-single-success-debug.apk") - Files.copy(assembleDirectory, outputDir, StandardCopyOption.REPLACE_EXISTING) -} - -suspend fun Shell.buildBaseTestApk() { - shell { - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, "app:assembleAndroidTest") - )() - } - val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "androidTest") - assembleDirectory.toFile().findApks().forEach { - Files.copy(it.toPath(), Paths.get(flankFixturesTmpPath, "apk", it.name), StandardCopyOption.REPLACE_EXISTING) - } -} - -suspend fun Shell.buildDuplicatedNamesApks() { - val modules = (0..3).map { "dir$it" } - shell { - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath) + modules.map { "$it:testModule:assembleAndroidTest" }.toList() - )() - } - val outputDir = Paths.get(flankFixturesTmpPath, "apk", "duplicated_names") - if (!outputDir.toFile().exists()) Files.createDirectories(outputDir) - - modules.map { Paths.get(androidTestProjectsPath, it, "testModule", "build", "outputs", "apk").toFile() } - .flatMap { it.findApks().toList() } - .forEachIndexed { index, file -> - file.copyApkToDirectory(Paths.get(outputDir.toString(), modules[index], file.name)) - } -} - -fun File.copyApkToDirectory(output: Path) = toPath().let { sourceFile -> - if (!output.parent.toFile().exists()) Files.createDirectories(output.parent) - Files.copy(sourceFile, output, StandardCopyOption.REPLACE_EXISTING) -} - -suspend fun Shell.buildMultiModulesApks() { - shell { - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, ":multi-modules:multiapp:assemble") + (1..20).map { ":multi-modules:testModule$it:assembleAndroidTest" })() - } - val outputDir = Paths.get(flankFixturesTmpPath, "apk", "multi-modules").toString() - Paths.get(androidTestProjectsPath, "multi-modules").toFile().findApks() - .forEach { it.copyApkToDirectory(Paths.get(outputDir, it.name)) } -} - -suspend fun Shell.buildCucumberSampleApp() { - shell { - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, "cucumber_sample_app:cukeulator:assembleDebug", ":cucumber_sample_app:cukeulator:assembleAndroidTest") - )() - } - val outputDir = Paths.get(flankFixturesTmpPath, "apk", "cucumber_sample_app").toString() - Paths.get(androidTestProjectsPath, "cucumber_sample_app").toFile().findApks().copyApksToPath(outputDir) -} - -fun File.findApks() = walk().filter { it.extension == "apk" } - -fun Sequence.copyApksToPath(outputDirectory: String) = forEach { - it.copyApkToDirectory(Paths.get(outputDirectory, it.name)) -} diff --git a/flank-bash/scripts/buildFlankScripts.main.kts b/flank-bash/scripts/buildFlankScripts.main.kts deleted file mode 100644 index 242e038af6..0000000000 --- a/flank-bash/scripts/buildFlankScripts.main.kts +++ /dev/null @@ -1,23 +0,0 @@ -@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") -@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") -@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") -@file:Import("util/GradleCommand.kt") -@file:Import("util/PathHelper.kt") -@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") -@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) - -import eu.jrie.jetbrains.kotlinshell.shell.* -import java.nio.file.Path -import java.nio.file.Paths - -val flankScriptsDirectory: Path = Paths.get(rootDirectoryPathString, "flank-scripts") - -shell { - createGradleCommand( - workingDir = rootDirectoryPathString, - "-p", rootDirectoryPathString, ":flank-scripts:clean", ":flank-scripts:assemble", ":flank-scripts:shadowJar" - )() -} - -Paths.get(flankScriptsDirectory.toString(), "build", "libs", "flankScripts.jar").toFile() - .copyTo(Paths.get(flankScriptsDirectory.toString(), "bash", "flankScripts.jar").toFile(), overwrite = true) diff --git a/flank-bash/scripts/go.ops.main.kts b/flank-bash/scripts/go.ops.main.kts deleted file mode 100644 index 90554c868d..0000000000 --- a/flank-bash/scripts/go.ops.main.kts +++ /dev/null @@ -1,48 +0,0 @@ -@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") -@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") -@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") - -@file:Import("util/PathHelper.kt") - -@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) - -import java.nio.file.Paths -import eu.jrie.jetbrains.kotlinshell.shell.* - -enum class GoOS( - val goName: String, - val directory: String, - val extension: String = "" -) { - LINUX("linux", "bin/linux"), - MAC("darwin", "bin/mac"), - WINDOWS("windows", "bin/win", ".exe"), -} - -val goHelloDirectory = - (if (args.isNotEmpty()) Paths.get(args.first()) else Paths.get(testProjectsPath, "gohello")) - .toString() -private val goHelloBinDirectoryPath = Paths.get(goHelloDirectory, "bin") - -suspend fun createExecutable(os: GoOS) { - Paths.get(goHelloBinDirectoryPath.toString(), *os.directory.split('/').toTypedArray()) - .toFile() - .mkdirs() - - shell(dir = Paths.get(testProjectsPath, "gohello").toFile()) { - export("GOOS" to os.goName) - export("GOARCH" to "amd64") - "go build -o ${createPathForBinary(os)}"() - } -} - -fun createPathForBinary(os: GoOS) = Paths.get(flankFixturesTmpPath, "gohello", os.directory, "gohello${os.extension}") - -suspend fun generateGoArtifacts() { - goHelloBinDirectoryPath.toFile().deleteRecursively() - GoOS.values().forEach { createExecutable(it) } -} - -shell { - if (args.contains("build")) generateGoArtifacts() -} diff --git a/flank-bash/scripts/ios.ops.main.kts b/flank-bash/scripts/ios.ops.main.kts deleted file mode 100644 index 2719e26f83..0000000000 --- a/flank-bash/scripts/ios.ops.main.kts +++ /dev/null @@ -1,84 +0,0 @@ -@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") -@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") -@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") -@file:Import("util/GradleCommand.kt") -@file:Import("util/PathHelper.kt") -@file:Import("ios/IosBuildCommand.kt") -@file:Import("util/downloadSoftware.main.kts") -@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") -@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) - -import eu.jrie.jetbrains.kotlinshell.shell.* -import java.io.File -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.Paths -import java.nio.file.StandardCopyOption - -val debugIphoneOs = "Debug-iphoneos" -val earlGreyExampleSwift = "EarlGreyExampleSwift.app" -val plugins = "PlugIns" -val earlGreyExample = "EarlGreyExample" -val earlGreyExampleTests = "EarlGreyExampleTests" -val earlGreyExampleSwiftTests = "EarlGreyExampleSwiftTests" -val buildDirectory = "Build" -val pluginsDirectory = arrayOf(debugIphoneOs, earlGreyExampleSwift, plugins) - -enum class TestType { - SWIFT, - OBJECTIVE_C -} - -shell { - if (args.contains("build")) generateIos() -} - -suspend fun Shell.generateIos() = takeUnless { isWindows }?.let { - downloadCocoaPodsIfNeeded() - installPods(Paths.get(iOSTestProjectsPath, earlGreyExample)) - downloadXcPrettyIfNeeded() - createDirectoryInFixture(directoryName = "objc") - createDirectoryInFixture(directoryName = "swift") - buildEarlGreyExample() -} - -fun createDirectoryInFixture(directoryName: String): Path = Files.createDirectories(Paths.get(flankFixturesTmpPath, directoryName)) - -suspend fun buildEarlGreyExample() = buildDirectoryPath.runBuilds().resolve("Products").apply { - filterFilesToCopy().copyIosProductFiles() -}.copyTestFiles() - -val buildDirectoryPath = Paths.get(iOSTestProjectsPath, earlGreyExample, buildDirectory) - -suspend fun Path.runBuilds() = toFile().let { projectPath -> - projectPath.deleteRecursively() - shell { - val swiftCommand = createIosBuildCommand( - projectPath.parent, Paths.get(projectPath.parent, "EarlGreyExample.xcworkspace").toString(), scheme = earlGreyExampleTests - ).process() - - pipeline { swiftCommand pipe "xcpretty".process() } - - val objcCommand = createIosBuildCommand(projectPath.parent, Paths.get(projectPath.parent, "EarlGreyExample.xcworkspace").toString(), scheme = earlGreyExampleSwiftTests).process() - pipeline { objcCommand pipe "xcpretty".process() } - } - this -} - -fun Path.filterFilesToCopy() = toFile().walk().filter { it.nameWithoutExtension.endsWith("-iphoneos") || it.extension == "xctestrun" } - -fun Sequence.copyIosProductFiles() = forEach { - if (it.isDirectory) it.copyRecursively(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) - else it.copyTo(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) -} - -fun Path.copyTestFiles() = toString().let { productsDirectory -> - copyTestFile(productsDirectory, earlGreyExampleTests, TestType.OBJECTIVE_C) - copyTestFile(productsDirectory, earlGreyExampleSwiftTests, TestType.SWIFT) -} - -fun copyTestFile(productsDirectory: String, name: String, type: TestType) = Files.copy( - Paths.get(productsDirectory, *pluginsDirectory, "$name.xctest", name), - Paths.get(flankFixturesTmpPath, type.toString().toLowerCase(), name), - StandardCopyOption.REPLACE_EXISTING -) diff --git a/flank-bash/scripts/ios/IosBuildCommand.kt b/flank-bash/scripts/ios/IosBuildCommand.kt deleted file mode 100644 index 38d8d297b2..0000000000 --- a/flank-bash/scripts/ios/IosBuildCommand.kt +++ /dev/null @@ -1,7 +0,0 @@ -fun createIosBuildCommand(buildDir: String, workspace: String, scheme: String) = - "xcodebuild build-for-testing" + - " -allowProvisioningUpdates" + - " -workspace $workspace" + - " -scheme $scheme" + - " -derivedDataPath $buildDir" + - " -sdk iphoneos" diff --git a/flank-bash/scripts/ios/LipoHelper.kt b/flank-bash/scripts/ios/LipoHelper.kt deleted file mode 100644 index 549e90b92b..0000000000 --- a/flank-bash/scripts/ios/LipoHelper.kt +++ /dev/null @@ -1,4 +0,0 @@ -fun createLipoCommand( - outputPath: String, - vararg files: String -) = "lipo -create ${files.joinToString(" ")} -output $outputPath" diff --git a/flank-bash/scripts/ios/buildExample.main.kts b/flank-bash/scripts/ios/buildExample.main.kts deleted file mode 100644 index 3704955460..0000000000 --- a/flank-bash/scripts/ios/buildExample.main.kts +++ /dev/null @@ -1,53 +0,0 @@ -@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") -@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") -@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") - -@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") -@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) - -@file:Import("../util/archive.main.kts") -@file:Import("../util/downloadSoftware.main.kts") -@file:Import("../util/PathHelper.kt") -@file:Import("../util/OsHelper.kts") -@file:Import("IosBuildCommand.kt") - -import eu.jrie.jetbrains.kotlinshell.shell.shell -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.Paths -import java.nio.file.StandardCopyOption -import java.util.stream.Collectors -import kotlin.system.exitProcess - -if (isWindows) { - println("This script does not work on Windows") - exitProcess(1) -} - -val dataPath: Path = Paths.get(currentPath.toString(), "dd_tmp") -dataPath.toFile().deleteRecursively() -val archiveFileName = "earlgrey_example.zip" -val buildProductPath = Paths.get(dataPath.toString(), "Build", "Products") -downloadXcPrettyIfNeeded() - -shell { - val xcodeCommandSwiftTests = createIosBuildCommand(dataPath.toString(), "./EarlGreyExample.xcworkspace", "EarlGreyExampleSwiftTests") - val xcPrettyCommand = "xcpretty".process() - - pipeline { xcodeCommandSwiftTests pipe xcPrettyCommand } - - val xcodeCommandTests = createIosBuildCommand(dataPath.toString(), "./EarlGreyExample.xcworkspace", "EarlGreyExampleTests") - pipeline { xcodeCommandTests pipe xcPrettyCommand } -} - -Files.walk(Paths.get("")) - .filter { it.fileName.toString().endsWith("-iphoneos") || it.fileName.toString().endsWith(".xctestrun") } - .map { it.toFile() } - .collect(Collectors.toList()) - .archive(archiveFileName, currentPath.toFile()) - -Files.move( - Paths.get("", archiveFileName), - Paths.get(buildProductPath.toString(), archiveFileName), - StandardCopyOption.REPLACE_EXISTING -) diff --git a/flank-bash/scripts/ios/buildFtl.main.kts b/flank-bash/scripts/ios/buildFtl.main.kts deleted file mode 100644 index 258ffefaf3..0000000000 --- a/flank-bash/scripts/ios/buildFtl.main.kts +++ /dev/null @@ -1,50 +0,0 @@ -@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") -@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") -@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") - -@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") -@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) - -@file:Import("../util/downloadSoftware.main.kts") -@file:Import("../util/archive.main.kts") -@file:Import("../util/PathHelper.kt") -@file:Import("IosBuildCommand.kt") - -import eu.jrie.jetbrains.kotlinshell.shell.shell -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.Paths -import java.nio.file.StandardCopyOption -import java.util.stream.Collectors -import kotlin.system.exitProcess - -if (isWindows) { - println("This script does not work on Windows") - exitProcess(1) -} - -val currentPath = Paths.get("") -val dataPath: Path = Paths.get("", "dd_tmp") -dataPath.toFile().deleteRecursively() -val archiveFileName = "earlgrey_example.zip" -val buildProductPath = Paths.get(dataPath.toString(), "Build", "Products") -downloadXcPrettyIfNeeded() - -shell { - val xcodeCommand = createIosBuildCommand(dataPath.toString(), "./EarlGreyExample.xcworkspace", "\"EarlGreyExampleSwiftTests\"").process() - val xcPrettyCommand = "xcpretty".process() - - pipeline { xcodeCommand pipe xcPrettyCommand } - - Files.walk(Paths.get("")) - .filter { it.fileName.toString().endsWith("-iphoneos") || it.fileName.toString().endsWith(".xctestrun") } - .map { it.toFile() } - .collect(Collectors.toList()) - .archive(archiveFileName, currentPath.toFile()) - - Files.move( - Paths.get("", archiveFileName), - Paths.get(buildProductPath.toString(), archiveFileName), - StandardCopyOption.REPLACE_EXISTING - ) -} diff --git a/flank-bash/scripts/ios/runFtlLocal.main.kts b/flank-bash/scripts/ios/runFtlLocal.main.kts deleted file mode 100644 index 4ee76edea2..0000000000 --- a/flank-bash/scripts/ios/runFtlLocal.main.kts +++ /dev/null @@ -1,35 +0,0 @@ -@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") -@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") -@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") - -@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") -@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) - -@file:Import("../util/PathHelper.kt") -@file:Import("../util/OsHelper.kts") - -import eu.jrie.jetbrains.kotlinshell.shell.shell -import java.nio.file.Path -import java.nio.file.Paths -import kotlin.system.exitProcess - -val id = args.firstOrNull() ?: { - println("Pass device id. Please take it from Xcode -> Window -> Devices and Simulators") - exitProcess(1) -} - -if (isWindows) { - println("This script does not work on Windows") - exitProcess(1) -} - -val dataPath: Path = Paths.get(currentPath.toString(), "dd_tmp", "Build", "Products") - -val xcodeCommand = "xcodebuild test-without-building " + - " -xctestrun $dataPath/*.xctestrun " + - "-derivedDataPath $dataPath " + - "-destination 'id=$id'" - -shell { - xcodeCommand() -} diff --git a/flank-bash/scripts/ios/universalFramework.main.kts b/flank-bash/scripts/ios/universalFramework.main.kts deleted file mode 100644 index 56c23f9909..0000000000 --- a/flank-bash/scripts/ios/universalFramework.main.kts +++ /dev/null @@ -1,57 +0,0 @@ -@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") -@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") -@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") - -@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") -@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) - -@file:Import("LipoHelper.kt") -@file:Import("../util/PathHelper.kt") -@file:Import("../util/OsHelper.kts") - -import eu.jrie.jetbrains.kotlinshell.shell.shell -import java.nio.file.Paths -import kotlin.system.exitProcess - -if (isWindows) { - println("This script does not work on Windows") - exitProcess(1) -} - -val comboPath = Paths.get(currentPath.toString(), "ios-frameworks").toString() -val devicePath = Paths.get(comboPath, "Debug-iphoneos").toString() -val simPath = Paths.get(comboPath, "Debug-iphonesimulator").toString() - -val universalFilesNames = listOf( - "libChannelLib.a", - "libCommonLib.a", - "libeDistantObject.a", - "libTestLib.a", - "libUILib.a" -) - -shell { - universalFilesNames.forEach { fileName -> - createLipoCommand( - outputPath = Paths.get(comboPath, fileName).toString(), - Paths.get(devicePath, fileName).toString(), Paths.get(simPath, fileName).toString() - ) - } -} -private val appFrameworkFramework = "AppFramework.framework" -private val appFramework = "AppFramework" -Paths.get(devicePath, appFrameworkFramework).toFile() - .copyRecursively(Paths.get(comboPath, appFrameworkFramework).toFile(), overwrite = true) - -val deviceFramework = Paths.get(devicePath, appFrameworkFramework, appFramework).toString() -val simFramework = Paths.get(simPath, appFrameworkFramework, appFramework).toString() -val universalFramework = Paths.get(comboPath, appFrameworkFramework, appFramework).toString() - -shell { - createLipoCommand( - outputPath = universalFramework, - deviceFramework, simFramework - ) - - "dsymutil $universalFramework --out ${Paths.get(comboPath, "AppFramework.framework.dSYM")}" -} diff --git a/flank-bash/scripts/ops.main.kts b/flank-bash/scripts/ops.main.kts deleted file mode 100644 index 21c6201265..0000000000 --- a/flank-bash/scripts/ops.main.kts +++ /dev/null @@ -1,26 +0,0 @@ -@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") -@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") -@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") -@file:Import("android.ops.main.kts") -@file:Import("ios.ops.main.kts") -@file:Import("go.ops.main.kts") -@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") -@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) - -import eu.jrie.jetbrains.kotlinshell.shell.* - -enum class OpsOptions { - ANDROID, - IOS, - GO -} - -shell { - args.map { it.toUpperCase() }.onEach { - when (it) { - OpsOptions.ANDROID.toString() -> generateApkAndTests() - OpsOptions.IOS.toString() -> generateIos() - OpsOptions.GO.toString() -> generateGoArtifacts() - } - } -} diff --git a/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts b/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts deleted file mode 100644 index c1c2b631eb..0000000000 --- a/flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts +++ /dev/null @@ -1,32 +0,0 @@ -@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") -@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") -@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") - -@file:Import("../util/downloadSoftware.main.kts") - -@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") -@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) - -import eu.jrie.jetbrains.kotlinshell.shell.* -import java.nio.file.Files -import java.nio.file.Paths -import java.nio.file.StandardCopyOption - -installClientGeneratorIfNeeded() -val apiPath = Paths.get("test_api").toString() -val outputDirectory = Paths.get(apiPath, "src", "main", "java").toString() -val testingJsonInput = Paths.get("json", "testing_v1.json").toString() -Paths.get(apiPath, "src").toFile().deleteRecursively() -shell { - val generateLibraryCommand = "generate_library " + - "--input=$testingJsonInput " + - "--language=java " + - "--output_dir=$outputDirectory" - generateLibraryCommand() -} - -Files.move( - Paths.get(outputDirectory, "pom.xml"), - Paths.get(apiPath, "pom.xml"), - StandardCopyOption.REPLACE_EXISTING -) diff --git a/flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts b/flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts deleted file mode 100644 index 6839eb85c3..0000000000 --- a/flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts +++ /dev/null @@ -1,36 +0,0 @@ - -@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") -@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") -@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") - -@file:Import("../util/downloadFiles.main.kts") -@file:Import("../util/PathHelper.kt") -@file:Import("../util/downloadSoftware.main.kts") - -@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) - -import eu.jrie.jetbrains.kotlinshell.shell.shell -import java.nio.file.Paths - -private val jsonDirectoryPath = Paths.get(currentPath.toString(), "json") -val testingV1Path = Paths.get(jsonDirectoryPath.toString(), "testing_v1.json").toString() -val testingV1Beta3Path = Paths.get(jsonDirectoryPath.toString(), "toolresults_v1beta3.json").toString() - -jsonDirectoryPath.toFile().mkdir() - -downloadFile( - "https://raw.githubusercontent.com/Flank/gcloud_cli/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/testing_v1.json", - testingV1Path -) - -downloadFile( - "https://raw.githubusercontent.com/Flank/gcloud_cli/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/toolresults_v1beta3.json", - testingV1Beta3Path -) - -downloadSortJsonIfNeeded() - -shell { - "sort-json $testingV1Path"() - "sort-json $testingV1Beta3Path"() -} diff --git a/flank-bash/scripts/updateFlank.main.kts b/flank-bash/scripts/updateFlank.main.kts deleted file mode 100644 index ebb339b4fb..0000000000 --- a/flank-bash/scripts/updateFlank.main.kts +++ /dev/null @@ -1,24 +0,0 @@ -@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") -@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") -@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") - -@file:Import("util/GradleCommand.kt") -@file:Import("util/PathHelper.kt") - -@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") -@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) - -import eu.jrie.jetbrains.kotlinshell.shell.* -import java.nio.file.Path -import java.nio.file.Paths - -val flankDirectory: Path = Paths.get(rootDirectoryPathString, "test_runner") - -shell { - createGradleCommand( - workingDir = rootDirectoryPathString, - "-p", rootDirectoryPathString, ":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar")() -} - -Paths.get(flankDirectory.toString(), "build", "libs", "flank.jar").toFile() - .copyTo(Paths.get(flankDirectory.toString(), "bash", "flank.jar").toFile(), overwrite = true) diff --git a/flank-bash/scripts/updateLibs/updateAtomic.main.kts b/flank-bash/scripts/updateLibs/updateAtomic.main.kts deleted file mode 100644 index 124044a657..0000000000 --- a/flank-bash/scripts/updateLibs/updateAtomic.main.kts +++ /dev/null @@ -1,53 +0,0 @@ -@file:CompilerOptions("jvmTarget = '1.8'") - -@file:Import("../util/downloadFiles.main.kts") -@file:Import("../util/archive.main.kts") - -import java.nio.file.Files -import java.nio.file.Paths -import java.util.stream.Collectors - -private val currentPath = Paths.get("") -private val atomicPath = Paths.get(currentPath.toString(), "libatomic") - -fun updateAtomic() { - val atomicDeb = Paths.get(atomicPath.toString(), "libatomic.deb").toFile() - val atomicDataTarXz = Paths.get(atomicPath.toString(), "data.tar.xz").toFile() - - if (atomicDeb.exists()) { - println("Atomic exists") - } else { - println("Downloading Atomic...") - atomicPath.toFile().mkdirs() - downloadFile( - url = "http://mirrors.kernel.org/ubuntu/pool/main/g/gcc-8/libatomic1_8-20180414-1ubuntu2_amd64.deb", - destinationPath = atomicDeb.toString() - ) - } - - atomicDeb.extract(atomicPath.toFile(), "ar") - atomicDataTarXz.extract(atomicPath.toFile(), "tar", "xz") - findAndCopyLicense() - findAndCopyAtomicFiles() - atomicPath.toFile().deleteRecursively() -} - -fun findAndCopyLicense() { - val licenseOutputFile = Paths.get(currentPath.toString(), "libatomic.txt").toFile() - - downloadFile( - "http://changelogs.ubuntu.com/changelogs/pool/main/g/gcc-8/gcc-8_8-20180414-1ubuntu2/copyright", - licenseOutputFile.toString() - ) -} - -fun findAndCopyAtomicFiles() { - println("Copying atomic files ...") - val list = Files.walk(atomicPath) - .filter { it.toString().endsWith("libatomic.so.1") || it.toString().endsWith("libatomic.so.1.2.0") } - .collect(Collectors.toList()) - - list.forEach { - it.toFile().copyTo(Paths.get(currentPath.toString(), it.fileName.toString()).toFile(), true) - } -} diff --git a/flank-bash/scripts/updateLibs/updateBinaries.main.kts b/flank-bash/scripts/updateLibs/updateBinaries.main.kts deleted file mode 100644 index b7e1d26b7f..0000000000 --- a/flank-bash/scripts/updateLibs/updateBinaries.main.kts +++ /dev/null @@ -1,9 +0,0 @@ -@file:Import("updateAtomic.main.kts") -@file:Import("updateLlvm.main.kts") -@file:Import("updateSwift.main.kts") - -updateAtomic() -updateLlvm() -updateSwift() - -println("Binaries updated!") diff --git a/flank-bash/scripts/updateLibs/updateLlvm.main.kts b/flank-bash/scripts/updateLibs/updateLlvm.main.kts deleted file mode 100644 index 69a647ead8..0000000000 --- a/flank-bash/scripts/updateLibs/updateLlvm.main.kts +++ /dev/null @@ -1,77 +0,0 @@ -@file:CompilerOptions("jvmTarget = '1.8'") - -@file:Import("../util/downloadFiles.main.kts") -@file:Import("../util/archive.main.kts") -@file:Import("../util/OsHelper.kts") - -import java.nio.file.Files -import java.nio.file.Paths -import java.nio.file.StandardCopyOption - -private val currentPath = Paths.get("") -private val llvmPath = Paths.get(currentPath.toString(), "llvm") - -fun updateLlvmWindows() { - val llvmExe = Paths.get(llvmPath.toString(), "LLVM-win64.exe") - if (llvmExe.toFile().exists()) { - println("LLVM exists") - } else { - println("Downloading Windows LLVM...") - llvmPath.toFile().mkdirs() - downloadFile( - url = "https://releases.llvm.org/8.0.0/LLVM-8.0.0-win64.exe", - destinationPath = llvmExe.toString() - ) - } - - llvmExe.toFile().extract(llvmPath.toFile(), "zip", "xz") - findAndCopyLicense() - findAndCopyLlvmNmFile() - llvmPath.toFile().deleteRecursively() -} - -fun updateLlvmNonWindows() { - val llvmTarXz = Paths.get(llvmPath.toString(), "llvm.tar.xz") - - if (llvmTarXz.toFile().exists()) { - println("LLVM exists") - } else { - println("Downloading LLVM...") - llvmPath.toFile().mkdirs() - downloadFile( - url = "http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz", - destinationPath = llvmTarXz.toString() - ) - } - - llvmTarXz.toFile().extract(llvmPath.toFile(), "tar", "xz") - findAndCopyLicense() - findAndCopyLlvmNmFile() - llvmPath.toFile().deleteRecursively() -} - -fun updateLlvm() = if (isWindows) updateLlvmWindows() else updateLlvmNonWindows() - -fun findAndCopyLicense() { - val licensePathSuffix = Paths.get("include", "llvm", "Support", "LICENSE.TXT").toString() - val licenseOutputFile = Paths.get(currentPath.toString(), "llvm.txt").toFile() - - println("Copying license ...") - Files.walk(llvmPath) - .filter { it.toString().endsWith(licensePathSuffix) } - .findFirst() - .takeIf { it.isPresent } - ?.run { get().toFile().copyTo(licenseOutputFile, overwrite = true) } -} - -fun findAndCopyLlvmNmFile() { - val llvmNmSuffix = Paths.get("bin", "llvm-nm").toString() - val llvmNmOutputFile = Paths.get(currentPath.toString(), "nm").toFile() - - println("Copying llvm nm ...") - Files.walk(llvmPath) - .filter { it.toString().endsWith(llvmNmSuffix) } - .findFirst() - .takeIf { it.isPresent } - ?.run { get().toFile().copyTo(llvmNmOutputFile, overwrite = true) } -} diff --git a/flank-bash/scripts/updateLibs/updateSwift.main.kts b/flank-bash/scripts/updateLibs/updateSwift.main.kts deleted file mode 100644 index 6baee8afe3..0000000000 --- a/flank-bash/scripts/updateLibs/updateSwift.main.kts +++ /dev/null @@ -1,77 +0,0 @@ -@file:CompilerOptions("jvmTarget = '1.8'") - -@file:Import("../util/downloadFiles.main.kts") -@file:Import("../util/archive.main.kts") -@file:Import("../util/OsHelper.kts") - -import java.nio.file.Files -import java.nio.file.Paths - -private val currentPath = Paths.get("") -private val swiftPath = Paths.get(currentPath.toString(), "swift") - -fun updateSwiftWindows() { - val swiftExe = Paths.get(swiftPath.toString(), "swift.exe") - - if (swiftExe.toFile().exists()) { - println("Swift exists") - } else { - println("Downloading swift for Windows") - swiftPath.toFile().mkdirs() - downloadFile( - url = "https://swift.org/builds/swift-5.3-release/windows10/swift-5.3-RELEASE/swift-5.3-RELEASE-windows10.exe", - destinationPath = swiftExe.toString() - ) - } - - swiftExe.toFile().extract(swiftPath.toFile(), "zip", "gz") - findAndCopyLicense() - findAndCopySwiftDemangleFile() - swiftPath.toFile().deleteRecursively() -} - -fun updateSwiftOther() { - val swiftTarGz = Paths.get(swiftPath.toString(), "swift.tar.gz") - - if (swiftTarGz.toFile().exists()) { - println("Swift exists") - } else { - println("Downloading swift") - swiftPath.toFile().mkdirs() - downloadFile( - url = "https://swift.org/builds/swift-5.0.1-release/ubuntu1604/swift-5.0.1-RELEASE/swift-5.0.1-RELEASE-ubuntu16.04.tar.gz", - destinationPath = swiftTarGz.toString() - ) - } - - swiftTarGz.toFile().extract(swiftPath.toFile(), "tar", "gz") - findAndCopyLicense() - findAndCopySwiftDemangleFile() - swiftPath.toFile().deleteRecursively() -} - -fun updateSwift() = if (isWindows) updateSwiftWindows() else updateSwiftOther() - -fun findAndCopyLicense() { - val licenseFileSuffix = Paths.get("usr", "share", "swift", "LICENSE.txt").toString() - val licenseOutputFile = Paths.get(currentPath.toString(), "swift.txt").toFile() - - println("Copying license ...") - Files.walk(swiftPath) - .filter { it.toString().endsWith(licenseFileSuffix) } - .findFirst() - .takeIf { it.isPresent } - ?.run { get().toFile().copyTo(licenseOutputFile, overwrite = true) } -} - -fun findAndCopySwiftDemangleFile() { - val switftDemangleFileSuffix = Paths.get("usr", "bin", "swift-demangle").toString() - val switftDemangleOutputFile = Paths.get(currentPath.toString(), "swift-demangle").toFile() - - println("Copying swift-demangle ...") - Files.walk(swiftPath) - .filter { it.toString().endsWith(switftDemangleFileSuffix) } - .findFirst() - .takeIf { it.isPresent } - ?.run { get().toFile().copyTo(switftDemangleOutputFile, overwrite = true) } -} diff --git a/flank-bash/scripts/util/GradleCommand.kt b/flank-bash/scripts/util/GradleCommand.kt deleted file mode 100644 index c924ee8bdb..0000000000 --- a/flank-bash/scripts/util/GradleCommand.kt +++ /dev/null @@ -1,16 +0,0 @@ -import java.nio.file.Paths - -fun createGradleCommand( - workingDir: String, - vararg options: String -) = createGradleCommand(workingDir, options.asList()) - -fun createGradleCommand( - workingDir: String, - options: List -) = "${Paths.get(workingDir, gradleExecutable).toString()} ${options.joinToString(" ")}" - -private val gradleExecutable: String - get() = if (isWindows) "gradlew.bat" else "./gradlew" - -val isWindows = System.getProperty("os.name").startsWith("Windows") diff --git a/flank-bash/scripts/util/OsHelper.kts b/flank-bash/scripts/util/OsHelper.kts deleted file mode 100644 index 2bed72f57b..0000000000 --- a/flank-bash/scripts/util/OsHelper.kts +++ /dev/null @@ -1,3 +0,0 @@ -val isWindows = System.getProperty("os.name").startsWith("Windows") -val isMacOS = System.getProperty("os.name").indexOf("mac") >= 0 -val isLinux = !isWindows && !isMacOS diff --git a/flank-bash/scripts/util/PathHelper.kt b/flank-bash/scripts/util/PathHelper.kt deleted file mode 100644 index a39a049d07..0000000000 --- a/flank-bash/scripts/util/PathHelper.kt +++ /dev/null @@ -1,19 +0,0 @@ -import java.nio.file.Files -import java.nio.file.Paths -import java.nio.file.Path - -val currentPath = Paths.get("") -val rootDirectoryPath = goToRoot(currentPath) -val rootDirectoryFile = rootDirectoryPath.toFile() -val rootDirectoryPathString = rootDirectoryPath.toString() - -fun goToRoot(startPath: Path): Path = - if (startPath.isRoot()) startPath.toAbsolutePath() else goToRoot(startPath.toAbsolutePath().parent) - -fun Path.isRoot() = Files.exists(Paths.get(toString(), "settings.gradle.kts")) - -val testProjectsPath = Paths.get(rootDirectoryPathString, "test_projects").toString() -val androidTestProjectsPath = Paths.get(testProjectsPath, "android").toString() -val iOSTestProjectsPath = Paths.get(testProjectsPath, "ios").toString() -val flankFixturesTmpPath = - Paths.get(rootDirectoryPathString, "test_runner", "src", "test", "kotlin", "ftl", "fixtures", "tmp").toString() diff --git a/flank-bash/scripts/util/archive.main.kts b/flank-bash/scripts/util/archive.main.kts deleted file mode 100644 index 32c5ab58c8..0000000000 --- a/flank-bash/scripts/util/archive.main.kts +++ /dev/null @@ -1,56 +0,0 @@ -@file:Repository("https://repo1.maven.org/maven2/org/rauschig/jarchivelib/") -@file:DependsOn("org.rauschig:jarchivelib:1.1.0") -@file:DependsOn("org.tukaani:xz:1.0") - -import org.rauschig.jarchivelib.* -import java.io.File - -fun File.extract( - destination: File, - archiveFormat: ArchiveFormat = ArchiveFormat.AR, - compressFormat: CompressionType? = null -) { - println("Unpacking...$name") - val archiver = if (compressFormat != null) { - ArchiverFactory.createArchiver(archiveFormat, compressFormat) - } else { - ArchiverFactory.createArchiver(archiveFormat) - } - runCatching { - archiver.extract(this, destination) - }.onFailure { - println("There was an error when unpacking $name - $it") - } -} - -fun File.extract( - destination: File, - archiveFormat: String, - compressFormat: String? = null -) { - println("Unpacking...$name") - val archiver = if (compressFormat != null) { - ArchiverFactory.createArchiver(archiveFormat, compressFormat) - } else { - ArchiverFactory.createArchiver(archiveFormat) - } - runCatching { - archiver.extract(this, destination) - }.onFailure { - println("There was an error when unpacking $name - $it") - } -} - -fun List.archive( - destinationFileName: String, - destinationDirectory: File, - archiveFormat: ArchiveFormat = ArchiveFormat.ZIP -) { - println("Packing...$destinationFileName") - val archiver = ArchiverFactory.createArchiver(archiveFormat) - runCatching { - archiver.create(destinationFileName, destinationDirectory, *toTypedArray()) - }.onFailure { - println("There was an error when packing ${destinationDirectory.absolutePath}${File.separator}$destinationFileName - $it") - } -} diff --git a/flank-bash/scripts/util/downloadFiles.main.kts b/flank-bash/scripts/util/downloadFiles.main.kts deleted file mode 100644 index e27d2ff6ba..0000000000 --- a/flank-bash/scripts/util/downloadFiles.main.kts +++ /dev/null @@ -1,24 +0,0 @@ -@file:Repository("https://dl.bintray.com/kittinunf/maven/com/github/kittinunf/fuel/fuel/") -@file:DependsOn("com.github.kittinunf.fuel:fuel:2.3.0") -@file:DependsOn("com.github.kittinunf.fuel:fuel-coroutines:2.3.0") - -import com.github.kittinunf.fuel.Fuel -import java.io.File - -fun downloadFile( - url: String, - destinationPath: String -) { - println("Downloading from $url") - var lastUpdate = 0L - Fuel.download(url) - .fileDestination { _, _ -> File(destinationPath) } - .progress { readBytes, totalBytes -> - if (System.currentTimeMillis() - lastUpdate > 2000) { - lastUpdate = System.currentTimeMillis() - val progress = (readBytes.toFloat() / totalBytes.toFloat() * 100).toInt() - println("Bytes downloaded $readBytes / $totalBytes ($progress %)") - } - } - .response() -} diff --git a/flank-bash/scripts/util/downloadSoftware.main.kts b/flank-bash/scripts/util/downloadSoftware.main.kts deleted file mode 100644 index 1db0d59a2c..0000000000 --- a/flank-bash/scripts/util/downloadSoftware.main.kts +++ /dev/null @@ -1,65 +0,0 @@ -@file:Repository("https://dl.bintray.com/jakubriegel/kotlin-shell") -@file:DependsOn("eu.jrie.jetbrains:kotlin-shell-core:0.2.1") -@file:DependsOn("org.slf4j:slf4j-simple:1.7.28") -@file:Import("downloadFiles.main.kts") -@file:CompilerOptions("-Xopt-in=kotlin.RequiresOptIn") -@file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) - -import eu.jrie.jetbrains.kotlinshell.shell.Shell -import eu.jrie.jetbrains.kotlinshell.shell.shell -import java.nio.file.Path -import kotlin.system.exitProcess - -suspend fun Shell.commandExitCode(command: String) = runCatching { command().pcb.exitCode }.getOrDefault(1) - -fun checkAndInstall( - checkCommand: String, - install: suspend Shell.() -> Unit -) { - shell { - if (commandExitCode(checkCommand) != 0) { - install() - } - } -} - -fun downloadXcPrettyIfNeeded() { - checkAndInstall(checkCommand = "command -v xcpretty") { - "gem install xcpretty"() - } -} - -fun downloadCocoaPodsIfNeeded() { - checkAndInstall(checkCommand = "command -v xcpretty") { - "gem install cocoapods -v 1.9.3"() - } -} - -suspend fun Shell.installPods(path: Path) { - runCatching { "pod install --project-directory=$path --verbose"() } -} - -fun checkIfPipInstalled() { - shell { - if (commandExitCode("pip -V") != 0) { - println("You need pip fot this script. To install it follow https://pip.pypa.io/en/stable/installing/") - exitProcess(1) - } - } -} - -fun downloadSortJsonIfNeeded() { - checkAndInstall("sort-json") { - "npm -g install sort-json"() - } -} - -fun installClientGeneratorIfNeeded() { - val isWindows = System.getProperty("os.name").startsWith("Windows") - val generateLibraryCheckCommand = (if (isWindows) "where " else "command -v ") + "generate_library" - - checkAndInstall(generateLibraryCheckCommand) { - checkIfPipInstalled() - "pip install google-apis-client-generator"() - } -} From 17e1e4cb75296803e14a30098566d36b0b12865e Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Tue, 20 Oct 2020 18:43:03 +0200 Subject: [PATCH 77/95] fixed native scripts --- firebase_apis/generate_java_client.bat | 2 +- firebase_apis/generate_java_client.sh | 2 +- firebase_apis/update_api_json.bat | 2 +- firebase_apis/update_api_json.sh | 2 +- test_projects/gohello/build.bat | 2 +- test_projects/gohello/build.sh | 2 +- test_runner/bash/update_flank.bat | 2 +- test_runner/bash/update_flank.sh | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/firebase_apis/generate_java_client.bat b/firebase_apis/generate_java_client.bat index 2b1df39b91..2b96715d4f 100755 --- a/firebase_apis/generate_java_client.bat +++ b/firebase_apis/generate_java_client.bat @@ -1,2 +1,2 @@ SET DIR=%~dp0 -kotlin %DIR%\..\flank-bash\scripts\updateFirebaseApi\generateJavaClient.main.kts +kotlin %DIR%\..\..\flank-scripts\bash\flankScripts.bat shell firebase generate_java_client diff --git a/firebase_apis/generate_java_client.sh b/firebase_apis/generate_java_client.sh index 298797b1e2..9500ceadfb 100755 --- a/firebase_apis/generate_java_client.sh +++ b/firebase_apis/generate_java_client.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../flank-bash/scripts/updateFirebaseApi/generateJavaClient.main.kts +kotlin $DIR/../flank-scripts/bash/flankScripts.bat shell firebase generate_java_client diff --git a/firebase_apis/update_api_json.bat b/firebase_apis/update_api_json.bat index b06fb35ae5..ea965040f4 100755 --- a/firebase_apis/update_api_json.bat +++ b/firebase_apis/update_api_json.bat @@ -1,2 +1,2 @@ SET DIR=%~dp0 -kotlin %DIR%\..\flank-bash\scripts\updateFirebaseApi\updateApiJson.main.kts +kotlin %DIR%\..\..\flank-scripts\bash\flankScripts.bat shell firebase update_api_json diff --git a/firebase_apis/update_api_json.sh b/firebase_apis/update_api_json.sh index a034be4e70..acc0ab2275 100755 --- a/firebase_apis/update_api_json.sh +++ b/firebase_apis/update_api_json.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../flank-bash/scripts/updateFirebaseApi/updateApiJson.main.kts +kotlin $DIR/../flank-scripts/bash/flankScripts.bat shell firebase update_api_json diff --git a/test_projects/gohello/build.bat b/test_projects/gohello/build.bat index 7d8fafe676..0550ac2e19 100644 --- a/test_projects/gohello/build.bat +++ b/test_projects/gohello/build.bat @@ -1,2 +1,2 @@ SET DIR=%~dp0 -kotlin %DIR%\..\..\flank-bash\scripts\go.ops.main.kts build +kotlin %DIR%\..\..\flank-scripts\bash\flankScripts.bat shell ops go diff --git a/test_projects/gohello/build.sh b/test_projects/gohello/build.sh index 3c920dec5b..3e736fed52 100755 --- a/test_projects/gohello/build.sh +++ b/test_projects/gohello/build.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../../flank-bash/scripts/go.ops.main.kts build +kotlin $DIR/../../flank-scripts/bash/flankScripts.bat shell ops go diff --git a/test_runner/bash/update_flank.bat b/test_runner/bash/update_flank.bat index 2971d19d61..1da3d03741 100644 --- a/test_runner/bash/update_flank.bat +++ b/test_runner/bash/update_flank.bat @@ -1,2 +1,2 @@ SET DIR=%~dp0 -kotlin %DIR%\..\..\flank-bash\scripts\buildFlankScripts.main.kts +kotlin %DIR%\..\..\flank-scripts\bash\flankScripts.bat shell buildFlank diff --git a/test_runner/bash/update_flank.sh b/test_runner/bash/update_flank.sh index e24874b2ff..1125237b88 100755 --- a/test_runner/bash/update_flank.sh +++ b/test_runner/bash/update_flank.sh @@ -1,3 +1,3 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../../flank-bash/scripts/updateFlank.main.kts +kotlin $DIR/../../flank-scripts/bash/flankScripts.bat shell buildFlank From 5fbfc220dbc84c8ba03a151e3ae9fc60e168116a Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Wed, 21 Oct 2020 15:51:21 +0200 Subject: [PATCH 78/95] fix native scripts and descriptions --- firebase_apis/generate_java_client.sh | 2 +- firebase_apis/update_api_json.sh | 2 +- flank-scripts/bash/flankScripts.bat | 4 +++ .../shell/firebase/UpdateApiJsonCommand.kt | 2 +- .../flank/scripts/shell/ios/RunFtlLocal.kt | 2 +- .../scripts/shell/ios/UniversalFramework.kt | 2 +- .../scripts/shell/ops/AndroidOpsCommand.kt | 2 +- .../shell/updatebinaries/UpdateLlvm.kt | 9 ++++-- .../shell/updatebinaries/UpdateSwift.kt | 31 ++++++++++--------- test_projects/gohello/build.sh | 2 +- .../ios/EarlGreyExample/build_example.sh | 2 +- .../ios/EarlGreyExample/build_ftl.sh | 2 +- .../ios/EarlGreyExample/run_ftl_local.sh | 2 +- .../EarlGreyExample/universal_framework.sh | 2 +- test_runner/bash/update_flank.sh | 2 +- 15 files changed, 39 insertions(+), 29 deletions(-) diff --git a/firebase_apis/generate_java_client.sh b/firebase_apis/generate_java_client.sh index 9500ceadfb..f2806279d6 100755 --- a/firebase_apis/generate_java_client.sh +++ b/firebase_apis/generate_java_client.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../flank-scripts/bash/flankScripts.bat shell firebase generate_java_client +kotlin $DIR/../flank-scripts/bash/flankScripts shell firebase generate_java_client diff --git a/firebase_apis/update_api_json.sh b/firebase_apis/update_api_json.sh index acc0ab2275..6f3f9c81ea 100755 --- a/firebase_apis/update_api_json.sh +++ b/firebase_apis/update_api_json.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../flank-scripts/bash/flankScripts.bat shell firebase update_api_json +kotlin $DIR/../flank-scripts/bash/flankScripts shell firebase update_api_json diff --git a/flank-scripts/bash/flankScripts.bat b/flank-scripts/bash/flankScripts.bat index 8158f96d59..bed24e6664 100755 --- a/flank-scripts/bash/flankScripts.bat +++ b/flank-scripts/bash/flankScripts.bat @@ -1,4 +1,8 @@ SET DIR=%~dp0 SET scriptsJar=%DIR%\flankScripts.jar +if not exist "%scriptsJar%" { + %DIR%\buildFlankScripts.bat +} + java -jar "%scriptsJar%" %* diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/UpdateApiJsonCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/UpdateApiJsonCommand.kt index 3453ccb4bd..ddffeeac6a 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/UpdateApiJsonCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/UpdateApiJsonCommand.kt @@ -7,7 +7,7 @@ import flank.scripts.utils.downloadSortJsonIfNeeded import flank.scripts.utils.runCommand import java.nio.file.Paths -object UpdateApiJsonCommand : CliktCommand(name = "update_api_json", help = "Contains all firebase commands") { +object UpdateApiJsonCommand : CliktCommand(name = "update_api_json", help = "Download file for generating client") { override fun run() { val jsonDirectoryPath = Paths.get(currentPath.toString(), "json") val testingV1Path = Paths.get(jsonDirectoryPath.toString(), "testing_v1.json").toString() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt index 27c40b5134..01a8e46528 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt @@ -9,7 +9,7 @@ import flank.scripts.utils.runCommand import java.nio.file.Path import java.nio.file.Paths -object RunFtlLocalCommand : CliktCommand(name = "iosBuildFtl", help = "Build ftl ios app") { +object RunFtlLocalCommand : CliktCommand(name = "iosRunFtlLocal", help = "Run ftl locally ios app") { private val deviceId by option(help = "Pass device id. Please take it from Xcode -> Window -> Devices and Simulators") .required() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt index c024f4c735..d96be8649e 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt @@ -6,7 +6,7 @@ import flank.scripts.shell.utils.failIfWindows import flank.scripts.utils.runCommand import java.nio.file.Paths -object UniversalFrameworkCommand : CliktCommand(name = "iosUniversalFramework", help = "??") { +object UniversalFrameworkCommand : CliktCommand(name = "iosUniversalFramework", help = "Create Universal Framework") { override fun run() { failIfWindows() createUniversalFiles() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt index 177ff90b14..994a93bc04 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt @@ -11,7 +11,7 @@ import java.nio.file.Path import java.nio.file.Paths import java.nio.file.StandardCopyOption -object AndroidOpsCommand : CliktCommand(name = "android", help = "Build android apk's with test's") { +object AndroidOpsCommand : CliktCommand(name = "android", help = "Build android apks with tests") { override fun run() { buildBaseApk() buildBaseTestApk() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateLlvm.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateLlvm.kt index 1b70f1d9bd..4e652d8312 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateLlvm.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateLlvm.kt @@ -12,7 +12,10 @@ private val llvmPath = Paths.get(currentPath.toString(), "llvm") fun updateLlvm() = if (isWindows) updateLlvmWindows() else updateLlvmNonWindows() private fun updateLlvmWindows() { - val llvmExe = Paths.get(llvmPath.toString(), "LLVM-win64.exe") + println(" Will be available after #1134") + /* + TODO finish this in #1134 + val llvmExe = Paths.get(llvmPath.toString(), "LLVM-win64.exe") if (llvmExe.toFile().exists()) { println("LLVM exists") } else { @@ -27,7 +30,7 @@ private fun updateLlvmWindows() { llvmExe.toFile().extract(llvmPath.toFile(), "zip", "xz") findAndCopyLlvmLicense() findAndCopyLlvmNmFile() - llvmPath.toFile().deleteRecursively() + llvmPath.toFile().deleteRecursively()*/ } private fun updateLlvmNonWindows() { @@ -46,7 +49,7 @@ private fun updateLlvmNonWindows() { llvmTarXz.toFile().extract(llvmPath.toFile(), "tar", "xz") findAndCopyLlvmLicense() - findAndCopyLlvmLicense() + findAndCopyLlvmNmFile() llvmPath.toFile().deleteRecursively() } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateSwift.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateSwift.kt index 0d63167a2b..fe109b2734 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateSwift.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateSwift.kt @@ -12,23 +12,26 @@ private val swiftPath = Paths.get(currentPath.toString(), "swift") fun updateSwift() = if (isWindows) updateSwiftWindows() else updateSwiftOther() private fun updateSwiftWindows() { + println(" Will be available after #1134") + /* + TODO finish this in #1134 val swiftExe = Paths.get(swiftPath.toString(), "swift.exe") - if (swiftExe.toFile().exists()) { - println("Swift exists") - } else { - println("Downloading swift for Windows") - swiftPath.toFile().mkdirs() - downloadFile( - srcUrl = "https://swift.org/builds/swift-5.3-release/windows10/swift-5.3-RELEASE/swift-5.3-RELEASE-windows10.exe", - destinationPath = swiftExe.toString() - ) - } + if (swiftExe.toFile().exists()) { + println("Swift exists") + } else { + println("Downloading swift for Windows") + swiftPath.toFile().mkdirs() + downloadFile( + srcUrl = "https://swift.org/builds/swift-5.3-release/windows10/swift-5.3-RELEASE/swift-5.3-RELEASE-windows10.exe", + destinationPath = swiftExe.toString() + ) + } - swiftExe.toFile().extract(swiftPath.toFile(), "zip", "gz") - findAndCopySwiftLicense() - findAndCopySwiftDemangleFile() - swiftPath.toFile().deleteRecursively() + swiftExe.toFile().extract(swiftPath.toFile(), "zip", "gz") + findAndCopySwiftLicense() + findAndCopySwiftDemangleFile() + swiftPath.toFile().deleteRecursively()*/ } private fun updateSwiftOther() { diff --git a/test_projects/gohello/build.sh b/test_projects/gohello/build.sh index 3e736fed52..e056e8fefb 100755 --- a/test_projects/gohello/build.sh +++ b/test_projects/gohello/build.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../../flank-scripts/bash/flankScripts.bat shell ops go +kotlin $DIR/../../flank-scripts/bash/flankScripts shell ops go diff --git a/test_projects/ios/EarlGreyExample/build_example.sh b/test_projects/ios/EarlGreyExample/build_example.sh index 7626b91dc2..2faf8cb419 100755 --- a/test_projects/ios/EarlGreyExample/build_example.sh +++ b/test_projects/ios/EarlGreyExample/build_example.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../../../flank-bash/scripts/ios/buildExample.main.kts +kotlin $DIR/../flank-scripts/bash/flankScripts shell iosBuildExample diff --git a/test_projects/ios/EarlGreyExample/build_ftl.sh b/test_projects/ios/EarlGreyExample/build_ftl.sh index 40cb3ab2aa..61e7829247 100755 --- a/test_projects/ios/EarlGreyExample/build_ftl.sh +++ b/test_projects/ios/EarlGreyExample/build_ftl.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../../../flank-bash/scripts/ios/buildFtl.main.kts +kotlin $DIR/../flank-scripts/bash/flankScripts shell iosBuildFtl diff --git a/test_projects/ios/EarlGreyExample/run_ftl_local.sh b/test_projects/ios/EarlGreyExample/run_ftl_local.sh index 768b6f8edb..9cef501702 100755 --- a/test_projects/ios/EarlGreyExample/run_ftl_local.sh +++ b/test_projects/ios/EarlGreyExample/run_ftl_local.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../../../flank-bash/scripts/ios/runFtlLocal.main.kts +kotlin $DIR/../flank-scripts/bash/flankScripts shell iosRunFtlLocal diff --git a/test_projects/ios/EarlGreyExample/universal_framework.sh b/test_projects/ios/EarlGreyExample/universal_framework.sh index 10cd25e27d..bb72a94f7a 100755 --- a/test_projects/ios/EarlGreyExample/universal_framework.sh +++ b/test_projects/ios/EarlGreyExample/universal_framework.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../../../flank-bash/scripts/ios/universalFramework.main.kts +kotlin $DIR/../flank-scripts/bash/flankScripts shell iosUniversalFramework diff --git a/test_runner/bash/update_flank.sh b/test_runner/bash/update_flank.sh index 1125237b88..93dd8d4b84 100755 --- a/test_runner/bash/update_flank.sh +++ b/test_runner/bash/update_flank.sh @@ -1,3 +1,3 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../../flank-scripts/bash/flankScripts.bat shell buildFlank +kotlin $DIR/../../flank-scripts/bash/flankScripts shell buildFlank From 0b57eb9c7c621ba63ae48884a1bae0c53cf73be4 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Wed, 21 Oct 2020 16:55:01 +0200 Subject: [PATCH 79/95] update documentation --- docs/development_kotlin_scripts.md | 15 ----- firebase_apis/generate_java_client.bat | 2 +- firebase_apis/generate_java_client.sh | 2 +- firebase_apis/update_api_json.bat | 2 +- firebase_apis/update_api_json.sh | 2 +- flank-scripts/README.md | 59 +++++++++++++++++++ .../firebase/GenerateJavaClientCommand.kt | 2 +- .../shell/firebase/UpdateApiJsonCommand.kt | 2 +- mkdocs.yml | 1 - 9 files changed, 65 insertions(+), 22 deletions(-) delete mode 100644 docs/development_kotlin_scripts.md diff --git a/docs/development_kotlin_scripts.md b/docs/development_kotlin_scripts.md deleted file mode 100644 index 1306bac409..0000000000 --- a/docs/development_kotlin_scripts.md +++ /dev/null @@ -1,15 +0,0 @@ -# Development kotlin scripts hints - -Sometimes kotlin scrips keep cached scripts even if you modify the source to prevent it you could: - -1. Set env variable for ```KOTLIN_MAIN_KTS_COMPILED_SCRIPTS_CACHE_DIR``` -1. Run script with additional commands - -```bash - -rm -d -r $KOTLIN_MAIN_KTS_COMPILED_SCRIPTS_CACHE_DIR && mkdir $KOTLIN_MAIN_KTS_COMPILED_SCRIPTS_CACHE_DIR && kotlin {SCRIPT_FILE_NAME} - -``` - -This command remove all cached scripts and make fresh run - diff --git a/firebase_apis/generate_java_client.bat b/firebase_apis/generate_java_client.bat index 2b96715d4f..67d22412f2 100755 --- a/firebase_apis/generate_java_client.bat +++ b/firebase_apis/generate_java_client.bat @@ -1,2 +1,2 @@ SET DIR=%~dp0 -kotlin %DIR%\..\..\flank-scripts\bash\flankScripts.bat shell firebase generate_java_client +kotlin %DIR%\..\..\flank-scripts\bash\flankScripts.bat shell firebase generateJavaClient diff --git a/firebase_apis/generate_java_client.sh b/firebase_apis/generate_java_client.sh index f2806279d6..5143190d6a 100755 --- a/firebase_apis/generate_java_client.sh +++ b/firebase_apis/generate_java_client.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../flank-scripts/bash/flankScripts shell firebase generate_java_client +kotlin $DIR/../flank-scripts/bash/flankScripts shell firebase generateJavaClient diff --git a/firebase_apis/update_api_json.bat b/firebase_apis/update_api_json.bat index ea965040f4..8af5715400 100755 --- a/firebase_apis/update_api_json.bat +++ b/firebase_apis/update_api_json.bat @@ -1,2 +1,2 @@ SET DIR=%~dp0 -kotlin %DIR%\..\..\flank-scripts\bash\flankScripts.bat shell firebase update_api_json +kotlin %DIR%\..\..\flank-scripts\bash\flankScripts.bat shell firebase updateApiJson diff --git a/firebase_apis/update_api_json.sh b/firebase_apis/update_api_json.sh index 6f3f9c81ea..561bff2497 100755 --- a/firebase_apis/update_api_json.sh +++ b/firebase_apis/update_api_json.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../flank-scripts/bash/flankScripts shell firebase update_api_json +kotlin $DIR/../flank-scripts/bash/flankScripts shell firebase updateApiJson diff --git a/flank-scripts/README.md b/flank-scripts/README.md index 79c736387b..8221260777 100644 --- a/flank-scripts/README.md +++ b/flank-scripts/README.md @@ -163,3 +163,62 @@ All [testArtifacts](../flank-scripts/src/main/kotlin/flank/scripts/testartifacts #### `resolve` Automatically prepare local artifacts if needed. +### Shell + +To show all available commands for shell use: `flankScripts shell` + +Available commands are: + - `firebase` Contains all firebase commands + - `iosBuildExample` Build example ios app + - `iosBuildFtl` Build ftl ios app + - `iosRunFtlLocal` Run ftl locally ios app + - `iosUniversalFramework` Create Universal Framework + - `ops` Contains all ops command: android, ios, gp + - `updateBinaries` Update binaries used by Flank + - `buildFlank` Build Flank + +#### `firebase` + +Contains tasks related to firebase client generation. +These tasks are : + - `updateApiJson` Download file for generating client + - `generateJavaClient` Generates Java client + +##### `updateApiJson` +Download file for generating client + +##### `generateJavaClient` +Generate Java Client from json schema + +#### `iosBuildExample` +Build example ios app + +#### `iosBuildFtl` +Build ftl ios app + +#### `iosRunFtlLocal` +Run ftl locally ios app + +#### `iosUniversalFramework` + +#### `ops` +Contains tasks related to building sample apps with tests. +These tasks are : + - `go` Build go app with tests + - `ios` Build ios app with tests + - `android` Build android apks with tests + +##### `go` +Build go app with tests + +##### `ios` +Build ios app with tests + +##### `android` +Build android apks with tests + +#### `updateBinaries` +Update binaries used by Flank + +#### `buildFlank` +Build Flank test runner diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClientCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClientCommand.kt index 2c331533f0..ff7f1ddee5 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClientCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/GenerateJavaClientCommand.kt @@ -9,7 +9,7 @@ import java.nio.file.Files import java.nio.file.Paths import java.nio.file.StandardCopyOption -object GenerateJavaClientCommand : CliktCommand(name = "generate_java_client", help = "Generate Java Client") { +object GenerateJavaClientCommand : CliktCommand(name = "generateJavaClient", help = "Generate Java Client") { override fun run() { checkIfPipInstalled() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/UpdateApiJsonCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/UpdateApiJsonCommand.kt index ddffeeac6a..831bfa5a79 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/UpdateApiJsonCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/UpdateApiJsonCommand.kt @@ -7,7 +7,7 @@ import flank.scripts.utils.downloadSortJsonIfNeeded import flank.scripts.utils.runCommand import java.nio.file.Paths -object UpdateApiJsonCommand : CliktCommand(name = "update_api_json", help = "Download file for generating client") { +object UpdateApiJsonCommand : CliktCommand(name = "updateApiJson", help = "Download file for generating client") { override fun run() { val jsonDirectoryPath = Paths.get(currentPath.toString(), "json") val testingV1Path = Paths.get(jsonDirectoryPath.toString(), "testing_v1.json").toString() diff --git a/mkdocs.yml b/mkdocs.yml index 1567f63522..ac2083f114 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -35,7 +35,6 @@ nav: - Dependencies update: dependencies_update_process.md - Secrets: flank_secrets.md - Releasing: release_process.md - - Kotlin scripts hints: development_kotlin_scripts.md theme: name: material From 4cabf5ac8ed4ab7f17bd11bd6889612baa076486 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Wed, 21 Oct 2020 17:09:14 +0200 Subject: [PATCH 80/95] fix scripts --- firebase_apis/generate_java_client.bat | 2 +- firebase_apis/generate_java_client.sh | 2 +- firebase_apis/update_api_json.bat | 2 +- firebase_apis/update_api_json.sh | 2 +- flank-scripts/README.md | 4 ++++ .../src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt | 2 +- test_projects/gohello/build.bat | 2 +- test_projects/gohello/build.sh | 2 +- test_projects/ios/EarlGreyExample/build_example.sh | 2 +- test_projects/ios/EarlGreyExample/build_ftl.sh | 2 +- test_projects/ios/EarlGreyExample/run_ftl_local.sh | 2 +- test_projects/ios/EarlGreyExample/universal_framework.sh | 2 +- test_runner/bash/update_flank.bat | 2 +- test_runner/bash/update_flank.sh | 2 +- 14 files changed, 17 insertions(+), 13 deletions(-) diff --git a/firebase_apis/generate_java_client.bat b/firebase_apis/generate_java_client.bat index 67d22412f2..7b27596f9d 100755 --- a/firebase_apis/generate_java_client.bat +++ b/firebase_apis/generate_java_client.bat @@ -1,2 +1,2 @@ SET DIR=%~dp0 -kotlin %DIR%\..\..\flank-scripts\bash\flankScripts.bat shell firebase generateJavaClient +%DIR%\..\..\flank-scripts\bash\flankScripts.bat shell firebase generateJavaClient diff --git a/firebase_apis/generate_java_client.sh b/firebase_apis/generate_java_client.sh index 5143190d6a..1ed7797d25 100755 --- a/firebase_apis/generate_java_client.sh +++ b/firebase_apis/generate_java_client.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../flank-scripts/bash/flankScripts shell firebase generateJavaClient +$DIR/../flank-scripts/bash/flankScripts shell firebase generateJavaClient diff --git a/firebase_apis/update_api_json.bat b/firebase_apis/update_api_json.bat index 8af5715400..1de7925542 100755 --- a/firebase_apis/update_api_json.bat +++ b/firebase_apis/update_api_json.bat @@ -1,2 +1,2 @@ SET DIR=%~dp0 -kotlin %DIR%\..\..\flank-scripts\bash\flankScripts.bat shell firebase updateApiJson +%DIR%\..\..\flank-scripts\bash\flankScripts.bat shell firebase updateApiJson diff --git a/firebase_apis/update_api_json.sh b/firebase_apis/update_api_json.sh index 561bff2497..a07105b5b1 100755 --- a/firebase_apis/update_api_json.sh +++ b/firebase_apis/update_api_json.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../flank-scripts/bash/flankScripts shell firebase updateApiJson +$DIR/../flank-scripts/bash/flankScripts shell firebase updateApiJson diff --git a/flank-scripts/README.md b/flank-scripts/README.md index 8221260777..2a7a3a75d3 100644 --- a/flank-scripts/README.md +++ b/flank-scripts/README.md @@ -199,6 +199,10 @@ Build ftl ios app #### `iosRunFtlLocal` Run ftl locally ios app +| Option | Description | +|-------------|--------------------------------------------------------------------------| +| --device-id | Device id. Please take it from Xcode -> Window -> Devices and Simulators | + #### `iosUniversalFramework` #### `ops` diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt index 01a8e46528..ff20f624ab 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt @@ -11,7 +11,7 @@ import java.nio.file.Paths object RunFtlLocalCommand : CliktCommand(name = "iosRunFtlLocal", help = "Run ftl locally ios app") { - private val deviceId by option(help = "Pass device id. Please take it from Xcode -> Window -> Devices and Simulators") + private val deviceId by option(help = "Device id. Please take it from Xcode -> Window -> Devices and Simulators") .required() override fun run() { diff --git a/test_projects/gohello/build.bat b/test_projects/gohello/build.bat index 0550ac2e19..2955f93675 100644 --- a/test_projects/gohello/build.bat +++ b/test_projects/gohello/build.bat @@ -1,2 +1,2 @@ SET DIR=%~dp0 -kotlin %DIR%\..\..\flank-scripts\bash\flankScripts.bat shell ops go +%DIR%\..\..\flank-scripts\bash\flankScripts.bat shell ops go diff --git a/test_projects/gohello/build.sh b/test_projects/gohello/build.sh index e056e8fefb..33510f858f 100755 --- a/test_projects/gohello/build.sh +++ b/test_projects/gohello/build.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../../flank-scripts/bash/flankScripts shell ops go +$DIR/../../flank-scripts/bash/flankScripts shell ops go diff --git a/test_projects/ios/EarlGreyExample/build_example.sh b/test_projects/ios/EarlGreyExample/build_example.sh index 2faf8cb419..54ce63a89e 100755 --- a/test_projects/ios/EarlGreyExample/build_example.sh +++ b/test_projects/ios/EarlGreyExample/build_example.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../flank-scripts/bash/flankScripts shell iosBuildExample +$DIR/../flank-scripts/bash/flankScripts shell iosBuildExample diff --git a/test_projects/ios/EarlGreyExample/build_ftl.sh b/test_projects/ios/EarlGreyExample/build_ftl.sh index 61e7829247..f2cdb7f3c3 100755 --- a/test_projects/ios/EarlGreyExample/build_ftl.sh +++ b/test_projects/ios/EarlGreyExample/build_ftl.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../flank-scripts/bash/flankScripts shell iosBuildFtl +$DIR/../flank-scripts/bash/flankScripts shell iosBuildFtl diff --git a/test_projects/ios/EarlGreyExample/run_ftl_local.sh b/test_projects/ios/EarlGreyExample/run_ftl_local.sh index 9cef501702..c81d9a56e5 100755 --- a/test_projects/ios/EarlGreyExample/run_ftl_local.sh +++ b/test_projects/ios/EarlGreyExample/run_ftl_local.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../flank-scripts/bash/flankScripts shell iosRunFtlLocal +$DIR/../flank-scripts/bash/flankScripts shell iosRunFtlLocal diff --git a/test_projects/ios/EarlGreyExample/universal_framework.sh b/test_projects/ios/EarlGreyExample/universal_framework.sh index bb72a94f7a..cec365d10a 100755 --- a/test_projects/ios/EarlGreyExample/universal_framework.sh +++ b/test_projects/ios/EarlGreyExample/universal_framework.sh @@ -1,2 +1,2 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../flank-scripts/bash/flankScripts shell iosUniversalFramework +$DIR/../flank-scripts/bash/flankScripts shell iosUniversalFramework diff --git a/test_runner/bash/update_flank.bat b/test_runner/bash/update_flank.bat index 1da3d03741..6a5e4d0489 100644 --- a/test_runner/bash/update_flank.bat +++ b/test_runner/bash/update_flank.bat @@ -1,2 +1,2 @@ SET DIR=%~dp0 -kotlin %DIR%\..\..\flank-scripts\bash\flankScripts.bat shell buildFlank +%DIR%\..\..\flank-scripts\bash\flankScripts.bat shell buildFlank diff --git a/test_runner/bash/update_flank.sh b/test_runner/bash/update_flank.sh index 93dd8d4b84..9090fbd33c 100755 --- a/test_runner/bash/update_flank.sh +++ b/test_runner/bash/update_flank.sh @@ -1,3 +1,3 @@ DIR=`dirname "$BASH_SOURCE"` -kotlin $DIR/../../flank-scripts/bash/flankScripts shell buildFlank +$DIR/../../flank-scripts/bash/flankScripts shell buildFlank From 9fad9d2e5b431e5ec973972404555d08487bd94e Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 21 Oct 2020 17:39:05 +0200 Subject: [PATCH 81/95] Add --copy --generate --artifacts options --- .../scripts/shell/ops/AndroidOpsCommand.kt | 156 +++++++++++------- .../flank/scripts/shell/ops/IosOpsCommand.kt | 11 +- test_projects/ops.sh | 18 +- 3 files changed, 114 insertions(+), 71 deletions(-) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt index 994a93bc04..cb17c47e62 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt @@ -1,6 +1,9 @@ package flank.scripts.shell.ops import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.parameters.options.flag +import com.github.ajalt.clikt.parameters.options.multiple +import com.github.ajalt.clikt.parameters.options.option import flank.scripts.shell.utils.androidTestProjectsPath import flank.scripts.shell.utils.createGradleCommand import flank.scripts.shell.utils.flankFixturesTmpPath @@ -12,87 +15,124 @@ import java.nio.file.Paths import java.nio.file.StandardCopyOption object AndroidOpsCommand : CliktCommand(name = "android", help = "Build android apks with tests") { + + private val generate: Boolean by option().flag("-g", default = true) + + private val copy: Boolean by option().flag("-c", default = true) + + private val artifacts: List by option().multiple() + override fun run() { + if (generate.not()) return buildBaseApk() buildBaseTestApk() buildDuplicatedNamesApks() buildMultiModulesApks() buildCucumberSampleApp() } -} -private fun buildBaseApk() { - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, "app:assemble") - ).runCommand() + private fun buildBaseApk() { + if (artifacts.canExecute("buildBaseApk").not()) return - val outputDir = Paths.get(flankFixturesTmpPath, "apk", "app-debug.apk") + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, "app:assemble") + ).runCommand() - if (!outputDir.parent.toFile().exists()) Files.createDirectories(outputDir.parent) + if (copy) copyBaseApk() + } - val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "singleSuccess", "debug", "app-single-success-debug.apk") - Files.copy(assembleDirectory, outputDir, StandardCopyOption.REPLACE_EXISTING) -} + private fun copyBaseApk() { + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "app-debug.apk") -private fun buildBaseTestApk() { - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, "app:assembleAndroidTest") - ).runCommand() + if (!outputDir.parent.toFile().exists()) Files.createDirectories(outputDir.parent) - val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "androidTest") - assembleDirectory.toFile().findApks().forEach { - Files.copy(it.toPath(), Paths.get(flankFixturesTmpPath, "apk", it.name), StandardCopyOption.REPLACE_EXISTING) + val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "singleSuccess", "debug", "app-single-success-debug.apk") + Files.copy(assembleDirectory, outputDir, StandardCopyOption.REPLACE_EXISTING) } -} -private fun buildDuplicatedNamesApks() { - val modules = (0..3).map { "dir$it" } + private fun buildBaseTestApk() { + if (artifacts.canExecute("buildBaseTestApk").not()) return + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, "app:assembleAndroidTest") + ).runCommand() - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath) + modules.map { "$it:testModule:assembleAndroidTest" }.toList() - ).runCommand() - - val outputDir = Paths.get(flankFixturesTmpPath, "apk", "duplicated_names") - if (!outputDir.toFile().exists()) Files.createDirectories(outputDir) + if (copy) copyBaseTestApk() + } - modules.map { Paths.get(androidTestProjectsPath, it, "testModule", "build", "outputs", "apk").toFile() } - .flatMap { it.findApks().toList() } - .forEachIndexed { index, file -> - file.copyApkToDirectory(Paths.get(outputDir.toString(), modules[index], file.name)) + private fun copyBaseTestApk() { + val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "androidTest") + assembleDirectory.toFile().findApks().forEach { + Files.copy(it.toPath(), Paths.get(flankFixturesTmpPath, "apk", it.name), StandardCopyOption.REPLACE_EXISTING) } -} + } -private fun File.copyApkToDirectory(output: Path): Path = toPath().let { sourceFile -> - if (!output.parent.toFile().exists()) Files.createDirectories(output.parent) - Files.copy(sourceFile, output, StandardCopyOption.REPLACE_EXISTING) -} + private fun buildDuplicatedNamesApks() { + if (artifacts.canExecute("buildDuplicatedNamesApks").not()) return + val modules = (0..3).map { "dir$it" } -private fun buildMultiModulesApks() { - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, - ":multi-modules:multiapp:assemble") + (1..20).map { ":multi-modules:testModule$it:assembleAndroidTest" }).runCommand() + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath) + modules.map { "$it:testModule:assembleAndroidTest" }.toList() + ).runCommand() - val outputDir = Paths.get(flankFixturesTmpPath, "apk", "multi-modules").toString() - Paths.get(androidTestProjectsPath, "multi-modules").toFile().findApks() - .forEach { it.copyApkToDirectory(Paths.get(outputDir, it.name)) } -} + if (copy) copyDuplicatedNamesApks() + } -private fun buildCucumberSampleApp() { - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, "cucumber_sample_app:cukeulator:assembleDebug", ":cucumber_sample_app:cukeulator:assembleAndroidTest") - ).runCommand() + private fun copyDuplicatedNamesApks() { + val modules = (0..3).map { "dir$it" } + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "duplicated_names") + if (!outputDir.toFile().exists()) Files.createDirectories(outputDir) - val outputDir = Paths.get(flankFixturesTmpPath, "apk", "cucumber_sample_app").toString() - Paths.get(androidTestProjectsPath, "cucumber_sample_app").toFile().findApks().copyApksToPath(outputDir) -} + modules.map { Paths.get(androidTestProjectsPath, it, "testModule", "build", "outputs", "apk").toFile() } + .flatMap { it.findApks().toList() } + .forEachIndexed { index, file -> + file.copyApkToDirectory(Paths.get(outputDir.toString(), modules[index], file.name)) + } + } + + private fun File.copyApkToDirectory(output: Path): Path = toPath().let { sourceFile -> + if (!output.parent.toFile().exists()) Files.createDirectories(output.parent) + Files.copy(sourceFile, output, StandardCopyOption.REPLACE_EXISTING) + } + + private fun buildMultiModulesApks() { + if (artifacts.canExecute("buildMultiModulesApks").not()) return + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, + ":multi-modules:multiapp:assemble") + (1..20).map { ":multi-modules:testModule$it:assembleAndroidTest" }).runCommand() + + if (copy) copyMultiModulesApks() + } + + private fun copyMultiModulesApks() { + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "multi-modules").toString() + Paths.get(androidTestProjectsPath, "multi-modules").toFile().findApks() + .forEach { it.copyApkToDirectory(Paths.get(outputDir, it.name)) } + } -private fun File.findApks() = walk().filter { it.extension == "apk" } + private fun buildCucumberSampleApp() { + if (artifacts.canExecute("buildMultiModulesApks").not()) return + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, "cucumber_sample_app:cukeulator:assembleDebug", ":cucumber_sample_app:cukeulator:assembleAndroidTest") + ).runCommand() + + if (copy) copyCucumberSampleApp() + } + + private fun copyCucumberSampleApp() { + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "cucumber_sample_app").toString() + Paths.get(androidTestProjectsPath, "cucumber_sample_app").toFile().findApks().copyApksToPath(outputDir) + } + + private fun File.findApks() = walk().filter { it.extension == "apk" } + + private fun Sequence.copyApksToPath(outputDirectory: String) = forEach { + it.copyApkToDirectory(Paths.get(outputDirectory, it.name)) + } -private fun Sequence.copyApksToPath(outputDirectory: String) = forEach { - it.copyApkToDirectory(Paths.get(outputDirectory, it.name)) + private fun List.canExecute(actionName: String) = isEmpty() || any { it.toLowerCase() == actionName.toLowerCase() } } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt index ea28a2e55a..8200ce11e2 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt @@ -1,6 +1,8 @@ package flank.scripts.shell.ops import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.parameters.options.flag +import com.github.ajalt.clikt.parameters.options.option import flank.scripts.shell.ios.createIosBuildCommand import flank.scripts.shell.utils.failIfWindows import flank.scripts.shell.utils.flankFixturesTmpPath @@ -21,6 +23,11 @@ enum class TestType { } object IosOpsCommand : CliktCommand(name = "ios", help = "Build ios app with tests") { + + private val generate: Boolean by option().flag("-g", default = true) + + private val copy: Boolean by option().flag("-c", default = true) + override fun run() { failIfWindows() generateIos() @@ -32,7 +39,7 @@ object IosOpsCommand : CliktCommand(name = "ios", help = "Build ios app with tes downloadXcPrettyIfNeeded() createDirectoryInFixture(directoryName = "objc") createDirectoryInFixture(directoryName = "swift") - buildEarlGreyExample() + if (generate) buildEarlGreyExample() } private fun createDirectoryInFixture(directoryName: String): Path = @@ -70,7 +77,7 @@ object IosOpsCommand : CliktCommand(name = "ios", help = "Build ios app with tes else it.copyTo(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) } - private fun Path.copyTestFiles() = toString().let { productsDirectory -> + private fun Path.copyTestFiles() = toString().takeIf { copy }?.let { productsDirectory -> val pluginsDirectory = arrayOf("Debug-iphoneos", "EarlGreyExampleSwift.app", "PlugIns") copyTestFile(productsDirectory, pluginsDirectory, EARL_GREY_EXAMPLE_TESTS, TestType.OBJECTIVE_C) copyTestFile(productsDirectory, pluginsDirectory, EARL_GREY_EXAMPLE_SWIFT_TESTS, TestType.SWIFT) diff --git a/test_projects/ops.sh b/test_projects/ops.sh index 2aaf4a4c36..2aef719e70 100755 --- a/test_projects/ops.sh +++ b/test_projects/ops.sh @@ -1,31 +1,27 @@ #!/usr/bin/env bash -TEST_PROJECTS_ANDROID="$TEST_PROJECTS/android" -TEST_PROJECTS_IOS="$TEST_PROJECTS/ios" - -. "$TEST_PROJECTS_ANDROID/ops.sh" -. "$TEST_PROJECTS_IOS/EarlGreyExample/ops.sh" +DIR=`dirname "$BASH_SOURCE"` function update_test_artifacts() { for arg in "$@"; do case "$arg" in android) - base_app_apk --generate --copy - base_test_apks --generate --copy + $DIR/../flank-scripts/bash/flankScripts shell ops android --copy --generate ;; ios) - setup_ios_env - earl_grey_example --generate --copy + kotlin $DIR/../flank-scripts/bash/flankScripts shell ops ios --copy --generate ;; go) - cp -R "$FLANK_ROOT/test_projects/gohello" "$FLANK_FIXTURES_TMP/" + kotlin $DIR/../flank-scripts/bash/flankScripts shell ops go --copy --generate ;; all) - update_test_artifacts android ios go + kotlin $DIR/../flank-scripts/bash/flankScripts shell ops android --copy --generate + kotlin $DIR/../flank-scripts/bash/flankScripts shell ops ios --copy --generate + kotlin $DIR/../flank-scripts/bash/flankScripts shell ops go --copy --generate ;; esac done From 615edcee903a7563f2e011f08756fd307b471245 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Wed, 21 Oct 2020 17:44:58 +0200 Subject: [PATCH 82/95] update documentation for ops --- flank-scripts/README.md | 10 ++++++++++ .../flank/scripts/shell/ops/AndroidOpsCommand.kt | 4 ++-- .../kotlin/flank/scripts/shell/ops/IosOpsCommand.kt | 4 ++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/flank-scripts/README.md b/flank-scripts/README.md index 2a7a3a75d3..09fc0ad607 100644 --- a/flank-scripts/README.md +++ b/flank-scripts/README.md @@ -218,9 +218,19 @@ Build go app with tests ##### `ios` Build ios app with tests +| Option | Short option | Description | +|------------|--------------|--------------------------| +| --generate | -g | Make build | +| --copy | -c | Copy output files to tmp | + ##### `android` Build android apks with tests +| Option | Short option | Description | +|------------|--------------|--------------------------| +| --generate | -g | Make build | +| --copy | -c | Copy output files to tmp | + #### `updateBinaries` Update binaries used by Flank diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt index cb17c47e62..04f8aa89d2 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt @@ -16,9 +16,9 @@ import java.nio.file.StandardCopyOption object AndroidOpsCommand : CliktCommand(name = "android", help = "Build android apks with tests") { - private val generate: Boolean by option().flag("-g", default = true) + private val generate: Boolean by option(help = "Make build").flag("-g", default = true) - private val copy: Boolean by option().flag("-c", default = true) + private val copy: Boolean by option(help = "Copy output files to tmp").flag("-c", default = true) private val artifacts: List by option().multiple() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt index 8200ce11e2..e8b1482620 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt @@ -24,9 +24,9 @@ enum class TestType { object IosOpsCommand : CliktCommand(name = "ios", help = "Build ios app with tests") { - private val generate: Boolean by option().flag("-g", default = true) + private val generate: Boolean by option(help = "Make build").flag("-g", default = true) - private val copy: Boolean by option().flag("-c", default = true) + private val copy: Boolean by option(help = "Copy output files to tmp").flag("-c", default = true) override fun run() { failIfWindows() From a6f7a66c31c35d2bd1fb7b752d55815e2450bfd4 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 21 Oct 2020 17:49:58 +0200 Subject: [PATCH 83/95] Update ops.sh --- test_projects/android/ops.sh | 122 ++--------------------------------- 1 file changed, 6 insertions(+), 116 deletions(-) diff --git a/test_projects/android/ops.sh b/test_projects/android/ops.sh index 00636bef56..ce68785836 100755 --- a/test_projects/android/ops.sh +++ b/test_projects/android/ops.sh @@ -1,136 +1,26 @@ #!/usr/bin/env bash +DIR=`dirname "$BASH_SOURCE"` function base_app_apk() { - local dir=$TEST_PROJECTS_ANDROID - local outputDir="$FLANK_FIXTURES_TMP/apk" - - for arg in "$@"; do case "$arg" in - - '--generate' | '-g') - "$dir/gradlew" -p "$dir" app:assemble - ;; - - '--copy' | '-c') - local apkIn="$dir/app/build/outputs/apk/singleSuccess/debug/app-single-success-debug.apk" - local apkOut="$outputDir/app-debug.apk" - - mkdir -p "$outputDir" - cp "$apkIn" "$apkOut" - ;; - - esac done + $DIR/../../flank-scripts/bash/flankScripts shell ops android --copy --generate --artifacts=buildBaseApk } # depends on base_app_apk function base_test_apks() { - local dir=$TEST_PROJECTS_ANDROID - - for arg in "$@"; do case "$arg" in - - '--generate' | '-g') - "$dir/gradlew" -p "$dir" app:assembleAndroidTest - ;; - - '--copy' | '-c') - local outputDir="$FLANK_FIXTURES_TMP/apk" - - mkdir -p "$outputDir" - cp "$dir"/app/build/outputs/apk/androidTest/**/debug/*.apk "$outputDir/" - ;; - - esac done + $DIR/../../flank-scripts/bash/flankScripts shell ops android --copy --generate --artifacts=buildBaseTestApk } # depends on base_app_apk function duplicated_names_apks() { - local dir=$TEST_PROJECTS_ANDROID - - for arg in "$@"; do case "$arg" in - - '--generate' | '-g') - "$dir/gradlew" -p "$dir" \ - dir0:testModule:assembleAndroidTest \ - dir1:testModule:assembleAndroidTest \ - dir2:testModule:assembleAndroidTest \ - dir3:testModule:assembleAndroidTest - ;; - - '--copy' | '-c') - local outputDir="$FLANK_FIXTURES_TMP/apk" - local testIn="$dir/app/build/outputs/apk/androidTest/**/debug/*.apk" - - mkdir -p "$outputDir" - local dir=$(dirname "${BASH_SOURCE[0]-$0}") - local outputDir="$FLANK_FIXTURES_TMP/apk/duplicated_names/" - - for index in 0 1 2 3; do - moduleName="dir$index" - apkDir="$outputDir/$moduleName/" - mkdir -p "$apkDir" - cp "$dir/$moduleName"/testModule/build/outputs/apk/**/debug/*.apk "$apkDir" - done - ;; - - esac done + $DIR/../../flank-scripts/bash/flankScripts shell ops android --copy --generate --artifacts=buildDuplicatedNamesApks } function multi_module_apks() { - local dir=$TEST_PROJECTS_ANDROID - local outputDir="$FLANK_FIXTURES_TMP/apk/multi-modules/" - - for arg in "$@"; do case "$arg" in - - '--generate' | '-g') - "$dir/gradlew" -p "$dir" \ - :multi-modules:multiapp:assemble \ - :multi-modules:testModule1:assembleAndroidTest \ - :multi-modules:testModule2:assembleAndroidTest \ - :multi-modules:testModule3:assembleAndroidTest \ - :multi-modules:testModule4:assembleAndroidTest \ - :multi-modules:testModule5:assembleAndroidTest \ - :multi-modules:testModule6:assembleAndroidTest \ - :multi-modules:testModule7:assembleAndroidTest \ - :multi-modules:testModule8:assembleAndroidTest \ - :multi-modules:testModule9:assembleAndroidTest \ - :multi-modules:testModule10:assembleAndroidTest \ - :multi-modules:testModule11:assembleAndroidTest \ - :multi-modules:testModule12:assembleAndroidTest \ - :multi-modules:testModule13:assembleAndroidTest \ - :multi-modules:testModule14:assembleAndroidTest \ - :multi-modules:testModule15:assembleAndroidTest \ - :multi-modules:testModule16:assembleAndroidTest \ - :multi-modules:testModule17:assembleAndroidTest \ - :multi-modules:testModule18:assembleAndroidTest \ - :multi-modules:testModule19:assembleAndroidTest \ - :multi-modules:testModule20:assembleAndroidTest - ;; - - '--copy' | '-c') - mkdir -p "$outputDir" - find "$dir/multi-modules" -type f -name "*.apk" -exec cp {} "$outputDir" \; - ;; - - esac done + $DIR/../../flank-scripts/bash/flankScripts shell ops android --copy --generate --artifacts=buildMultiModulesApks } function cucumber_sample_app() { - local dir=$TEST_PROJECTS_ANDROID - local outputDir="$FLANK_FIXTURES_TMP/apk/cucumber_sample_app/" - - for arg in "$@"; do case "$arg" in - - '--generate' | '-g') - "$dir/gradlew" -p "$dir" \ - :cucumber_sample_app:cukeulator:assemble \ - :cucumber_sample_app:cukeulator:assembleAndroidTest - ;; - - '--copy' | '-c') - mkdir -p "$outputDir" - find "$dir/cucumber_sample_app" -type f -name "*.apk" -exec cp {} "$outputDir" \; - ;; - - esac done + $DIR/../../flank-scripts/bash/flankScripts shell ops android --copy --generate --artifacts=buildCucumberSampleApp } echo "Android test projects ops loaded" From fec68178f29c6aa8a4c300da48b4f4970ea21117 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 22 Oct 2020 12:47:40 +0200 Subject: [PATCH 84/95] Add ios commands --- .../flank/scripts/shell/ShellCommand.kt | 6 +- .../shell/ios/InstallXcPrettyCommand.kt | 12 ++++ .../scripts/shell/ios/SetupIosEnvCommand.kt | 17 ++++++ .../flank/scripts/shell/ops/IosOpsCommand.kt | 2 +- test_projects/ios/EarlGreyExample/ops.sh | 60 ++----------------- 5 files changed, 39 insertions(+), 58 deletions(-) create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ios/InstallXcPrettyCommand.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ios/SetupIosEnvCommand.kt diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ShellCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ShellCommand.kt index e69df8b2a0..69bcaf5ca2 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ShellCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ShellCommand.kt @@ -5,7 +5,9 @@ import com.github.ajalt.clikt.core.subcommands import flank.scripts.shell.firebase.FirebaseCommand import flank.scripts.shell.ios.BuildExampleCommand import flank.scripts.shell.ios.BuildFtlCommand +import flank.scripts.shell.ios.InstallXcPrettyCommand import flank.scripts.shell.ios.RunFtlLocalCommand +import flank.scripts.shell.ios.SetupIosEnvCommand import flank.scripts.shell.ios.UniversalFrameworkCommand import flank.scripts.shell.ops.OpsCommand import flank.scripts.shell.updatebinaries.UpdateBinariesCommand @@ -20,7 +22,9 @@ object ShellCommand : CliktCommand(name = "shell", help = "Task for shell comman UniversalFrameworkCommand, OpsCommand, UpdateBinariesCommand, - BuildFlankCommand + BuildFlankCommand, + InstallXcPrettyCommand, + SetupIosEnvCommand ) } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/InstallXcPrettyCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/InstallXcPrettyCommand.kt new file mode 100644 index 0000000000..86247fc3ab --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/InstallXcPrettyCommand.kt @@ -0,0 +1,12 @@ +package flank.scripts.shell.ios + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.shell.utils.failIfWindows +import flank.scripts.utils.downloadXcPrettyIfNeeded + +object InstallXcPrettyCommand : CliktCommand(name = "install_xcpretty", help = "Build ios app with tests") { + override fun run() { + failIfWindows() + downloadXcPrettyIfNeeded() + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/SetupIosEnvCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/SetupIosEnvCommand.kt new file mode 100644 index 0000000000..47eac9ee68 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/SetupIosEnvCommand.kt @@ -0,0 +1,17 @@ +package flank.scripts.shell.ios + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.shell.ops.EARL_GREY_EXAMPLE +import flank.scripts.shell.utils.failIfWindows +import flank.scripts.shell.utils.iOSTestProjectsPath +import flank.scripts.utils.downloadCocoaPodsIfNeeded +import flank.scripts.utils.installPods +import java.nio.file.Paths + +object SetupIosEnvCommand : CliktCommand(name = "setup_ios_env", help = "Build ios app with tests") { + override fun run() { + failIfWindows() + downloadCocoaPodsIfNeeded() + installPods(Paths.get(iOSTestProjectsPath, EARL_GREY_EXAMPLE)) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt index e8b1482620..5aeb088dc0 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt @@ -95,6 +95,6 @@ object IosOpsCommand : CliktCommand(name = "ios", help = "Build ios app with tes ) } -private const val EARL_GREY_EXAMPLE = "EarlGreyExample" +const val EARL_GREY_EXAMPLE = "EarlGreyExample" private const val EARL_GREY_EXAMPLE_TESTS = "EarlGreyExampleTests" private const val EARL_GREY_EXAMPLE_SWIFT_TESTS = "EarlGreyExampleSwiftTests" diff --git a/test_projects/ios/EarlGreyExample/ops.sh b/test_projects/ios/EarlGreyExample/ops.sh index 9e13c035da..c5b60631f2 100644 --- a/test_projects/ios/EarlGreyExample/ops.sh +++ b/test_projects/ios/EarlGreyExample/ops.sh @@ -1,71 +1,19 @@ #!/usr/bin/env bash -EARL_GREY_EXAMPLE="$TEST_PROJECTS_IOS/EarlGreyExample" - function setup_ios_env() { - if ! [ -x "$(command -v xcpretty)" ]; then - gem install cocoapods -v 1.9.3 - fi - (cd "$EARL_GREY_EXAMPLE" && pod install) + $DIR/../../flank-scripts/bash/flankScripts shell setup_ios_env } function install_xcpretty() { - if ! [ -x "$(command -v xcpretty)" ]; then - gem install xcpretty - fi + $DIR/../../flank-scripts/bash/flankScripts shell install_xcpretty } function universal_framework() { - "$EARL_GREY_EXAMPLE/universal_framework.sh" + $DIR/../../flank-scripts/bash/flankScripts shell iosUniversalFramework } function earl_grey_example() { - local dir=$EARL_GREY_EXAMPLE - local buildDir="$dir/build" - - for arg in "$@"; do case "$arg" in - - '--generate' | '-g') - - install_xcpretty - - rm -rf "$buildDir" - - xcodebuild build-for-testing \ - -allowProvisioningUpdates \ - -workspace "$dir/EarlGreyExample.xcworkspace" \ - -scheme "EarlGreyExampleSwiftTests" \ - -derivedDataPath "$buildDir" \ - -sdk iphoneos | - xcpretty - - xcodebuild build-for-testing \ - -allowProvisioningUpdates \ - -workspace "$dir/EarlGreyExample.xcworkspace" \ - -scheme "EarlGreyExampleTests" \ - -derivedDataPath "$buildDir" \ - -sdk iphoneos | - xcpretty - ;; - - '--copy' | '-c') - - local productsDir="$dir/build/Build/Products" - - cp -Rf "$productsDir"/*-iphoneos "$FLANK_FIXTURES_TMP/" - - cp "$productsDir"/*.xctestrun "$FLANK_FIXTURES_TMP/" - - cp \ - "$productsDir/Debug-iphoneos/EarlGreyExampleSwift.app/PlugIns/EarlGreyExampleTests.xctest/EarlGreyExampleTests" \ - "$FLANK_FIXTURES_TMP/objc/" - - cp \ - "$productsDir/Debug-iphoneos/EarlGreyExampleSwift.app/PlugIns/EarlGreyExampleSwiftTests.xctest/EarlGreyExampleSwiftTests" \ - "$FLANK_FIXTURES_TMP/swift/" - ;; - - esac done + $DIR/../../flank-scripts/bash/flankScripts shell ops ios --copy --generate } echo "iOS test projects ops loaded" From b85308a1f909a40b3cc1d3be832ad56aa311ea68 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 22 Oct 2020 13:01:34 +0200 Subject: [PATCH 85/95] Add windows batch script --- test_projects/ops.bat | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 test_projects/ops.bat diff --git a/test_projects/ops.bat b/test_projects/ops.bat new file mode 100644 index 0000000000..64c35e4731 --- /dev/null +++ b/test_projects/ops.bat @@ -0,0 +1,12 @@ +SET ARG=%1 + +if %ARG%=="android" CALL $DIR/../flank-scripts/bash/flankScripts.bat shell ops android --copy --generate + +if %ARG%=="ios" echo "iOS Build on windows not supported + +if %ARG%=="go" CALL $DIR/../flank-scripts/bash/flankScripts.bat shell ops go --copy --generate + +if %ARG%=="all" ( + CALL $DIR/../flank-scripts/bash/flankScripts.bat shell ops android --copy --generate + CALL $DIR/../flank-scripts/bash/flankScripts.bat shell ops go +) From 541e84c86a2104949f4eccecf4ef54dd9ddaf26a Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 22 Oct 2020 15:43:05 +0200 Subject: [PATCH 86/95] Add batch script to build android --- test_projects/android/build.bat | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 test_projects/android/build.bat diff --git a/test_projects/android/build.bat b/test_projects/android/build.bat new file mode 100644 index 0000000000..15e97ba4d8 --- /dev/null +++ b/test_projects/android/build.bat @@ -0,0 +1,2 @@ +SET DIR=%~dp0 +%DIR%\..\..\flank-scripts\bash\flankScripts.bat shell ops android --copy --generate From c065c0b77484c973f7141fa6dbc88e3e821ce000 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 22 Oct 2020 17:03:08 +0200 Subject: [PATCH 87/95] Fix build on windows --- flank-scripts/bash/buildFlankScripts.bat | 2 +- test_projects/ops.bat | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/flank-scripts/bash/buildFlankScripts.bat b/flank-scripts/bash/buildFlankScripts.bat index aeeb65e9c6..7dba984cc9 100755 --- a/flank-scripts/bash/buildFlankScripts.bat +++ b/flank-scripts/bash/buildFlankScripts.bat @@ -3,5 +3,5 @@ SET DIR=%~dp0 SET FLANK_SCRIPTS=%DIR%\.. SET GRADLE_EXECUTABLE_PATH=%FLANK_SCRIPTS%\.. -%GRADLE_EXECUTABLE_PATH%\gradlew.bat flank-scripts:clean flank-scripts:assemble flank-scripts:shadowJar +%GRADLE_EXECUTABLE_PATH%\gradlew.bat -p ..\ flank-scripts:clean flank-scripts:assemble flank-scripts:shadowJar copy %FLANK_SCRIPTS%\build\libs\flankScripts.jar %DIR%\flankScripts.jar diff --git a/test_projects/ops.bat b/test_projects/ops.bat index 64c35e4731..f1c35124ac 100644 --- a/test_projects/ops.bat +++ b/test_projects/ops.bat @@ -1,12 +1,18 @@ +@ECHO OFF SET ARG=%1 +if "%ARG%" == "android" ( + CALL ../flank-scripts/bash/flankScripts.bat shell ops android --copy --generate +) -if %ARG%=="android" CALL $DIR/../flank-scripts/bash/flankScripts.bat shell ops android --copy --generate - -if %ARG%=="ios" echo "iOS Build on windows not supported +if "%ARG%" == "ios" ( + echo iOS Build on windows not supported +) -if %ARG%=="go" CALL $DIR/../flank-scripts/bash/flankScripts.bat shell ops go --copy --generate +if "%ARG%" == "go" ( + CALL ../flank-scripts/bash/flankScripts.bat shell ops go +) -if %ARG%=="all" ( - CALL $DIR/../flank-scripts/bash/flankScripts.bat shell ops android --copy --generate - CALL $DIR/../flank-scripts/bash/flankScripts.bat shell ops go +if "%ARG%" == "all" ( + CALL ../flank-scripts/bash/flankScripts.bat shell ops android --copy --generate + CALL ../flank-scripts/bash/flankScripts.bat shell ops go ) From d2db108d5b2e76cc752f57c485765b793c7c8296 Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 27 Oct 2020 17:02:32 +0100 Subject: [PATCH 88/95] Update EarlGrey ops --- .../flank/scripts/shell/ops/IosOpsCommand.kt | 25 ++++++++++++++----- .../flank/scripts/shell/utils/PathHelper.kt | 2 ++ .../kotlin/ftl/fixtures/simple-ios-flank.yml | 8 ++++-- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt index 5aeb088dc0..cae74051d6 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt @@ -5,7 +5,7 @@ import com.github.ajalt.clikt.parameters.options.flag import com.github.ajalt.clikt.parameters.options.option import flank.scripts.shell.ios.createIosBuildCommand import flank.scripts.shell.utils.failIfWindows -import flank.scripts.shell.utils.flankFixturesTmpPath +import flank.scripts.shell.utils.flankFixturesIosTmpPath import flank.scripts.shell.utils.iOSTestProjectsPath import flank.scripts.shell.utils.pipe import flank.scripts.utils.downloadCocoaPodsIfNeeded @@ -43,12 +43,12 @@ object IosOpsCommand : CliktCommand(name = "ios", help = "Build ios app with tes } private fun createDirectoryInFixture(directoryName: String): Path = - Files.createDirectories(Paths.get(flankFixturesTmpPath, directoryName)) + Files.createDirectories(Paths.get(flankFixturesIosTmpPath, directoryName)) private fun buildEarlGreyExample() = Paths.get(iOSTestProjectsPath, EARL_GREY_EXAMPLE, "Build") .runBuilds() .resolve("Products") - .apply { filterFilesToCopy().copyIosProductFiles() } + .apply { renameXctestFiles().filterFilesToCopy().copyIosProductFiles() } .copyTestFiles() private fun Path.runBuilds() = apply { @@ -69,12 +69,25 @@ object IosOpsCommand : CliktCommand(name = "ios", help = "Build ios app with tes objcCommand pipe "xcpretty" } + private fun Path.renameXctestFiles() = apply { + toFile().walk().filter { it.extension == "xctestrun" && it.name.contains("EarlGreyExampleSwiftTests|EarlGreyExampleTests") }.forEach { + it.reduceTestFileName() + } + } + + private fun File.reduceTestFileName() = when { + (name.contains("EarlGreyExampleSwiftTests")) -> renameTo(toPath().parent.resolve("EarlGreyExampleSwiftTests.xctestrun").toFile()) + (name.contains("EarlGreyExampleTests")) -> renameTo(toPath().parent.resolve("EarlGreyExampleTests.xctestrun").toFile()) + else -> false + } + private fun Path.filterFilesToCopy() = toFile().walk().filter { it.nameWithoutExtension.endsWith("-iphoneos") || it.extension == "xctestrun" } + private fun Sequence.copyIosProductFiles() = forEach { - if (it.isDirectory) it.copyRecursively(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) - else it.copyTo(Paths.get(flankFixturesTmpPath, it.name).toFile(), overwrite = true) + if (it.isDirectory) it.copyRecursively(Paths.get(flankFixturesIosTmpPath, it.name).toFile(), overwrite = true) + else it.copyTo(Paths.get(flankFixturesIosTmpPath, it.name).toFile(), overwrite = true) } private fun Path.copyTestFiles() = toString().takeIf { copy }?.let { productsDirectory -> @@ -90,7 +103,7 @@ object IosOpsCommand : CliktCommand(name = "ios", help = "Build ios app with tes type: TestType ) = Files.copy( Paths.get(productsDirectory, *pluginsDirectories, "$name.xctest", name), - Paths.get(flankFixturesTmpPath, type.toString().toLowerCase(), name), + Paths.get(flankFixturesIosTmpPath, type.toString().toLowerCase(), name), StandardCopyOption.REPLACE_EXISTING ) } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt index e6f217c29d..3fe4748e95 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt @@ -18,3 +18,5 @@ val androidTestProjectsPath = Paths.get(testProjectsPath, "android").toString() val iOSTestProjectsPath = Paths.get(testProjectsPath, "ios").toString() val flankFixturesTmpPath = Paths.get(rootDirectoryPathString, "test_runner", "src", "test", "kotlin", "ftl", "fixtures", "tmp").toString() +val flankFixturesIosTmpPath = + Paths.get(flankFixturesTmpPath, "ios").toString() diff --git a/test_runner/src/test/kotlin/ftl/fixtures/simple-ios-flank.yml b/test_runner/src/test/kotlin/ftl/fixtures/simple-ios-flank.yml index 50b3a617cd..55fdef5b55 100644 --- a/test_runner/src/test/kotlin/ftl/fixtures/simple-ios-flank.yml +++ b/test_runner/src/test/kotlin/ftl/fixtures/simple-ios-flank.yml @@ -1,4 +1,8 @@ gcloud: - test: ./src/test/kotlin/ftl/fixtures/tmp/earlgrey_example.zip - xctestrun-file: ./src/test/kotlin/ftl/fixtures/tmp/EarlGreyExampleSwiftTests_iphoneos13.4-arm64e.xctestrun + test: ../flank_bins/earlgrey_example.zip + xctestrun-file: ../flank_bins/EarlGreyExampleSwiftTests_iphoneos14.0-arm64-armv7.xctestrun results-dir: test_dir + directories-to-pull: + - io.gogoapps.earlgrey.samples.EarlGrey:/Documents/output2 + other-files: + io.gogoapps.earlgrey.samples.EarlGrey:/Documents/output2/flank.txt: /Users/adamfilipowicz/Repos/flank.txt From 7bd1a077ff897bf52a84fcd732ec5c1d62b981b5 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 29 Oct 2020 12:59:18 +0100 Subject: [PATCH 89/95] Update simple-ios-flank.yml --- .../src/test/kotlin/ftl/fixtures/simple-ios-flank.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test_runner/src/test/kotlin/ftl/fixtures/simple-ios-flank.yml b/test_runner/src/test/kotlin/ftl/fixtures/simple-ios-flank.yml index 55fdef5b55..50b3a617cd 100644 --- a/test_runner/src/test/kotlin/ftl/fixtures/simple-ios-flank.yml +++ b/test_runner/src/test/kotlin/ftl/fixtures/simple-ios-flank.yml @@ -1,8 +1,4 @@ gcloud: - test: ../flank_bins/earlgrey_example.zip - xctestrun-file: ../flank_bins/EarlGreyExampleSwiftTests_iphoneos14.0-arm64-armv7.xctestrun + test: ./src/test/kotlin/ftl/fixtures/tmp/earlgrey_example.zip + xctestrun-file: ./src/test/kotlin/ftl/fixtures/tmp/EarlGreyExampleSwiftTests_iphoneos13.4-arm64e.xctestrun results-dir: test_dir - directories-to-pull: - - io.gogoapps.earlgrey.samples.EarlGrey:/Documents/output2 - other-files: - io.gogoapps.earlgrey.samples.EarlGrey:/Documents/output2/flank.txt: /Users/adamfilipowicz/Repos/flank.txt From 32ac866de3fd6b4043532cbdbea85dd7ee193742 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Mon, 26 Oct 2020 18:33:25 +0100 Subject: [PATCH 90/95] fix ops.sh script --- test_projects/ops.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test_projects/ops.sh b/test_projects/ops.sh index 2aef719e70..f9ab388618 100755 --- a/test_projects/ops.sh +++ b/test_projects/ops.sh @@ -11,17 +11,17 @@ function update_test_artifacts() { ;; ios) - kotlin $DIR/../flank-scripts/bash/flankScripts shell ops ios --copy --generate + $DIR/../flank-scripts/bash/flankScripts shell ops ios --copy --generate ;; go) - kotlin $DIR/../flank-scripts/bash/flankScripts shell ops go --copy --generate + $DIR/../flank-scripts/bash/flankScripts shell ops go --copy --generate ;; all) - kotlin $DIR/../flank-scripts/bash/flankScripts shell ops android --copy --generate - kotlin $DIR/../flank-scripts/bash/flankScripts shell ops ios --copy --generate - kotlin $DIR/../flank-scripts/bash/flankScripts shell ops go --copy --generate + $DIR/../flank-scripts/bash/flankScripts shell ops android --copy --generate + $DIR/../flank-scripts/bash/flankScripts shell ops ios --copy --generate + $DIR/../flank-scripts/bash/flankScripts shell ops go --copy --generate ;; esac done From c6cd1f2e0797adbc37c1e3efc46e44faed894726 Mon Sep 17 00:00:00 2001 From: Piotr Adamczyk Date: Thu, 29 Oct 2020 15:07:32 +0100 Subject: [PATCH 91/95] fixed pipe --- .../main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt | 1 - .../main/kotlin/flank/scripts/shell/utils/ShellHelper.kt | 7 ++++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt index cae74051d6..a4ea756c9c 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt @@ -84,7 +84,6 @@ object IosOpsCommand : CliktCommand(name = "ios", help = "Build ios app with tes private fun Path.filterFilesToCopy() = toFile().walk().filter { it.nameWithoutExtension.endsWith("-iphoneos") || it.extension == "xctestrun" } - private fun Sequence.copyIosProductFiles() = forEach { if (it.isDirectory) it.copyRecursively(Paths.get(flankFixturesIosTmpPath, it.name).toFile(), overwrite = true) else it.copyTo(Paths.get(flankFixturesIosTmpPath, it.name).toFile(), overwrite = true) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/ShellHelper.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/ShellHelper.kt index 9faceac91c..f086d9c36a 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/ShellHelper.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/ShellHelper.kt @@ -1,7 +1,12 @@ package flank.scripts.shell.utils +import flank.scripts.utils.isWindows import flank.scripts.utils.runCommand infix fun String.pipe(command: String) { - "$this | $command".runCommand() + if (isWindows) { + listOf("cmd", "/C", "$this | $command").runCommand() + } else { + listOf("/bin/bash", "-c", "$this | $command").runCommand() + } } From 485ed3ff412df0c5c47749b75e152831e8950c5f Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 29 Oct 2020 18:23:16 +0100 Subject: [PATCH 92/95] Add support for FlankExample build --- .../scripts/shell/ios/IosBuildCommand.kt | 13 +- .../flank/scripts/shell/ops/BuildIos.kt | 119 +++++++++++++++++ .../flank/scripts/shell/ops/IosOpsCommand.kt | 122 ++++-------------- 3 files changed, 154 insertions(+), 100 deletions(-) create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIos.kt diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/IosBuildCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/IosBuildCommand.kt index 60e66c87df..947fe99784 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/IosBuildCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/IosBuildCommand.kt @@ -1,9 +1,10 @@ package flank.scripts.shell.ios -fun createIosBuildCommand(buildDir: String, workspace: String, scheme: String) = +fun createIosBuildCommand(buildDir: String, workspace: String, scheme: String, project: String = "") = "xcodebuild build-for-testing" + - " -allowProvisioningUpdates" + - " -workspace $workspace" + - " -scheme $scheme" + - " -derivedDataPath $buildDir" + - " -sdk iphoneos" + " -allowProvisioningUpdates" + + (if (workspace.isBlank()) "" else " -workspace $workspace") + + (if (project.isBlank()) "" else " -project $project") + + " -scheme $scheme" + + " -derivedDataPath $buildDir" + + " -sdk iphoneos" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIos.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIos.kt new file mode 100644 index 0000000000..4ebc40afcc --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIos.kt @@ -0,0 +1,119 @@ +package flank.scripts.shell.ops + +import flank.scripts.shell.ios.createIosBuildCommand +import flank.scripts.shell.utils.flankFixturesIosTmpPath +import flank.scripts.shell.utils.iOSTestProjectsPath +import flank.scripts.shell.utils.pipe +import flank.scripts.utils.archive +import flank.scripts.utils.downloadCocoaPodsIfNeeded +import flank.scripts.utils.downloadXcPrettyIfNeeded +import flank.scripts.utils.installPods +import java.io.File +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths + +fun IosBuildConfiguration.generateIos() { + downloadCocoaPodsIfNeeded() + installPods(Paths.get(projectPath)) + downloadXcPrettyIfNeeded() + createDirectoryInFixture(directoryName = "objective_c") + createDirectoryInFixture(directoryName = "swift") + if (generate) buildEarlGreyExample() +} + +private fun IosBuildConfiguration.createDirectoryInFixture(directoryName: String): Path = + Files.createDirectories(Paths.get(flankFixturesIosTmpPath, projectName, directoryName)) + +private fun IosBuildConfiguration.buildEarlGreyExample() = Paths.get(projectPath, "Build") + .runBuilds(this) + .resolve("Products") + .apply { renameXctestFiles().filterFilesToCopy().archiveProject(projectName).copyIosProductFiles(projectName) } + .copyTestFiles(this) + +private fun Path.runBuilds(configuration: IosBuildConfiguration) = apply { + toFile().deleteRecursively() + val parent = toFile().parent + val workspace = + if (configuration.useWorkspace) Paths.get(parent, configuration.workspaceName).toString() + else "" + + val project = if (configuration.useWorkspace) "" + else Paths.get(parent, "${configuration.projectName}.xcodeproj").toString() + configuration.buildConfigurations.forEach { + val buildCommand = createIosBuildCommand( + parent, + workspace, + scheme = it.scheme, + project, + ) + buildCommand pipe "xcpretty" + } +} + +private fun Path.renameXctestFiles() = apply { + toFile().walk().filter { it.extension == "xctestrun" }.forEach { + it.reduceTestFileName() + } +} + +private fun Sequence.archiveProject(projectName: String) = also { + it.toList().archive("$projectName.zip", File(flankFixturesIosTmpPath, projectName)) +} + +private fun File.reduceTestFileName() = + renameTo(toPath().parent.resolve(name.reduceTestFileName()).toFile()) + +private fun String.reduceTestFileName() = + "_.*xctestrun".toRegex().replace(this, ".xctestrun") + +private fun Path.filterFilesToCopy() = + toFile().walk().filter { it.nameWithoutExtension.endsWith("-iphoneos") || it.extension == "xctestrun" } + +private fun Sequence.copyIosProductFiles(projectName: String) = forEach { + if (it.isDirectory) it.copyRecursively(Paths.get(flankFixturesIosTmpPath, projectName, it.name).toFile(), overwrite = true) + else it.copyTo(Paths.get(flankFixturesIosTmpPath, projectName, it.name).toFile(), overwrite = true) +} + +private fun Path.copyTestFiles(configuration: IosBuildConfiguration) = toString().takeIf { configuration.copy }?.let { productsDirectory -> + val appDirectory = Paths.get(productsDirectory, "Debug-iphoneos").toFile().findTestDirectories() + appDirectory.forEach { + it.walk().filter { it.isFile && it.extension == "" }.forEach { testFile -> + configuration.copyTestFile(testFile) + } + } +} + +private fun IosBuildConfiguration.copyTestFile( + fileToCopy: File, +) = + fileToCopy.copyTo(Paths.get(flankFixturesIosTmpPath, projectName, fileToCopy.name).toFile(), true) + +private fun File.findTestDirectories() = walk().filter { it.isDirectory && it.name.endsWith(".xctest") } + +data class IosBuildConfiguration( + val projectPath: String = Paths.get(iOSTestProjectsPath, EARL_GREY_EXAMPLE).toString(), + val projectName: String = EARL_GREY_EXAMPLE, + val objcTestsName: String = EARL_GREY_EXAMPLE_TESTS, + val swiftTestsName: String = EARL_GREY_EXAMPLE_SWIFT_TESTS, + val buildConfigurations: List = emptyList(), + val useWorkspace: Boolean = false, + val generate: Boolean = true, + val copy: Boolean = true +) + +data class IosTestBuildConfiguration(val scheme: String, val outputDirectoryName: String) + +private val IosBuildConfiguration.workspaceName + get() = "$projectName.xcworkspace" + +// private val IosBuildConfiguration.swiftAppDirectory +// get() = "${projectName}Swift.app" + +const val EARL_GREY_EXAMPLE = "EarlGreyExample" +const val EARL_GREY_EXAMPLE_TESTS = "EarlGreyExampleTests" +const val EARL_GREY_EXAMPLE_SWIFT_TESTS = "EarlGreyExampleSwiftTests" + +const val FLANK_EXAMPLE = "FlankExample" +const val FLANK_EXAMPLE_TESTS = "FlankExampleTests" +const val FLANK_EXAMPLE_SECOND_TESTS = "FlankExampleSecondTests" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt index a4ea756c9c..011a66f473 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt @@ -3,110 +3,44 @@ package flank.scripts.shell.ops import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.parameters.options.flag import com.github.ajalt.clikt.parameters.options.option -import flank.scripts.shell.ios.createIosBuildCommand import flank.scripts.shell.utils.failIfWindows -import flank.scripts.shell.utils.flankFixturesIosTmpPath import flank.scripts.shell.utils.iOSTestProjectsPath -import flank.scripts.shell.utils.pipe -import flank.scripts.utils.downloadCocoaPodsIfNeeded -import flank.scripts.utils.downloadXcPrettyIfNeeded -import flank.scripts.utils.installPods -import java.io.File -import java.nio.file.Files -import java.nio.file.Path import java.nio.file.Paths -import java.nio.file.StandardCopyOption - -enum class TestType { - SWIFT, - OBJECTIVE_C -} object IosOpsCommand : CliktCommand(name = "ios", help = "Build ios app with tests") { - private val generate: Boolean by option(help = "Make build").flag("-g", default = true) + private val generate: Boolean? by option(help = "Make build").flag("-g", default = true) - private val copy: Boolean by option(help = "Copy output files to tmp").flag("-c", default = true) + private val copy: Boolean? by option(help = "Copy output files to tmp").flag("-c", default = true) override fun run() { failIfWindows() - generateIos() - } - - private fun generateIos() { - downloadCocoaPodsIfNeeded() - installPods(Paths.get(iOSTestProjectsPath, EARL_GREY_EXAMPLE)) - downloadXcPrettyIfNeeded() - createDirectoryInFixture(directoryName = "objc") - createDirectoryInFixture(directoryName = "swift") - if (generate) buildEarlGreyExample() - } - - private fun createDirectoryInFixture(directoryName: String): Path = - Files.createDirectories(Paths.get(flankFixturesIosTmpPath, directoryName)) - - private fun buildEarlGreyExample() = Paths.get(iOSTestProjectsPath, EARL_GREY_EXAMPLE, "Build") - .runBuilds() - .resolve("Products") - .apply { renameXctestFiles().filterFilesToCopy().copyIosProductFiles() } - .copyTestFiles() - - private fun Path.runBuilds() = apply { - toFile().deleteRecursively() - val parent = toFile().parent - val swiftCommand = createIosBuildCommand( - parent, - Paths.get(parent, "EarlGreyExample.xcworkspace").toString(), - scheme = EARL_GREY_EXAMPLE_TESTS - ) - swiftCommand pipe "xcpretty" - - val objcCommand = createIosBuildCommand( - parent, - Paths.get(parent, "EarlGreyExample.xcworkspace").toString(), - scheme = EARL_GREY_EXAMPLE_SWIFT_TESTS - ) - objcCommand pipe "xcpretty" - } - private fun Path.renameXctestFiles() = apply { - toFile().walk().filter { it.extension == "xctestrun" && it.name.contains("EarlGreyExampleSwiftTests|EarlGreyExampleTests") }.forEach { - it.reduceTestFileName() - } + IosBuildConfiguration( + projectPath = Paths.get(iOSTestProjectsPath, FLANK_EXAMPLE).toString(), + projectName = FLANK_EXAMPLE, + objcTestsName = FLANK_EXAMPLE_TESTS, + swiftTestsName = FLANK_EXAMPLE_SECOND_TESTS, + buildConfigurations = listOf( + IosTestBuildConfiguration(FLANK_EXAMPLE, "tests"), + ), + useWorkspace = false, + generate = generate ?: true, + copy = copy ?: true + ).generateIos() + + IosBuildConfiguration( + projectPath = Paths.get(iOSTestProjectsPath, EARL_GREY_EXAMPLE).toString(), + projectName = EARL_GREY_EXAMPLE, + objcTestsName = EARL_GREY_EXAMPLE_TESTS, + swiftTestsName = EARL_GREY_EXAMPLE_SWIFT_TESTS, + buildConfigurations = listOf( + IosTestBuildConfiguration(EARL_GREY_EXAMPLE_SWIFT_TESTS, "swift"), + IosTestBuildConfiguration(EARL_GREY_EXAMPLE_TESTS, "objective_c") + ), + useWorkspace = true, + generate = generate ?: true, + copy = copy ?: true + ).generateIos() } - - private fun File.reduceTestFileName() = when { - (name.contains("EarlGreyExampleSwiftTests")) -> renameTo(toPath().parent.resolve("EarlGreyExampleSwiftTests.xctestrun").toFile()) - (name.contains("EarlGreyExampleTests")) -> renameTo(toPath().parent.resolve("EarlGreyExampleTests.xctestrun").toFile()) - else -> false - } - - private fun Path.filterFilesToCopy() = - toFile().walk().filter { it.nameWithoutExtension.endsWith("-iphoneos") || it.extension == "xctestrun" } - - private fun Sequence.copyIosProductFiles() = forEach { - if (it.isDirectory) it.copyRecursively(Paths.get(flankFixturesIosTmpPath, it.name).toFile(), overwrite = true) - else it.copyTo(Paths.get(flankFixturesIosTmpPath, it.name).toFile(), overwrite = true) - } - - private fun Path.copyTestFiles() = toString().takeIf { copy }?.let { productsDirectory -> - val pluginsDirectory = arrayOf("Debug-iphoneos", "EarlGreyExampleSwift.app", "PlugIns") - copyTestFile(productsDirectory, pluginsDirectory, EARL_GREY_EXAMPLE_TESTS, TestType.OBJECTIVE_C) - copyTestFile(productsDirectory, pluginsDirectory, EARL_GREY_EXAMPLE_SWIFT_TESTS, TestType.SWIFT) - } - - private fun copyTestFile( - productsDirectory: String, - pluginsDirectories: Array, - name: String, - type: TestType - ) = Files.copy( - Paths.get(productsDirectory, *pluginsDirectories, "$name.xctest", name), - Paths.get(flankFixturesIosTmpPath, type.toString().toLowerCase(), name), - StandardCopyOption.REPLACE_EXISTING - ) } - -const val EARL_GREY_EXAMPLE = "EarlGreyExample" -private const val EARL_GREY_EXAMPLE_TESTS = "EarlGreyExampleTests" -private const val EARL_GREY_EXAMPLE_SWIFT_TESTS = "EarlGreyExampleSwiftTests" From cac8b2c730705491d5668d80e2e8c6ec08ea1433 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 30 Oct 2020 12:57:35 +0100 Subject: [PATCH 93/95] Add commands for biuld flankExample and earlGreyExample --- .../scripts/shell/ops/AndroidOpsCommand.kt | 124 +----------------- .../flank/scripts/shell/ops/BuildAndroid.kt | 118 +++++++++++++++++ ...mand.kt => BuildEarlGreyExampleCommand.kt} | 21 +-- .../shell/ops/BuildFlankExampleCommand.kt | 32 +++++ .../flank/scripts/shell/ops/BuildIos.kt | 26 +--- .../flank/scripts/shell/ops/OpsCommand.kt | 3 +- 6 files changed, 166 insertions(+), 158 deletions(-) create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildAndroid.kt rename flank-scripts/src/main/kotlin/flank/scripts/shell/ops/{IosOpsCommand.kt => BuildEarlGreyExampleCommand.kt} (60%) create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildFlankExampleCommand.kt diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt index 04f8aa89d2..d837f45723 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt @@ -4,15 +4,6 @@ import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.parameters.options.flag import com.github.ajalt.clikt.parameters.options.multiple import com.github.ajalt.clikt.parameters.options.option -import flank.scripts.shell.utils.androidTestProjectsPath -import flank.scripts.shell.utils.createGradleCommand -import flank.scripts.shell.utils.flankFixturesTmpPath -import flank.scripts.utils.runCommand -import java.io.File -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.Paths -import java.nio.file.StandardCopyOption object AndroidOpsCommand : CliktCommand(name = "android", help = "Build android apks with tests") { @@ -24,115 +15,12 @@ object AndroidOpsCommand : CliktCommand(name = "android", help = "Build android override fun run() { if (generate.not()) return - buildBaseApk() - buildBaseTestApk() - buildDuplicatedNamesApks() - buildMultiModulesApks() - buildCucumberSampleApp() - } - - private fun buildBaseApk() { - if (artifacts.canExecute("buildBaseApk").not()) return - - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, "app:assemble") - ).runCommand() - - if (copy) copyBaseApk() - } - - private fun copyBaseApk() { - val outputDir = Paths.get(flankFixturesTmpPath, "apk", "app-debug.apk") - - if (!outputDir.parent.toFile().exists()) Files.createDirectories(outputDir.parent) - - val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "singleSuccess", "debug", "app-single-success-debug.apk") - Files.copy(assembleDirectory, outputDir, StandardCopyOption.REPLACE_EXISTING) - } - - private fun buildBaseTestApk() { - if (artifacts.canExecute("buildBaseTestApk").not()) return - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, "app:assembleAndroidTest") - ).runCommand() - - if (copy) copyBaseTestApk() - } - - private fun copyBaseTestApk() { - val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "androidTest") - assembleDirectory.toFile().findApks().forEach { - Files.copy(it.toPath(), Paths.get(flankFixturesTmpPath, "apk", it.name), StandardCopyOption.REPLACE_EXISTING) + AndroidBuildConfiguration(artifacts, generate, copy).run { + buildBaseApk() + buildBaseTestApk() + buildDuplicatedNamesApks() + buildMultiModulesApks() + buildCucumberSampleApp() } } - - private fun buildDuplicatedNamesApks() { - if (artifacts.canExecute("buildDuplicatedNamesApks").not()) return - val modules = (0..3).map { "dir$it" } - - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath) + modules.map { "$it:testModule:assembleAndroidTest" }.toList() - ).runCommand() - - if (copy) copyDuplicatedNamesApks() - } - - private fun copyDuplicatedNamesApks() { - val modules = (0..3).map { "dir$it" } - val outputDir = Paths.get(flankFixturesTmpPath, "apk", "duplicated_names") - if (!outputDir.toFile().exists()) Files.createDirectories(outputDir) - - modules.map { Paths.get(androidTestProjectsPath, it, "testModule", "build", "outputs", "apk").toFile() } - .flatMap { it.findApks().toList() } - .forEachIndexed { index, file -> - file.copyApkToDirectory(Paths.get(outputDir.toString(), modules[index], file.name)) - } - } - - private fun File.copyApkToDirectory(output: Path): Path = toPath().let { sourceFile -> - if (!output.parent.toFile().exists()) Files.createDirectories(output.parent) - Files.copy(sourceFile, output, StandardCopyOption.REPLACE_EXISTING) - } - - private fun buildMultiModulesApks() { - if (artifacts.canExecute("buildMultiModulesApks").not()) return - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, - ":multi-modules:multiapp:assemble") + (1..20).map { ":multi-modules:testModule$it:assembleAndroidTest" }).runCommand() - - if (copy) copyMultiModulesApks() - } - - private fun copyMultiModulesApks() { - val outputDir = Paths.get(flankFixturesTmpPath, "apk", "multi-modules").toString() - Paths.get(androidTestProjectsPath, "multi-modules").toFile().findApks() - .forEach { it.copyApkToDirectory(Paths.get(outputDir, it.name)) } - } - - private fun buildCucumberSampleApp() { - if (artifacts.canExecute("buildMultiModulesApks").not()) return - createGradleCommand( - workingDir = androidTestProjectsPath, - options = listOf("-p", androidTestProjectsPath, "cucumber_sample_app:cukeulator:assembleDebug", ":cucumber_sample_app:cukeulator:assembleAndroidTest") - ).runCommand() - - if (copy) copyCucumberSampleApp() - } - - private fun copyCucumberSampleApp() { - val outputDir = Paths.get(flankFixturesTmpPath, "apk", "cucumber_sample_app").toString() - Paths.get(androidTestProjectsPath, "cucumber_sample_app").toFile().findApks().copyApksToPath(outputDir) - } - - private fun File.findApks() = walk().filter { it.extension == "apk" } - - private fun Sequence.copyApksToPath(outputDirectory: String) = forEach { - it.copyApkToDirectory(Paths.get(outputDirectory, it.name)) - } - - private fun List.canExecute(actionName: String) = isEmpty() || any { it.toLowerCase() == actionName.toLowerCase() } } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildAndroid.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildAndroid.kt new file mode 100644 index 0000000000..3bb9c033c5 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildAndroid.kt @@ -0,0 +1,118 @@ +package flank.scripts.shell.ops + +import flank.scripts.shell.utils.androidTestProjectsPath +import flank.scripts.shell.utils.createGradleCommand +import flank.scripts.shell.utils.flankFixturesTmpPath +import flank.scripts.utils.runCommand +import java.io.File +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths +import java.nio.file.StandardCopyOption + +fun AndroidBuildConfiguration.buildBaseApk() { + if (artifacts.canExecute("buildBaseApk").not()) return + + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, "app:assemble") + ).runCommand() + + if (copy) copyBaseApk() +} + +private fun copyBaseApk() { + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "app-debug.apk") + + if (!outputDir.parent.toFile().exists()) Files.createDirectories(outputDir.parent) + + val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "singleSuccess", "debug", "app-single-success-debug.apk") + Files.copy(assembleDirectory, outputDir, StandardCopyOption.REPLACE_EXISTING) +} + +fun AndroidBuildConfiguration.buildBaseTestApk() { + if (artifacts.canExecute("buildBaseTestApk").not()) return + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, "app:assembleAndroidTest") + ).runCommand() + + if (copy) copyBaseTestApk() +} + +private fun copyBaseTestApk() { + val assembleDirectory = Paths.get(androidTestProjectsPath, "app", "build", "outputs", "apk", "androidTest") + assembleDirectory.toFile().findApks().forEach { + Files.copy(it.toPath(), Paths.get(flankFixturesTmpPath, "apk", it.name), StandardCopyOption.REPLACE_EXISTING) + } +} + +fun AndroidBuildConfiguration.buildDuplicatedNamesApks() { + if (artifacts.canExecute("buildDuplicatedNamesApks").not()) return + val modules = (0..3).map { "dir$it" } + + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath) + modules.map { "$it:testModule:assembleAndroidTest" }.toList() + ).runCommand() + + if (copy) copyDuplicatedNamesApks() +} + +private fun copyDuplicatedNamesApks() { + val modules = (0..3).map { "dir$it" } + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "duplicated_names") + if (!outputDir.toFile().exists()) Files.createDirectories(outputDir) + + modules.map { Paths.get(androidTestProjectsPath, it, "testModule", "build", "outputs", "apk").toFile() } + .flatMap { it.findApks().toList() } + .forEachIndexed { index, file -> + file.copyApkToDirectory(Paths.get(outputDir.toString(), modules[index], file.name)) + } +} + +private fun File.copyApkToDirectory(output: Path): Path = toPath().let { sourceFile -> + if (!output.parent.toFile().exists()) Files.createDirectories(output.parent) + Files.copy(sourceFile, output, StandardCopyOption.REPLACE_EXISTING) +} + +fun AndroidBuildConfiguration.buildMultiModulesApks() { + if (artifacts.canExecute("buildMultiModulesApks").not()) return + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, + ":multi-modules:multiapp:assemble") + (1..20).map { ":multi-modules:testModule$it:assembleAndroidTest" }).runCommand() + + if (copy) copyMultiModulesApks() +} + +private fun copyMultiModulesApks() { + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "multi-modules").toString() + Paths.get(androidTestProjectsPath, "multi-modules").toFile().findApks() + .forEach { it.copyApkToDirectory(Paths.get(outputDir, it.name)) } +} + +fun AndroidBuildConfiguration.buildCucumberSampleApp() { + if (artifacts.canExecute("buildMultiModulesApks").not()) return + createGradleCommand( + workingDir = androidTestProjectsPath, + options = listOf("-p", androidTestProjectsPath, "cucumber_sample_app:cukeulator:assembleDebug", ":cucumber_sample_app:cukeulator:assembleAndroidTest") + ).runCommand() + + if (copy) copyCucumberSampleApp() +} + +private fun copyCucumberSampleApp() { + val outputDir = Paths.get(flankFixturesTmpPath, "apk", "cucumber_sample_app").toString() + Paths.get(androidTestProjectsPath, "cucumber_sample_app").toFile().findApks().copyApksToPath(outputDir) +} + +private fun File.findApks() = walk().filter { it.extension == "apk" } + +private fun Sequence.copyApksToPath(outputDirectory: String) = forEach { + it.copyApkToDirectory(Paths.get(outputDirectory, it.name)) +} + +private fun List.canExecute(actionName: String) = isEmpty() || any { it.toLowerCase() == actionName.toLowerCase() } + +data class AndroidBuildConfiguration(val artifacts: List, val generate: Boolean, val copy: Boolean) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildEarlGreyExampleCommand.kt similarity index 60% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt rename to flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildEarlGreyExampleCommand.kt index 011a66f473..8f92a88303 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildEarlGreyExampleCommand.kt @@ -7,7 +7,7 @@ import flank.scripts.shell.utils.failIfWindows import flank.scripts.shell.utils.iOSTestProjectsPath import java.nio.file.Paths -object IosOpsCommand : CliktCommand(name = "ios", help = "Build ios app with tests") { +object BuildEarlGreyExampleCommand : CliktCommand(name = "build_earl_grey_example", help = "Build ios earl grey example app with tests") { private val generate: Boolean? by option(help = "Make build").flag("-g", default = true) @@ -16,24 +16,9 @@ object IosOpsCommand : CliktCommand(name = "ios", help = "Build ios app with tes override fun run() { failIfWindows() - IosBuildConfiguration( - projectPath = Paths.get(iOSTestProjectsPath, FLANK_EXAMPLE).toString(), - projectName = FLANK_EXAMPLE, - objcTestsName = FLANK_EXAMPLE_TESTS, - swiftTestsName = FLANK_EXAMPLE_SECOND_TESTS, - buildConfigurations = listOf( - IosTestBuildConfiguration(FLANK_EXAMPLE, "tests"), - ), - useWorkspace = false, - generate = generate ?: true, - copy = copy ?: true - ).generateIos() - IosBuildConfiguration( projectPath = Paths.get(iOSTestProjectsPath, EARL_GREY_EXAMPLE).toString(), projectName = EARL_GREY_EXAMPLE, - objcTestsName = EARL_GREY_EXAMPLE_TESTS, - swiftTestsName = EARL_GREY_EXAMPLE_SWIFT_TESTS, buildConfigurations = listOf( IosTestBuildConfiguration(EARL_GREY_EXAMPLE_SWIFT_TESTS, "swift"), IosTestBuildConfiguration(EARL_GREY_EXAMPLE_TESTS, "objective_c") @@ -44,3 +29,7 @@ object IosOpsCommand : CliktCommand(name = "ios", help = "Build ios app with tes ).generateIos() } } + +const val EARL_GREY_EXAMPLE = "EarlGreyExample" +private const val EARL_GREY_EXAMPLE_TESTS = "EarlGreyExampleTests" +private const val EARL_GREY_EXAMPLE_SWIFT_TESTS = "EarlGreyExampleSwiftTests" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildFlankExampleCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildFlankExampleCommand.kt new file mode 100644 index 0000000000..5cd940f831 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildFlankExampleCommand.kt @@ -0,0 +1,32 @@ +package flank.scripts.shell.ops + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.parameters.options.flag +import com.github.ajalt.clikt.parameters.options.option +import flank.scripts.shell.utils.failIfWindows +import flank.scripts.shell.utils.iOSTestProjectsPath +import java.nio.file.Paths + +object BuildFlankExampleCommand : CliktCommand(name = "build_flank_example", help = "Build ios flank example app with tests") { + + private val generate: Boolean? by option(help = "Make build").flag("-g", default = true) + + private val copy: Boolean? by option(help = "Copy output files to tmp").flag("-c", default = true) + + override fun run() { + failIfWindows() + + IosBuildConfiguration( + projectPath = Paths.get(iOSTestProjectsPath, FLANK_EXAMPLE).toString(), + projectName = FLANK_EXAMPLE, + buildConfigurations = listOf( + IosTestBuildConfiguration(FLANK_EXAMPLE, "tests"), + ), + useWorkspace = false, + generate = generate ?: true, + copy = copy ?: true + ).generateIos() + } +} + +private const val FLANK_EXAMPLE = "FlankExample" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIos.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIos.kt index 4ebc40afcc..d10e9ccc33 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIos.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIos.kt @@ -2,14 +2,12 @@ package flank.scripts.shell.ops import flank.scripts.shell.ios.createIosBuildCommand import flank.scripts.shell.utils.flankFixturesIosTmpPath -import flank.scripts.shell.utils.iOSTestProjectsPath import flank.scripts.shell.utils.pipe import flank.scripts.utils.archive import flank.scripts.utils.downloadCocoaPodsIfNeeded import flank.scripts.utils.downloadXcPrettyIfNeeded import flank.scripts.utils.installPods import java.io.File -import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths @@ -17,14 +15,9 @@ fun IosBuildConfiguration.generateIos() { downloadCocoaPodsIfNeeded() installPods(Paths.get(projectPath)) downloadXcPrettyIfNeeded() - createDirectoryInFixture(directoryName = "objective_c") - createDirectoryInFixture(directoryName = "swift") if (generate) buildEarlGreyExample() } -private fun IosBuildConfiguration.createDirectoryInFixture(directoryName: String): Path = - Files.createDirectories(Paths.get(flankFixturesIosTmpPath, projectName, directoryName)) - private fun IosBuildConfiguration.buildEarlGreyExample() = Paths.get(projectPath, "Build") .runBuilds(this) .resolve("Products") @@ -92,11 +85,9 @@ private fun IosBuildConfiguration.copyTestFile( private fun File.findTestDirectories() = walk().filter { it.isDirectory && it.name.endsWith(".xctest") } data class IosBuildConfiguration( - val projectPath: String = Paths.get(iOSTestProjectsPath, EARL_GREY_EXAMPLE).toString(), - val projectName: String = EARL_GREY_EXAMPLE, - val objcTestsName: String = EARL_GREY_EXAMPLE_TESTS, - val swiftTestsName: String = EARL_GREY_EXAMPLE_SWIFT_TESTS, - val buildConfigurations: List = emptyList(), + val projectPath: String, + val projectName: String, + val buildConfigurations: List, val useWorkspace: Boolean = false, val generate: Boolean = true, val copy: Boolean = true @@ -106,14 +97,3 @@ data class IosTestBuildConfiguration(val scheme: String, val outputDirectoryName private val IosBuildConfiguration.workspaceName get() = "$projectName.xcworkspace" - -// private val IosBuildConfiguration.swiftAppDirectory -// get() = "${projectName}Swift.app" - -const val EARL_GREY_EXAMPLE = "EarlGreyExample" -const val EARL_GREY_EXAMPLE_TESTS = "EarlGreyExampleTests" -const val EARL_GREY_EXAMPLE_SWIFT_TESTS = "EarlGreyExampleSwiftTests" - -const val FLANK_EXAMPLE = "FlankExample" -const val FLANK_EXAMPLE_TESTS = "FlankExampleTests" -const val FLANK_EXAMPLE_SECOND_TESTS = "FlankExampleSecondTests" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt index f97440c252..c13d24ab81 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt @@ -7,7 +7,8 @@ object OpsCommand : CliktCommand(name = "ops", help = "Contains all ops command: init { subcommands( AndroidOpsCommand, - IosOpsCommand, + BuildEarlGreyExampleCommand, + BuildFlankExampleCommand, GoOpsCommand ) } From 44ae1d4bc296886fa1ef3df9df3046b5d19c2eaa Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 30 Oct 2020 13:04:17 +0100 Subject: [PATCH 94/95] Update README.md --- flank-scripts/README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/flank-scripts/README.md b/flank-scripts/README.md index 09fc0ad607..4eaaa3791a 100644 --- a/flank-scripts/README.md +++ b/flank-scripts/README.md @@ -215,8 +215,16 @@ These tasks are : ##### `go` Build go app with tests -##### `ios` -Build ios app with tests +##### `build_earl_grey_example` +Build ios earl grey example app with tests + +| Option | Short option | Description | +|------------|--------------|--------------------------| +| --generate | -g | Make build | +| --copy | -c | Copy output files to tmp | + +##### `build_flank_example` +Build ios flank example app with tests | Option | Short option | Description | |------------|--------------|--------------------------| From 2680656a4ace02f1dd595656fad6cef1bb7df513 Mon Sep 17 00:00:00 2001 From: piotradamczyk5 <65554637+piotradamczyk5@users.noreply.github.com> Date: Fri, 30 Oct 2020 15:10:57 +0100 Subject: [PATCH 95/95] Update buildFlankScripts.bat --- flank-scripts/bash/buildFlankScripts.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flank-scripts/bash/buildFlankScripts.bat b/flank-scripts/bash/buildFlankScripts.bat index 7dba984cc9..aeeb65e9c6 100755 --- a/flank-scripts/bash/buildFlankScripts.bat +++ b/flank-scripts/bash/buildFlankScripts.bat @@ -3,5 +3,5 @@ SET DIR=%~dp0 SET FLANK_SCRIPTS=%DIR%\.. SET GRADLE_EXECUTABLE_PATH=%FLANK_SCRIPTS%\.. -%GRADLE_EXECUTABLE_PATH%\gradlew.bat -p ..\ flank-scripts:clean flank-scripts:assemble flank-scripts:shadowJar +%GRADLE_EXECUTABLE_PATH%\gradlew.bat flank-scripts:clean flank-scripts:assemble flank-scripts:shadowJar copy %FLANK_SCRIPTS%\build\libs\flankScripts.jar %DIR%\flankScripts.jar