diff --git a/common/src/test/kotlin/flank/common/FilesTest.kt b/common/src/test/kotlin/flank/common/FilesTest.kt index 27bd6b3207..fc634bd8e2 100644 --- a/common/src/test/kotlin/flank/common/FilesTest.kt +++ b/common/src/test/kotlin/flank/common/FilesTest.kt @@ -2,8 +2,10 @@ package flank.common import io.mockk.InternalPlatformDsl.toStr import org.junit.After +import org.junit.Assert import org.junit.Assert.assertTrue import org.junit.Assume.assumeFalse +import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder import java.io.File @@ -14,6 +16,9 @@ class FilesTest { private val linkName = "tmp" private val targetName = "../" + @get:Rule + val root = TemporaryFolder() + @Test fun `should create symbolic link`() { assumeFalse(isWindows) @@ -63,4 +68,51 @@ class FilesTest { fun tearDown() { File(linkName).delete() } + + @Test + fun `Should create symbolic file at desired location`() { + assumeFalse(isWindows) + // given + val testFile = root.newFile("test.file").toPath() + val expectedDestination = Paths.get(root.newFolder("temp").toString(), "test.link") + + // when + createSymbolicLinkToFile(expectedDestination, testFile) + + // then + assertTrue(Files.isSymbolicLink(expectedDestination)) + + // clean + testFile.toFile().delete() + expectedDestination.toFile().delete() + } + + @Test + fun `Should check if directory contains all needed files`() { + // given + val testDirectory = root.newFolder("test").toPath() + val testFiles = listOf( + Paths.get(testDirectory.toString(), "testFile1"), + Paths.get(testDirectory.toString(), "testFile2"), + Paths.get(testDirectory.toString(), "testFile3"), + Paths.get(testDirectory.toString(), "testFile4") + ) + + testFiles.forEach { Files.createFile(it) } + + // when + val resultTrue = testDirectory.toFile().hasAllFiles(testFiles.map { it.fileName.toString() }) + val resultFalse = testDirectory.toFile() + .hasAllFiles( + (testFiles + Paths.get(testDirectory.toString(), "testFile5")) + .map { it.fileName.toString() } + ) + + // then + assertTrue(resultTrue) + Assert.assertFalse(resultFalse) + + // clean + testDirectory.toFile().deleteRecursively() + } } diff --git a/flank-scripts/build.gradle.kts b/flank-scripts/build.gradle.kts index 9701644224..42cbb2d63c 100644 --- a/flank-scripts/build.gradle.kts +++ b/flank-scripts/build.gradle.kts @@ -28,11 +28,11 @@ shadowJar.apply { } } // .. -version = "1.4.6" +version = "1.5.0" group = "com.github.flank" application { - mainClassName = "flank.scripts.MainKt" + mainClassName = "flank.scripts.cli.MainKt" applicationDefaultJvmArgs = listOf( "-Xmx2048m", "-Xms512m" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/Main.kt b/flank-scripts/src/main/kotlin/flank/scripts/Main.kt deleted file mode 100644 index 143908e55e..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/Main.kt +++ /dev/null @@ -1,30 +0,0 @@ -package flank.scripts - -import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.clikt.core.subcommands -import flank.scripts.ci.CiCommand -import flank.scripts.contribution.ContributionCommand -import flank.scripts.dependencies.DependenciesCommand -import flank.scripts.integration.IntegrationCommand -import flank.scripts.pullrequest.PullRequestCommand -import flank.scripts.release.ReleaseCommand -import flank.scripts.shell.ShellCommand -import flank.scripts.testartifacts.TestArtifactsCommand - -class Main : CliktCommand(name = "flankScripts") { - @Suppress("EmptyFunctionBlock") - override fun run() {} -} - -fun main(args: Array) { - Main().subcommands( - ReleaseCommand(), - CiCommand(), - DependenciesCommand, - TestArtifactsCommand(), - ShellCommand, - PullRequestCommand, - IntegrationCommand, - ContributionCommand - ).main(args) -} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ci/CiCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/ci/CiCommand.kt deleted file mode 100644 index 2478933ba1..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/ci/CiCommand.kt +++ /dev/null @@ -1,16 +0,0 @@ -package flank.scripts.ci - -import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.clikt.core.subcommands -import flank.scripts.ci.nexttag.NextReleaseTagCommand -import flank.scripts.ci.releasenotes.GenerateReleaseNotesCommand - -class CiCommand : CliktCommand(help = "Contains command related to CI", name = "ci") { - - init { - subcommands(GenerateReleaseNotesCommand(), NextReleaseTagCommand()) - } - - @Suppress("EmptyFunctionBlock") - override fun run() {} -} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ci/nexttag/NextReleaseTagCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/ci/nexttag/NextReleaseTagCommand.kt deleted file mode 100644 index beaaf2b109..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/ci/nexttag/NextReleaseTagCommand.kt +++ /dev/null @@ -1,30 +0,0 @@ -package flank.scripts.ci.nexttag - -import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.clikt.parameters.options.option -import com.github.ajalt.clikt.parameters.options.required -import com.github.kittinunf.result.Result -import flank.scripts.github.getLatestReleaseTag -import kotlinx.coroutines.runBlocking -import kotlin.system.exitProcess - -class NextReleaseTagCommand : CliktCommand(help = "Print next release tag", name = "nextReleaseTag") { - - private val token by option(help = "Git Token").required() - - override fun run() { - runBlocking { - getNextReleaseTagCommand(token) - } - } -} - -private suspend fun getNextReleaseTagCommand(token: String) { - when (val result = getLatestReleaseTag(token)) { - is Result.Success -> println(generateNextReleaseTag(result.value.tag)) - is Result.Failure -> { - println(result.error) - exitProcess(1) - } - } -} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/GenerateReleaseNotesCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/GenerateReleaseNotesCommand.kt deleted file mode 100644 index 75f3d56abd..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/GenerateReleaseNotesCommand.kt +++ /dev/null @@ -1,32 +0,0 @@ -package flank.scripts.ci.releasenotes - -import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.clikt.parameters.options.default -import com.github.ajalt.clikt.parameters.options.option -import com.github.ajalt.clikt.parameters.options.required -import com.github.kittinunf.result.map -import com.github.kittinunf.result.success -import flank.scripts.ci.nexttag.generateNextReleaseTag -import flank.scripts.github.getLatestReleaseTag -import kotlinx.coroutines.runBlocking -import java.io.File - -class GenerateReleaseNotesCommand : - CliktCommand("Command to append item to release notes", name = "generateReleaseNotes") { - - private val token by option(help = "Git Token").required() - internal val releaseNotesFile by option(help = "Path to release_notes.md").default("release_notes.md") - - override fun run() { - runBlocking { - getLatestReleaseTag(token) - .map { it.tag } - .success { previousTag -> - File(releaseNotesFile).appendReleaseNotes( - releaseNotesWithType = generateReleaseNotes(previousTag, token), - releaseTag = generateNextReleaseTag(previousTag) - ) - } - } - } -} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/Main.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/Main.kt new file mode 100644 index 0000000000..1c2eb2903d --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/Main.kt @@ -0,0 +1,30 @@ +package flank.scripts.cli + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.subcommands +import flank.scripts.cli.ci.CiCommand +import flank.scripts.cli.contribution.ContributionCommand +import flank.scripts.cli.dependencies.DependenciesCommand +import flank.scripts.cli.integration.IntegrationCommand +import flank.scripts.cli.pullrequest.PullRequestCommand +import flank.scripts.cli.release.ReleaseCommand +import flank.scripts.cli.shell.ShellCommand +import flank.scripts.cli.testartifacts.TestArtifactsCommand + +class Main : CliktCommand(name = "flankScripts") { + @Suppress("EmptyFunctionBlock") + override fun run() {} +} + +fun main(args: Array) { + Main().subcommands( + ReleaseCommand, + CiCommand, + DependenciesCommand, + TestArtifactsCommand, + ShellCommand, + PullRequestCommand, + IntegrationCommand, + ContributionCommand + ).main(args) +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/ci/CiCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/ci/CiCommand.kt new file mode 100644 index 0000000000..69e06cea82 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/ci/CiCommand.kt @@ -0,0 +1,17 @@ +package flank.scripts.cli.ci + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.subcommands + +object CiCommand : CliktCommand( + help = "Contains command related to CI", + name = "ci" +) { + init { + subcommands(GenerateReleaseNotesCommand, NextReleaseTagCommand) + } + + @Suppress("EmptyFunctionBlock") + override fun run() { + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/ci/GenerateReleaseNotesCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/ci/GenerateReleaseNotesCommand.kt new file mode 100644 index 0000000000..3889b5d1af --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/ci/GenerateReleaseNotesCommand.kt @@ -0,0 +1,23 @@ +package flank.scripts.cli.ci + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.parameters.options.default +import com.github.ajalt.clikt.parameters.options.option +import com.github.ajalt.clikt.parameters.options.required +import com.google.common.annotations.VisibleForTesting +import flank.scripts.ops.ci.createReleaseNotes + +object GenerateReleaseNotesCommand : CliktCommand( + help = "Command to append item to release notes", + name = "generateReleaseNotes" +) { + private val token by option(help = "Git Token").required() + + @VisibleForTesting + internal val releaseNotesFile by option(help = "Path to release_notes.md") + .default("release_notes.md") + + override fun run() { + createReleaseNotes(token, releaseNotesFile) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/ci/NextReleaseTagCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/ci/NextReleaseTagCommand.kt new file mode 100644 index 0000000000..fdce451dd9 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/ci/NextReleaseTagCommand.kt @@ -0,0 +1,17 @@ +package flank.scripts.cli.ci + +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.ops.ci.createNextReleaseTag + +object NextReleaseTagCommand : CliktCommand( + help = "Print next release tag", + name = "nextReleaseTag" +) { + private val token by option(help = "Git Token").required() + + override fun run() { + createNextReleaseTag(token) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/contribution/ContributionCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/contribution/ContributionCommand.kt new file mode 100644 index 0000000000..af56159732 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/contribution/ContributionCommand.kt @@ -0,0 +1,20 @@ +package flank.scripts.cli.contribution + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.subcommands + +object ContributionCommand : CliktCommand( + name = "contribution", + help = "Tasks for assisting with contribution" +) { + init { + subcommands( + GitHooksLinkCommand, + IdeaKtlintCodeStyleCommand + ) + } + + @Suppress("EmptyFunctionBlock") + override fun run() { + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/contribution/githooks/GitHooksLinkCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/contribution/GitHooksLinkCommand.kt similarity index 51% rename from flank-scripts/src/main/kotlin/flank/scripts/contribution/githooks/GitHooksLinkCommand.kt rename to flank-scripts/src/main/kotlin/flank/scripts/cli/contribution/GitHooksLinkCommand.kt index 8bc77520db..4ef5f33eb8 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/contribution/githooks/GitHooksLinkCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/contribution/GitHooksLinkCommand.kt @@ -1,17 +1,13 @@ -package flank.scripts.contribution.githooks +package flank.scripts.cli.contribution import com.github.ajalt.clikt.core.CliktCommand -import flank.common.logLn -import flank.scripts.utils.runCommand +import flank.scripts.ops.contribution.linkGitHooks object GitHooksLinkCommand : CliktCommand( name = "linkGitHooks", help = "Creates a link for pre-commit hook for automatic linting" ) { override fun run() { - logLn("Linking Githooks.") linkGitHooks() } - - private fun linkGitHooks() = "git config --local core.hooksPath .githooks/".runCommand() } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/contribution/IdeaKtlintCodeStyleCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/contribution/IdeaKtlintCodeStyleCommand.kt new file mode 100644 index 0000000000..94260ebede --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/contribution/IdeaKtlintCodeStyleCommand.kt @@ -0,0 +1,14 @@ +package flank.scripts.cli.contribution + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.ops.contribution.applyKtlintToIdea +import kotlinx.coroutines.runBlocking + +object IdeaKtlintCodeStyleCommand : CliktCommand( + name = "applyKtlintToIdea", + help = "Applies Ktlint to this idea project forcefully" +) { + override fun run(): Unit = runBlocking { + applyKtlintToIdea() + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/dependencies/DependenciesCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/dependencies/DependenciesCommand.kt new file mode 100644 index 0000000000..e749e0183d --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/dependencies/DependenciesCommand.kt @@ -0,0 +1,17 @@ +package flank.scripts.cli.dependencies + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.subcommands + +object DependenciesCommand : CliktCommand( + name = "dependencies", + help = "Task for manages dependencies" +) { + init { + subcommands(DependenciesUpdateCommand) + } + + @Suppress("EmptyFunctionBlock") + override fun run() { + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/DependenciesUpdateCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/dependencies/DependenciesUpdateCommand.kt similarity index 53% rename from flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/DependenciesUpdateCommand.kt rename to flank-scripts/src/main/kotlin/flank/scripts/cli/dependencies/DependenciesUpdateCommand.kt index 1240e8d749..504ee210c3 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/DependenciesUpdateCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/dependencies/DependenciesUpdateCommand.kt @@ -1,36 +1,31 @@ -package flank.scripts.dependencies.update +package flank.scripts.cli.dependencies import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.parameters.options.default import com.github.ajalt.clikt.parameters.options.option import com.github.ajalt.clikt.parameters.types.file +import flank.scripts.ops.dependencies.updateAllDependencies import java.io.File object DependenciesUpdateCommand : CliktCommand(name = "update", help = "Update dependencies") { private val reportFile - by option(help = "Path to .json report file") - .file(mustExist = true) - .default(File("./report.json")) + by option(help = "Path to .json report file").file(mustExist = true).default(File("./report.json")) + private val dependenciesFile - by option(help = "Path to .kts file with dependencies defined") - .file(mustExist = true) - .default(File("./buildSrc/src/main/kotlin/Dependencies.kt")) + by option(help = "Path to .kts file with dependencies defined").file(mustExist = true).default(File("./buildSrc/src/main/kotlin/Dependencies.kt")) + private val versionsFile - by option(help = "Path to .kts file with versions defined") - .file(mustExist = true) - .default(File("./buildSrc/src/main/kotlin/Versions.kt")) + by option(help = "Path to .kts file with versions defined").file(mustExist = true).default(File("./buildSrc/src/main/kotlin/Versions.kt")) + private val pluginsFile - by option(help = "Path to .kts file with plugins defined") - .file(mustExist = true) - .default(File("./buildSrc/src/main/kotlin/Plugins.kt")) + by option(help = "Path to .kts file with plugins defined").file(mustExist = true).default(File("./buildSrc/src/main/kotlin/Plugins.kt")) override fun run() { - reportFile.updateDependencies( + reportFile.updateAllDependencies( dependenciesFile = dependenciesFile, - versionsFile = versionsFile + versionsFile = versionsFile, + pluginsFile = pluginsFile ) - reportFile.updateGradle() - reportFile.updatePlugins(pluginsFile, versionsFile) } } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/integration/IntegrationCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/integration/IntegrationCommand.kt similarity index 58% rename from flank-scripts/src/main/kotlin/flank/scripts/integration/IntegrationCommand.kt rename to flank-scripts/src/main/kotlin/flank/scripts/cli/integration/IntegrationCommand.kt index e0cb5593c2..664e543d5b 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/integration/IntegrationCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/integration/IntegrationCommand.kt @@ -1,14 +1,16 @@ -package flank.scripts.integration +package flank.scripts.cli.integration import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.subcommands -object IntegrationCommand : CliktCommand(name = "integration") { - +object IntegrationCommand : CliktCommand( + name = "integration" +) { init { subcommands(ProcessResultCommand) } @Suppress("EmptyFunctionBlock") - override fun run() {} + override fun run() { + } } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/integration/ProcessResultCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/integration/ProcessResultCommand.kt new file mode 100644 index 0000000000..7918b5d36d --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/integration/ProcessResultCommand.kt @@ -0,0 +1,43 @@ +package flank.scripts.cli.integration + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.parameters.options.default +import com.github.ajalt.clikt.parameters.options.option +import com.github.ajalt.clikt.parameters.options.required +import com.github.ajalt.clikt.parameters.types.enum +import flank.scripts.ops.integration.ITResults +import flank.scripts.ops.integration.processIntegrationTestsResult + +object ProcessResultCommand : CliktCommand( + name = "processResults" +) { + private val itResult by option( + help = "IT run job status", + names = arrayOf("--result") + ) + .enum(ignoreCase = true) + .required() + + private val buildScanURL by option( + help = "Gradle build scan URL", + names = arrayOf("--url") + ) + .default("") + + private val validatedURL: String + get() = if (buildScanURL.isBlank()) + "No build scan URL provided" else + buildScanURL + + private val githubToken by option(help = "Git Token").required() + private val runID by option(help = "Workflow job ID").required() + + override fun run() { + processIntegrationTestsResult( + result = itResult, + githubToken = githubToken, + url = validatedURL, + runID = runID + ) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/pullrequest/CopyPropertiesCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/pullrequest/CopyPropertiesCommand.kt new file mode 100644 index 0000000000..68dda97178 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/pullrequest/CopyPropertiesCommand.kt @@ -0,0 +1,20 @@ +package flank.scripts.cli.pullrequest + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.parameters.options.option +import com.github.ajalt.clikt.parameters.options.required +import com.github.ajalt.clikt.parameters.types.int +import flank.scripts.ops.pullrequest.copyGitHubProperties + +object CopyPropertiesCommand : CliktCommand( + name = "copyProperties", + help = "Copy properties from referenced issue to pull request" +) { + private val githubToken by option(help = "Git Token").required() + private val zenhubToken by option(help = "ZenHub api Token").required() + private val prNumber by option(help = "Pull request number").int().required() + + override fun run() { + copyGitHubProperties(githubToken, zenhubToken, prNumber) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/pullrequest/PullRequestCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/pullrequest/PullRequestCommand.kt new file mode 100644 index 0000000000..24af6b18d8 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/pullrequest/PullRequestCommand.kt @@ -0,0 +1,16 @@ +package flank.scripts.cli.pullrequest + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.subcommands + +object PullRequestCommand : CliktCommand( + name = "pullRequest" +) { + init { + subcommands(CopyPropertiesCommand) + } + + @Suppress("EmptyFunctionBlock") + override fun run() { + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/release/DeleteOldReleaseCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/release/DeleteOldReleaseCommand.kt new file mode 100644 index 0000000000..11eaddaf74 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/release/DeleteOldReleaseCommand.kt @@ -0,0 +1,18 @@ +package flank.scripts.cli.release + +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.ops.release.hub.deleteOldRelease + +object DeleteOldReleaseCommand : CliktCommand( + name = "deleteOldRelease", + help = "Delete old release on github" +) { + + private val gitTag by option(help = "Git Tag").required() + + override fun run() { + deleteOldRelease(gitTag) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/release/DeleteOldSnapshotCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/release/DeleteOldSnapshotCommand.kt new file mode 100644 index 0000000000..123363dd9a --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/release/DeleteOldSnapshotCommand.kt @@ -0,0 +1,17 @@ +package flank.scripts.cli.release + +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.ops.release.jfrog.jFrogDeleteOldSnapshot + +object DeleteOldSnapshotCommand : CliktCommand( + name = "jFrogDelete", + help = "Delete old version on bintray" +) { + private val version by option(help = "Maven version to delete").required() + + override fun run() { + jFrogDeleteOldSnapshot(version) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/release/DeleteOldTagCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/release/DeleteOldTagCommand.kt new file mode 100644 index 0000000000..3d6dda151a --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/release/DeleteOldTagCommand.kt @@ -0,0 +1,19 @@ +package flank.scripts.cli.release + +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.ops.release.hub.tryDeleteOldTag + +object DeleteOldTagCommand : CliktCommand( + name = "deleteOldTag", + help = "Delete old tag on GitHub" +) { + private val gitTag by option(help = "Git Tag").required() + private val username by option(help = "Git User").required() + private val token by option(help = "Git Token").required() + + override fun run() { + tryDeleteOldTag(gitTag, username, token) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/release/ReleaseCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/release/ReleaseCommand.kt new file mode 100644 index 0000000000..8b4edfdc49 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/release/ReleaseCommand.kt @@ -0,0 +1,23 @@ +package flank.scripts.cli.release + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.subcommands + +object ReleaseCommand : CliktCommand( + name = "release", + help = "Contains all release commands" +) { + init { + subcommands( + ReleaseFlankCommand, + DeleteOldSnapshotCommand, + SyncMavenCommand, + DeleteOldReleaseCommand, + DeleteOldTagCommand + ) + } + + @Suppress("EmptyFunctionBlock") + override fun run() { + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/release/hub/ReleaseFlankCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/release/ReleaseFlankCommand.kt similarity index 50% rename from flank-scripts/src/main/kotlin/flank/scripts/release/hub/ReleaseFlankCommand.kt rename to flank-scripts/src/main/kotlin/flank/scripts/cli/release/ReleaseFlankCommand.kt index a912cef086..4e59623cfb 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/release/hub/ReleaseFlankCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/release/ReleaseFlankCommand.kt @@ -1,4 +1,4 @@ -package flank.scripts.release.hub +package flank.scripts.cli.release import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.parameters.options.default @@ -6,28 +6,24 @@ import com.github.ajalt.clikt.parameters.options.flag import com.github.ajalt.clikt.parameters.options.option import com.github.ajalt.clikt.parameters.options.required import com.github.ajalt.clikt.parameters.types.path -import flank.scripts.utils.ERROR_WHEN_RUNNING +import flank.scripts.ops.release.hub.tryReleaseFlank import kotlin.system.exitProcess -class ReleaseFlankCommand : CliktCommand(name = "releaseFlank", help = "Release Flank on GitHub") { +object ReleaseFlankCommand : CliktCommand( + name = "releaseFlank", + help = "Release Flank on GitHub" +) { + private val inputFile by option(help = "Path to release file") + .path(mustExist = true).required() + + private val snapshot by option(help = "Is Snapshot release") + .flag(default = false) - private val inputFile by option(help = "Path to release file").path(mustExist = true).required() - private val snapshot by option(help = "Is Snapshot release").flag(default = false) private val gitTag by option(help = "Git Tag").required() private val commitHash by option(help = "Git Commit hash").default("") private val token by option(help = "Git Token").default("") override fun run() { - when { - snapshot && commitHash.isBlank() -> { - println("Commit hash is required for snapshot release") - exitProcess(ERROR_WHEN_RUNNING) - } - !snapshot && token.isBlank() -> { - println("Git hub token is required for stable release") - exitProcess(ERROR_WHEN_RUNNING) - } - else -> exitProcess(releaseFlank(inputFile, gitTag, commitHash, snapshot, token)) - } + exitProcess(tryReleaseFlank(inputFile, gitTag, commitHash, snapshot, token)) } } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/release/jfrog/sync/SyncMaven.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/release/SyncMavenCommand.kt similarity index 50% rename from flank-scripts/src/main/kotlin/flank/scripts/release/jfrog/sync/SyncMaven.kt rename to flank-scripts/src/main/kotlin/flank/scripts/cli/release/SyncMavenCommand.kt index e26a16b0d1..9b2ebd1cbd 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/release/jfrog/sync/SyncMaven.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/release/SyncMavenCommand.kt @@ -1,19 +1,18 @@ -package flank.scripts.release.jfrog.sync +package flank.scripts.cli.release 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.release.jfrog.flankMaven -import flank.scripts.utils.runCommand +import flank.scripts.ops.release.jfrog.jFrogSync import kotlin.system.exitProcess -class SyncMavenCommand : CliktCommand(name = "jFrogSync", help = "Sync maven repository using jfrog") { - +object SyncMavenCommand : CliktCommand( + name = "jFrogSync", + help = "Sync maven repository using jfrog" +) { private val mavenTag by option(help = "Maven Tag").required() override fun run() { exitProcess(jFrogSync(mavenTag)) } } - -fun jFrogSync(mavenTag: String) = "jfrog bt mcs ${flankMaven(mavenTag)}".runCommand(retryCount = 5) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/BuildFlankCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/BuildFlankCommand.kt new file mode 100644 index 0000000000..bcd364fe9b --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/BuildFlankCommand.kt @@ -0,0 +1,13 @@ +package flank.scripts.cli.shell + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.ops.shell.buildFlank + +object BuildFlankCommand : CliktCommand( + name = "buildFlank", + help = "Build Flank" +) { + override fun run() { + buildFlank() + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/BuildFtlCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/BuildFtlCommand.kt new file mode 100644 index 0000000000..be0efffaca --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/BuildFtlCommand.kt @@ -0,0 +1,13 @@ +package flank.scripts.cli.shell + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.ops.shell.ios.buildFtl + +object BuildFtlCommand : CliktCommand( + name = "iosBuildFtl", + help = "Build ftl ios app" +) { + override fun run() { + buildFtl() + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/InstallXcPrettyCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/InstallXcPrettyCommand.kt new file mode 100644 index 0000000000..09c5ffffd8 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/InstallXcPrettyCommand.kt @@ -0,0 +1,13 @@ +package flank.scripts.cli.shell + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.ops.shell.installXcPretty + +object InstallXcPrettyCommand : CliktCommand( + name = "install_xcpretty", + help = "Build ios app with tests" +) { + override fun run() { + installXcPretty() + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/RunFtlLocalCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/RunFtlLocalCommand.kt new file mode 100644 index 0000000000..44eada98a0 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/RunFtlLocalCommand.kt @@ -0,0 +1,19 @@ +package flank.scripts.cli.shell + +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.ops.shell.ios.runFtlLocal + +object RunFtlLocalCommand : CliktCommand( + name = "iosRunFtlLocal", + help = "Run ftl locally ios app" +) { + private val deviceId by option( + help = "Device id. Please take it from Xcode -> Window -> Devices and Simulators" + ).required() + + override fun run() { + runFtlLocal(deviceId) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/SetupIosEnvCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/SetupIosEnvCommand.kt new file mode 100644 index 0000000000..bd54bce220 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/SetupIosEnvCommand.kt @@ -0,0 +1,13 @@ +package flank.scripts.cli.shell + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.ops.shell.setupIosEnv + +object SetupIosEnvCommand : CliktCommand( + name = "setup_ios_env", + help = "Build ios app with tests" +) { + override fun run() { + setupIosEnv() + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/ShellCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/ShellCommand.kt new file mode 100644 index 0000000000..2c499a010a --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/ShellCommand.kt @@ -0,0 +1,31 @@ +package flank.scripts.cli.shell + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.subcommands +import flank.scripts.cli.shell.buildexample.BuildExampleCommand +import flank.scripts.cli.shell.buildexample.OpsCommand +import flank.scripts.cli.shell.firebase.FirebaseCommand + +object ShellCommand : CliktCommand( + name = "shell", + help = "Task for shell commands" +) { + init { + subcommands( + BuildFlankCommand, + FirebaseCommand, + OpsCommand, + BuildExampleCommand, + BuildFtlCommand, + InstallXcPrettyCommand, + RunFtlLocalCommand, + SetupIosEnvCommand, + UniversalFrameworkCommand, + UpdateBinariesCommand + ) + } + + @Suppress("EmptyFunctionBlock") + override fun run() { + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/UniversalFrameworkCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/UniversalFrameworkCommand.kt new file mode 100644 index 0000000000..1a5dc42167 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/UniversalFrameworkCommand.kt @@ -0,0 +1,13 @@ +package flank.scripts.cli.shell + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.ops.shell.ios.createUniversalFrameworkFiles + +object UniversalFrameworkCommand : CliktCommand( + name = "iosUniversalFramework", + help = "Create Universal Framework" +) { + override fun run() { + createUniversalFrameworkFiles() + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/UpdateBinariesCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/UpdateBinariesCommand.kt new file mode 100644 index 0000000000..66ffa92f09 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/UpdateBinariesCommand.kt @@ -0,0 +1,13 @@ +package flank.scripts.cli.shell + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.ops.shell.updatebinaries.updateBinaries + +object UpdateBinariesCommand : CliktCommand( + name = "updateBinaries", + help = "Update binaries used by Flank" +) { + override fun run() { + updateBinaries() + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/AndroidOpsCommand.kt similarity index 55% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt rename to flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/AndroidOpsCommand.kt index d837f45723..bfb9a4261e 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/AndroidOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/AndroidOpsCommand.kt @@ -1,26 +1,25 @@ -package flank.scripts.shell.ops +package flank.scripts.cli.shell.buildexample 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.ops.shell.buildexample.android.AndroidBuildConfiguration +import flank.scripts.ops.shell.buildexample.android.runAndroidBuild -object AndroidOpsCommand : CliktCommand(name = "android", help = "Build android apks with tests") { +object AndroidOpsCommand : CliktCommand( + name = "android", + help = "Build android apks 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) private val artifacts: List by option().multiple() override fun run() { - if (generate.not()) return - AndroidBuildConfiguration(artifacts, generate, copy).run { - buildBaseApk() - buildBaseTestApk() - buildDuplicatedNamesApks() - buildMultiModulesApks() - buildCucumberSampleApp() - } + AndroidBuildConfiguration(artifacts, generate, copy).runAndroidBuild() } } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/BuildEarlGreyExampleCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/BuildEarlGreyExampleCommand.kt new file mode 100644 index 0000000000..c23ff59d5c --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/BuildEarlGreyExampleCommand.kt @@ -0,0 +1,21 @@ +package flank.scripts.cli.shell.buildexample + +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.ops.shell.buildexample.ios.buildEarlGreyExample + +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) + + private val copy: Boolean? by option(help = "Copy output files to tmp") + .flag("-c", default = true) + + override fun run() { + buildEarlGreyExample(generate, copy) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/BuildExampleCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/BuildExampleCommand.kt new file mode 100644 index 0000000000..a879465ab1 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/BuildExampleCommand.kt @@ -0,0 +1,13 @@ +package flank.scripts.cli.shell.buildexample + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.ops.shell.ios.buildIosExample + +object BuildExampleCommand : CliktCommand( + name = "iosBuildExample", + help = "Build example ios app" +) { + override fun run() { + buildIosExample() + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/BuildFlankExampleCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/BuildFlankExampleCommand.kt new file mode 100644 index 0000000000..b9edd34a37 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/BuildFlankExampleCommand.kt @@ -0,0 +1,21 @@ +package flank.scripts.cli.shell.buildexample + +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.ops.shell.buildexample.ios.buildIosFlankExample + +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() { + buildIosFlankExample(generate, copy) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/BuildGameLoopExampleCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/BuildGameLoopExampleCommand.kt new file mode 100644 index 0000000000..35ccaf4eb4 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/BuildGameLoopExampleCommand.kt @@ -0,0 +1,21 @@ +package flank.scripts.cli.shell.buildexample + +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.ops.shell.buildexample.ios.buildIosGameLoopExampleCommand + +object BuildGameLoopExampleCommand : CliktCommand( + name = "build_ios_gameloop_example", + help = "Build ios game loop example app" +) { + 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() { + buildIosGameLoopExampleCommand(generate, copy) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/BuildTestPlansExample.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/BuildTestPlansExample.kt new file mode 100644 index 0000000000..1fff556333 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/BuildTestPlansExample.kt @@ -0,0 +1,21 @@ +package flank.scripts.cli.shell.buildexample + +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.ops.shell.buildexample.ios.buildTestPlansExample + +object BuildTestPlansExample : CliktCommand( + name = "build_ios_testplans_example", + help = "Build ios test plans example app" +) { + 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() { + buildTestPlansExample(generate, copy) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/GoOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/GoOpsCommand.kt new file mode 100644 index 0000000000..8cf9541a10 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/GoOpsCommand.kt @@ -0,0 +1,13 @@ +package flank.scripts.cli.shell.buildexample + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.ops.shell.buildexample.go.generateGoArtifacts + +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/cli/shell/buildexample/IosOpsCommand.kt similarity index 87% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt rename to flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/IosOpsCommand.kt index d2753333cb..214c721ceb 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/IosOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/IosOpsCommand.kt @@ -1,4 +1,4 @@ -package flank.scripts.shell.ops +package flank.scripts.cli.shell.buildexample import com.github.ajalt.clikt.core.CliktCommand @@ -6,7 +6,6 @@ object IosOpsCommand : CliktCommand( name = "ios", help = "Build ios test artifacts" ) { - override fun run() = listOf( BuildEarlGreyExampleCommand, BuildTestPlansExample, diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/OpsCommand.kt similarity index 69% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt rename to flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/OpsCommand.kt index 55bd47c547..b624d59879 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/OpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/buildexample/OpsCommand.kt @@ -1,9 +1,12 @@ -package flank.scripts.shell.ops +package flank.scripts.cli.shell.buildexample import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.subcommands -object 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, @@ -17,5 +20,6 @@ object OpsCommand : CliktCommand(name = "ops", help = "Contains all ops command: } @Suppress("EmptyFunctionBlock") - override fun run() {} + override fun run() { + } } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/firebase/CheckForSdkUpdateCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/firebase/CheckForSdkUpdateCommand.kt new file mode 100644 index 0000000000..db17a8a553 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/firebase/CheckForSdkUpdateCommand.kt @@ -0,0 +1,18 @@ +package flank.scripts.cli.shell.firebase + +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.ops.shell.firebase.sdk.checkForSDKUpdate + +object CheckForSdkUpdateCommand : CliktCommand( + name = "checkForSdkUpdate", + help = "Verifies if there were changes in gcloud sdk that need to be implemented in flank" +) { + private val githubToken by option(help = "Git Token").required() + private val zenhubToken by option(help = "Zenhub Token").required() + + override fun run() { + checkForSDKUpdate(githubToken, zenhubToken) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/firebase/FirebaseCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/firebase/FirebaseCommand.kt new file mode 100644 index 0000000000..27484bb969 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/firebase/FirebaseCommand.kt @@ -0,0 +1,21 @@ +package flank.scripts.cli.shell.firebase + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.subcommands + +object FirebaseCommand : CliktCommand( + name = "firebase", + help = "Contains all firebase commands" +) { + init { + subcommands( + UpdateApiJsonCommand, + GenerateJavaClientCommand, + CheckForSdkUpdateCommand + ) + } + + @Suppress("EmptyFunctionBlock") + override fun run() { + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/firebase/GenerateJavaClientCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/firebase/GenerateJavaClientCommand.kt new file mode 100644 index 0000000000..fe141a9c41 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/firebase/GenerateJavaClientCommand.kt @@ -0,0 +1,13 @@ +package flank.scripts.cli.shell.firebase + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.ops.shell.firebase.apiclient.generateJavaClient + +object GenerateJavaClientCommand : CliktCommand( + name = "generateJavaClient", + help = "Generate Java Client" +) { + override fun run() { + generateJavaClient() + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/firebase/UpdateApiJsonCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/firebase/UpdateApiJsonCommand.kt new file mode 100644 index 0000000000..70d43040ea --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/shell/firebase/UpdateApiJsonCommand.kt @@ -0,0 +1,13 @@ +package flank.scripts.cli.shell.firebase + +import com.github.ajalt.clikt.core.CliktCommand +import flank.scripts.ops.shell.firebase.apiclient.updateApiJson + +object UpdateApiJsonCommand : CliktCommand( + name = "updateApiJson", + help = "Download file for generating client" +) { + override fun run() { + updateApiJson() + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/DownloadCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/DownloadCommand.kt new file mode 100644 index 0000000000..d36c0fb0c9 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/DownloadCommand.kt @@ -0,0 +1,23 @@ +package flank.scripts.cli.testartifacts + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.requireObject +import com.github.ajalt.clikt.parameters.options.flag +import com.github.ajalt.clikt.parameters.options.option +import flank.scripts.ops.testartifacts.Context +import flank.scripts.ops.testartifacts.downloadFixtures + +object DownloadCommand : CliktCommand( + help = "Download test artifacts zip asset to test_artifacts directory." +) { + private val artifacts by requireObject() + + private val overwrite by option( + "--overwrite", "-o", + help = "Flag which indicates if should overwrite old resources when downloading" + ).flag() + + override fun run() { + artifacts.downloadFixtures(overwrite) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/LinkCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/LinkCommand.kt new file mode 100644 index 0000000000..e74e82127f --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/LinkCommand.kt @@ -0,0 +1,16 @@ +package flank.scripts.cli.testartifacts + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.requireObject +import flank.scripts.ops.testartifacts.Context +import flank.scripts.ops.testartifacts.linkArtifacts + +object LinkCommand : CliktCommand( + help = "Create symbolic link to under test_runner/src/test/kotlin/ftl/fixtures/tmp to test_artifacts/{branchName}." +) { + private val artifacts by requireObject() + + override fun run() { + artifacts.linkArtifacts() + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/PrepareCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/PrepareCommand.kt new file mode 100644 index 0000000000..cb4e6e6281 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/PrepareCommand.kt @@ -0,0 +1,23 @@ +package flank.scripts.cli.testartifacts + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.requireObject +import com.github.ajalt.clikt.parameters.options.default +import com.github.ajalt.clikt.parameters.options.option +import flank.scripts.ops.testartifacts.Context +import flank.scripts.ops.testartifacts.prepareTestArtifacts + +object PrepareCommand : CliktCommand( + help = "Creates fresh copy of test artifacts for current working branch, basing on existing one." +) { + val artifacts by requireObject() + + val source by option( + "--src", "-s", + help = "The name of branch that identify artifacts source. The master branch is a default." + ).default("master") + + override fun run() { + artifacts.prepareTestArtifacts(source) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/RemoveCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/RemoveCommand.kt new file mode 100644 index 0000000000..b4eb885d06 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/RemoveCommand.kt @@ -0,0 +1,16 @@ +package flank.scripts.cli.testartifacts + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.requireObject +import flank.scripts.ops.testartifacts.Context +import flank.scripts.ops.testartifacts.removeRemoteCopy + +object RemoveCommand : CliktCommand( + help = "Remove remote copy of test artifacts." +) { + val artifacts by requireObject() + + override fun run() { + artifacts.removeRemoteCopy() + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/ResolveCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/ResolveCommand.kt new file mode 100644 index 0000000000..0f8719b9bc --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/ResolveCommand.kt @@ -0,0 +1,16 @@ +package flank.scripts.cli.testartifacts + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.requireObject +import flank.scripts.ops.testartifacts.Context +import flank.scripts.ops.testartifacts.resolveArtifacts + +object ResolveCommand : CliktCommand( + help = "Automatically prepare local artifacts if needed." +) { + val artifacts by requireObject() + + override fun run() { + artifacts.resolveArtifacts() + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/TestArtifactsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/TestArtifactsCommand.kt new file mode 100644 index 0000000000..2fd605f175 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/TestArtifactsCommand.kt @@ -0,0 +1,51 @@ +package flank.scripts.cli.testartifacts + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.findOrSetObject +import com.github.ajalt.clikt.core.subcommands +import com.github.ajalt.clikt.parameters.options.defaultLazy +import com.github.ajalt.clikt.parameters.options.option +import com.github.ajalt.clikt.parameters.types.file +import flank.scripts.ops.testartifacts.Context +import flank.scripts.ops.testartifacts.flankRoot +import flank.scripts.utils.currentGitBranch +import java.io.File + +object TestArtifactsCommand : CliktCommand( + name = "testArtifacts", + help = "The base command for artifacts management." +) { + private val branch: String by option( + "--branch", "-b", + help = "Branch name that identify test artifacts to operate. The current git branch is a default." + ).defaultLazy { currentGitBranch() } + + private val projectRoot: File by option( + "--project-root", "-p", + help = "Path to local project repository root. By default it is resolved from FLANK_ROOT env variable." + ).file().defaultLazy { flankRoot() } + + private val artifacts by findOrSetObject { + Context( + branch = branch, + projectRoot = projectRoot + ) + } + + init { + subcommands( + DownloadCommand, + UploadCommand, + PrepareCommand, + ZipCommand, + UnzipCommand, + LinkCommand, + RemoveCommand, + ResolveCommand + ) + } + + override fun run() { + artifacts + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/UnzipCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/UnzipCommand.kt new file mode 100644 index 0000000000..417f8a46c8 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/UnzipCommand.kt @@ -0,0 +1,16 @@ +package flank.scripts.cli.testartifacts + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.requireObject +import flank.scripts.ops.testartifacts.Context +import flank.scripts.ops.testartifacts.unzipTestArtifacts + +object UnzipCommand : CliktCommand( + help = "Unpack test artifacts zip archive." +) { + val artifacts by requireObject() + + override fun run() { + artifacts.unzipTestArtifacts() + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/UploadCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/UploadCommand.kt new file mode 100644 index 0000000000..d633004208 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/UploadCommand.kt @@ -0,0 +1,16 @@ +package flank.scripts.cli.testartifacts + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.requireObject +import flank.scripts.ops.testartifacts.Context +import flank.scripts.ops.testartifacts.uploadFixtures + +object UploadCommand : CliktCommand( + help = "Upload test artifacts zip as github release asset." +) { + val artifacts by requireObject() + + override fun run() { + artifacts.uploadFixtures() + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/ZipCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/ZipCommand.kt new file mode 100644 index 0000000000..6399ccab32 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/testartifacts/ZipCommand.kt @@ -0,0 +1,16 @@ +package flank.scripts.cli.testartifacts + +import com.github.ajalt.clikt.core.CliktCommand +import com.github.ajalt.clikt.core.requireObject +import flank.scripts.ops.testartifacts.Context +import flank.scripts.ops.testartifacts.zipTestArtifacts + +object ZipCommand : CliktCommand( + help = "Create zip archive from test artifacts directory." +) { + val artifacts by requireObject() + + override fun run() { + artifacts.zipTestArtifacts() + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/contribution/ContributionCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/contribution/ContributionCommand.kt deleted file mode 100644 index adeb376619..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/contribution/ContributionCommand.kt +++ /dev/null @@ -1,18 +0,0 @@ -package flank.scripts.contribution - -import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.clikt.core.subcommands -import flank.scripts.contribution.githooks.GitHooksLinkCommand -import flank.scripts.contribution.ideaktlint.IdeaKtlintCodeStyleCommand - -object ContributionCommand : CliktCommand(name = "contribution", help = "Tasks for assisting with contribution") { - init { - subcommands( - GitHooksLinkCommand, - IdeaKtlintCodeStyleCommand - ) - } - - @Suppress("EmptyFunctionBlock") - override fun run() {} -} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/contribution/ideaktlint/IdeaKtlintCodeStyleCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/contribution/ideaktlint/IdeaKtlintCodeStyleCommand.kt deleted file mode 100644 index e9b87f5cf8..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/contribution/ideaktlint/IdeaKtlintCodeStyleCommand.kt +++ /dev/null @@ -1,43 +0,0 @@ -package flank.scripts.contribution.ideaktlint - -import com.github.ajalt.clikt.core.CliktCommand -import flank.common.currentPath -import flank.common.deleteFile -import flank.common.downloadFile -import flank.common.goToRoot -import flank.common.logLn -import flank.scripts.utils.isWindows -import flank.scripts.utils.runCommand -import kotlinx.coroutines.runBlocking - -object IdeaKtlintCodeStyleCommand : CliktCommand( - name = "applyKtlintToIdea", - help = "Applies Ktlint to this idea project forcefully" -) { - override fun run(): Unit = runBlocking { - logLn("Applying Ktlint code style to this idea project") - logLn("Retrieving Ktlint...") - retrieveKtlintResolveCommand() - applyKtlintToIdea() - } - - private fun applyKtlintToIdea() { - applyKtlintToIdeaCommand() - tryCleanupKtlint() - } - - private fun applyKtlintToIdeaCommand() = - "java -jar ktlint applyToIDEAProject -y".runCommand(executionDirectory = getRootDirFile()) - - private fun tryCleanupKtlint() { - logLn("Cleanup Ktlint leftover files...") - (getKtlintFilePath()).deleteFile() - } - - private suspend fun retrieveKtlintResolveCommand() = - "https://github.com/pinterest/ktlint/releases/download/0.40.0/ktlint".downloadFile(getKtlintFilePath()) - - private fun getKtlintFilePath() = getRootPathString() + (if (isWindows) "\\" else "/") + "ktlint" - private fun getRootPathString() = goToRoot(currentPath).toAbsolutePath().toString() - private fun getRootDirFile() = goToRoot(currentPath).toAbsolutePath().toFile() -} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/GitHubErrorResponse.kt b/flank-scripts/src/main/kotlin/flank/scripts/data/github/GitHubErrorResponse.kt similarity index 87% rename from flank-scripts/src/main/kotlin/flank/scripts/github/GitHubErrorResponse.kt rename to flank-scripts/src/main/kotlin/flank/scripts/data/github/GitHubErrorResponse.kt index bad2c05ae9..4911623ba1 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/GitHubErrorResponse.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/data/github/GitHubErrorResponse.kt @@ -1,4 +1,4 @@ -package flank.scripts.github +package flank.scripts.data.github import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt b/flank-scripts/src/main/kotlin/flank/scripts/data/github/GithubApi.kt similarity index 83% rename from flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt rename to flank-scripts/src/main/kotlin/flank/scripts/data/github/GithubApi.kt index 833e55de34..30dbb80e00 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/data/github/GithubApi.kt @@ -1,4 +1,4 @@ -package flank.scripts.github +package flank.scripts.data.github import com.github.kittinunf.fuel.Fuel import com.github.kittinunf.fuel.core.Parameters @@ -15,28 +15,27 @@ import com.jcabi.github.Releases import com.jcabi.github.Repo import com.jcabi.github.RtGithub import flank.common.config.flankRepository -import flank.scripts.ci.releasenotes.GitHubRelease -import flank.scripts.ci.releasenotes.GithubReleaseDeserializable -import flank.scripts.exceptions.mapClientErrorToGithubException -import flank.scripts.github.objects.GitHubCommit -import flank.scripts.github.objects.GitHubCommitListDeserializer -import flank.scripts.github.objects.GitHubCreateIssueCommentRequest -import flank.scripts.github.objects.GitHubCreateIssueCommentResponse -import flank.scripts.github.objects.GitHubCreateIssueCommentResponseDeserializer -import flank.scripts.github.objects.GitHubCreateIssueRequest -import flank.scripts.github.objects.GitHubCreateIssueResponse -import flank.scripts.github.objects.GitHubCreateIssueResponseDeserializer -import flank.scripts.github.objects.GitHubLabelDeserializable -import flank.scripts.github.objects.GitHubSetAssigneesRequest -import flank.scripts.github.objects.GitHubSetLabelsRequest -import flank.scripts.github.objects.GitHubUpdateIssueRequest -import flank.scripts.github.objects.GitHubWorkflowRunsSummary -import flank.scripts.github.objects.GithubPullRequest -import flank.scripts.github.objects.GithubPullRequestDeserializer -import flank.scripts.github.objects.GithubPullRequestListDeserializer -import flank.scripts.github.objects.GithubWorkflowRunsSummaryDeserializer +import flank.scripts.data.github.objects.GitHubCommit +import flank.scripts.data.github.objects.GitHubCommitListDeserializer +import flank.scripts.data.github.objects.GitHubCreateIssueCommentRequest +import flank.scripts.data.github.objects.GitHubCreateIssueCommentResponse +import flank.scripts.data.github.objects.GitHubCreateIssueCommentResponseDeserializer +import flank.scripts.data.github.objects.GitHubCreateIssueRequest +import flank.scripts.data.github.objects.GitHubCreateIssueResponse +import flank.scripts.data.github.objects.GitHubCreateIssueResponseDeserializer +import flank.scripts.data.github.objects.GitHubLabelDeserializable +import flank.scripts.data.github.objects.GitHubRelease +import flank.scripts.data.github.objects.GitHubSetAssigneesRequest +import flank.scripts.data.github.objects.GitHubSetLabelsRequest +import flank.scripts.data.github.objects.GitHubUpdateIssueRequest +import flank.scripts.data.github.objects.GitHubWorkflowRunsSummary +import flank.scripts.data.github.objects.GithubPullRequest +import flank.scripts.data.github.objects.GithubPullRequestDeserializer +import flank.scripts.data.github.objects.GithubPullRequestListDeserializer +import flank.scripts.data.github.objects.GithubReleaseDeserializable +import flank.scripts.data.github.objects.GithubWorkflowRunsSummaryDeserializer +import flank.scripts.utils.exceptions.mapClientErrorToGithubException import flank.scripts.utils.toJson -import java.lang.Exception private const val URL_BASE = "https://api.github.com/repos" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/commons/LastWorkflowRunDate.kt b/flank-scripts/src/main/kotlin/flank/scripts/data/github/commons/LastWorkflowRunDate.kt similarity index 88% rename from flank-scripts/src/main/kotlin/flank/scripts/github/commons/LastWorkflowRunDate.kt rename to flank-scripts/src/main/kotlin/flank/scripts/data/github/commons/LastWorkflowRunDate.kt index cf1c5d6030..08ae72f189 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/commons/LastWorkflowRunDate.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/data/github/commons/LastWorkflowRunDate.kt @@ -1,8 +1,8 @@ -package flank.scripts.github.commons +package flank.scripts.data.github.commons import com.github.kittinunf.result.getOrNull -import flank.scripts.github.getGitHubWorkflowRunsSummary -import flank.scripts.github.objects.GitHubWorkflowRun +import flank.scripts.data.github.getGitHubWorkflowRunsSummary +import flank.scripts.data.github.objects.GitHubWorkflowRun import java.time.Instant import java.time.format.DateTimeFormatter diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubCommit.kt b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubCommit.kt similarity index 93% rename from flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubCommit.kt rename to flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubCommit.kt index 432b9a3ae1..54b1d62390 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubCommit.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubCommit.kt @@ -1,4 +1,4 @@ -package flank.scripts.github.objects +package flank.scripts.data.github.objects import com.github.kittinunf.fuel.core.ResponseDeserializable import flank.scripts.utils.toObject diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubCreateIssue.kt b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubCreateIssue.kt similarity index 94% rename from flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubCreateIssue.kt rename to flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubCreateIssue.kt index d7ea76c249..6e0af949d8 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubCreateIssue.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubCreateIssue.kt @@ -1,4 +1,4 @@ -package flank.scripts.github.objects +package flank.scripts.data.github.objects import com.github.kittinunf.fuel.core.ResponseDeserializable import flank.scripts.utils.toObject diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubCreateIssueComment.kt b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubCreateIssueComment.kt similarity index 93% rename from flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubCreateIssueComment.kt rename to flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubCreateIssueComment.kt index 2f9fdcc4d1..bc18584f01 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubCreateIssueComment.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubCreateIssueComment.kt @@ -1,4 +1,4 @@ -package flank.scripts.github.objects +package flank.scripts.data.github.objects import com.github.kittinunf.fuel.core.ResponseDeserializable import flank.scripts.utils.toObject diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/GitHubRelease.kt b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubRelease.kt similarity index 91% rename from flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/GitHubRelease.kt rename to flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubRelease.kt index 82c214d3e2..07b0836e16 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/GitHubRelease.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubRelease.kt @@ -1,4 +1,4 @@ -package flank.scripts.ci.releasenotes +package flank.scripts.data.github.objects import com.github.kittinunf.fuel.core.ResponseDeserializable import flank.scripts.utils.toObject diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubSetAssigneesRequest.kt b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubSetAssigneesRequest.kt similarity index 75% rename from flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubSetAssigneesRequest.kt rename to flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubSetAssigneesRequest.kt index 56da1afdf9..116f51c7fa 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubSetAssigneesRequest.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubSetAssigneesRequest.kt @@ -1,4 +1,4 @@ -package flank.scripts.github.objects +package flank.scripts.data.github.objects import kotlinx.serialization.Serializable diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubSetLabelsRequest.kt b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubSetLabelsRequest.kt similarity index 74% rename from flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubSetLabelsRequest.kt rename to flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubSetLabelsRequest.kt index bb5300149a..102dd66041 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubSetLabelsRequest.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubSetLabelsRequest.kt @@ -1,4 +1,4 @@ -package flank.scripts.github.objects +package flank.scripts.data.github.objects import kotlinx.serialization.Serializable diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubUpdateIssue.kt b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubUpdateIssue.kt similarity index 91% rename from flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubUpdateIssue.kt rename to flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubUpdateIssue.kt index ca5ba6f929..3ef139b19d 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubUpdateIssue.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubUpdateIssue.kt @@ -1,4 +1,4 @@ -package flank.scripts.github.objects +package flank.scripts.data.github.objects import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubWorkflowRun.kt b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubWorkflowRun.kt similarity index 94% rename from flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubWorkflowRun.kt rename to flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubWorkflowRun.kt index 208c617e63..83ed5ada36 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubWorkflowRun.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GitHubWorkflowRun.kt @@ -1,4 +1,4 @@ -package flank.scripts.github.objects +package flank.scripts.data.github.objects import com.github.kittinunf.fuel.core.ResponseDeserializable import flank.scripts.utils.toObject diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GithubPullRequest.kt b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GithubPullRequest.kt similarity index 96% rename from flank-scripts/src/main/kotlin/flank/scripts/github/objects/GithubPullRequest.kt rename to flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GithubPullRequest.kt index b7c88687ce..2cfa586791 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GithubPullRequest.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/data/github/objects/GithubPullRequest.kt @@ -1,4 +1,4 @@ -package flank.scripts.github.objects +package flank.scripts.data.github.objects import com.github.kittinunf.fuel.core.ResponseDeserializable import flank.scripts.utils.toObject diff --git a/flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubAPI.kt b/flank-scripts/src/main/kotlin/flank/scripts/data/zenhub/ZenHubAPI.kt similarity index 94% rename from flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubAPI.kt rename to flank-scripts/src/main/kotlin/flank/scripts/data/zenhub/ZenHubAPI.kt index 2e5a4faff6..2ff5bf0c94 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubAPI.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/data/zenhub/ZenHubAPI.kt @@ -1,4 +1,4 @@ -package flank.scripts.zenhub +package flank.scripts.data.zenhub import com.github.kittinunf.fuel.Fuel import com.github.kittinunf.fuel.core.Request @@ -8,9 +8,9 @@ import com.github.kittinunf.result.getOrNull import com.github.kittinunf.result.onError import com.github.kittinunf.result.success import flank.common.config.zenhubRepositoryID +import flank.scripts.data.zenhub.objects.ConvertToEpicRequest +import flank.scripts.data.zenhub.objects.UpdateEpicRequest import flank.scripts.utils.toJson -import flank.scripts.zenhub.objects.ConvertToEpicRequest -import flank.scripts.zenhub.objects.UpdateEpicRequest import kotlinx.serialization.Serializable internal val ZENHUB_BASE_URL = "https://api.zenhub.com/p1/repositories/$zenhubRepositoryID" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubIssue.kt b/flank-scripts/src/main/kotlin/flank/scripts/data/zenhub/ZenHubIssue.kt similarity index 92% rename from flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubIssue.kt rename to flank-scripts/src/main/kotlin/flank/scripts/data/zenhub/ZenHubIssue.kt index 011b522c8e..c3967dcd10 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubIssue.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/data/zenhub/ZenHubIssue.kt @@ -1,4 +1,4 @@ -package flank.scripts.zenhub +package flank.scripts.data.zenhub import com.github.kittinunf.fuel.core.ResponseDeserializable import flank.scripts.utils.toObject diff --git a/flank-scripts/src/main/kotlin/flank/scripts/zenhub/objects/ConvertToEpicRequest.kt b/flank-scripts/src/main/kotlin/flank/scripts/data/zenhub/objects/ConvertToEpicRequest.kt similarity index 92% rename from flank-scripts/src/main/kotlin/flank/scripts/zenhub/objects/ConvertToEpicRequest.kt rename to flank-scripts/src/main/kotlin/flank/scripts/data/zenhub/objects/ConvertToEpicRequest.kt index 8274751b46..95a677c180 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/zenhub/objects/ConvertToEpicRequest.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/data/zenhub/objects/ConvertToEpicRequest.kt @@ -1,4 +1,4 @@ -package flank.scripts.zenhub.objects +package flank.scripts.data.zenhub.objects import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/DependenciesCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/dependencies/DependenciesCommand.kt deleted file mode 100644 index 47e63fc872..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/DependenciesCommand.kt +++ /dev/null @@ -1,15 +0,0 @@ -package flank.scripts.dependencies - -import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.clikt.core.subcommands -import flank.scripts.dependencies.update.DependenciesUpdateCommand - -object DependenciesCommand : CliktCommand(name = "dependencies", help = "Task for manages dependencies") { - - init { - subcommands(DependenciesUpdateCommand) - } - - @Suppress("EmptyFunctionBlock") - override fun run() {} -} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/integration/ProcessResultCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/integration/ProcessResultCommand.kt deleted file mode 100644 index 323d4bd341..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/integration/ProcessResultCommand.kt +++ /dev/null @@ -1,64 +0,0 @@ -@file:Suppress("EXPERIMENTAL_API_USAGE") - -package flank.scripts.integration - -import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.clikt.parameters.options.default -import com.github.ajalt.clikt.parameters.options.option -import com.github.ajalt.clikt.parameters.options.required -import com.github.ajalt.clikt.parameters.types.enum -import kotlinx.coroutines.runBlocking - -object ProcessResultCommand : CliktCommand(name = "processResults") { - - private val itResult by option(help = "IT run job status", names = arrayOf("--result")) - .enum(ignoreCase = true) - .required() - - private val buildScanURL by option(help = "Gradle build scan URL", names = arrayOf("--url")) - .default("") - - private val validatedURL: String - get() = if (buildScanURL.isBlank()) "No build scan URL provided" else buildScanURL - - private val githubToken by option(help = "Git Token").required() - private val runID by option(help = "Workflow job ID").required() - private val openedIssue by lazy { runBlocking { checkForOpenedITIssues(githubToken) } } - private val lastRun by lazy { runBlocking { getLastITWorkflowRunDate(githubToken) } } - - override fun run() { - runBlocking { - logArgs() - with(makeContext()) { - when { - itResult == ITResults.FAILURE && openedIssue == null -> createNewIssue() - itResult == ITResults.FAILURE && openedIssue != null -> postComment() - itResult == ITResults.SUCCESS && openedIssue != null -> closeIssue() - else -> return@runBlocking - } - } - } - } - - private fun makeContext() = IntegrationContext( - result = itResult, - token = githubToken, - url = validatedURL, - runID = runID, - lastRun = lastRun, - openedIssue = openedIssue - ) - - private fun logArgs() = println( - """ - ** Parameters: - result: $itResult - url: $validatedURL - runID: $runID - """.trimIndent() - ) -} - -enum class ITResults { - SUCCESS, FAILURE -} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/integration/WorkflowSummary.kt b/flank-scripts/src/main/kotlin/flank/scripts/integration/WorkflowSummary.kt deleted file mode 100644 index 7350ea4be0..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/integration/WorkflowSummary.kt +++ /dev/null @@ -1,9 +0,0 @@ -package flank.scripts.integration - -import flank.common.config.fullSuiteWorkflowFilename -import flank.scripts.github.commons.getLastWorkflowRunDate - -suspend fun getLastITWorkflowRunDate(token: String) = getLastWorkflowRunDate( - token = token, - workflowFileName = fullSuiteWorkflowFilename -) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/ci/CreateReleaseNotes.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/ci/CreateReleaseNotes.kt new file mode 100644 index 0000000000..6107a40a2e --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/ci/CreateReleaseNotes.kt @@ -0,0 +1,20 @@ +package flank.scripts.ops.ci + +import com.github.kittinunf.result.map +import com.github.kittinunf.result.success +import flank.scripts.data.github.getLatestReleaseTag +import flank.scripts.ops.ci.releasenotes.appendReleaseNotes +import flank.scripts.ops.ci.releasenotes.generateReleaseNotes +import kotlinx.coroutines.runBlocking +import java.io.File + +fun createReleaseNotes(token: String, releaseNotesFilePath: String) = runBlocking { + getLatestReleaseTag(token) + .map { it.tag } + .success { previousTag -> + File(releaseNotesFilePath).appendReleaseNotes( + releaseNotesWithType = generateReleaseNotes(previousTag, token), + releaseTag = generateNextReleaseTag(previousTag) + ) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ci/nexttag/NextReleaseTagGenerator.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/ci/NextReleaseTag.kt similarity index 53% rename from flank-scripts/src/main/kotlin/flank/scripts/ci/nexttag/NextReleaseTagGenerator.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/ci/NextReleaseTag.kt index 230f03ca21..d35caf7de7 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/ci/nexttag/NextReleaseTagGenerator.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/ci/NextReleaseTag.kt @@ -1,9 +1,23 @@ -package flank.scripts.ci.nexttag +package flank.scripts.ops.ci +import com.github.kittinunf.result.Result +import flank.scripts.data.github.getLatestReleaseTag +import kotlinx.coroutines.runBlocking import java.time.LocalDate import java.time.format.DateTimeFormatter +import kotlin.system.exitProcess -fun generateNextReleaseTag(previousReleaseTag: String): String { +fun createNextReleaseTag(token: String) = runBlocking { + when (val result = getLatestReleaseTag(token)) { + is Result.Success -> println(generateNextReleaseTag(result.value.tag)) + is Result.Failure -> { + println(result.error) + exitProcess(1) + } + } +} + +internal fun generateNextReleaseTag(previousReleaseTag: String): String { val (year, month, number) = previousReleaseTag.trimStart('v').split('.') return if (isNextReleaseInCurrentMonth( year, diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/AppendReleaseNotes.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/ci/releasenotes/AppendReleaseNotes.kt similarity index 93% rename from flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/AppendReleaseNotes.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/ci/releasenotes/AppendReleaseNotes.kt index 0696b9bafa..663b084f17 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/AppendReleaseNotes.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/ci/releasenotes/AppendReleaseNotes.kt @@ -1,4 +1,4 @@ -package flank.scripts.ci.releasenotes +package flank.scripts.ops.ci.releasenotes import flank.common.withNewLineAtTheEnd import java.io.File diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/ConventionalCommitFormatter.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/ci/releasenotes/ConventionalCommitFormatter.kt similarity index 95% rename from flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/ConventionalCommitFormatter.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/ci/releasenotes/ConventionalCommitFormatter.kt index 28c14641f1..eb4d394687 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/ConventionalCommitFormatter.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/ci/releasenotes/ConventionalCommitFormatter.kt @@ -1,4 +1,4 @@ -package flank.scripts.ci.releasenotes +package flank.scripts.ops.ci.releasenotes fun String.mapPrTitleWithType() = when { startsWith("feat") -> "Features" to skipConventionalCommitPrefix().capitalize() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/GenerateChangeLog.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/ci/releasenotes/GenerateChangeLog.kt similarity index 88% rename from flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/GenerateChangeLog.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/ci/releasenotes/GenerateChangeLog.kt index bc52a8fff9..3d6247a134 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/GenerateChangeLog.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/ci/releasenotes/GenerateChangeLog.kt @@ -1,12 +1,12 @@ -package flank.scripts.ci.releasenotes +package flank.scripts.ops.ci.releasenotes import com.github.kittinunf.result.Result import com.github.kittinunf.result.getOrElse import com.github.kittinunf.result.map -import flank.scripts.github.getLatestReleaseTag -import flank.scripts.github.getPrDetailsByCommit -import flank.scripts.github.objects.GithubPullRequest -import flank.scripts.github.objects.GithubUser +import flank.scripts.data.github.getLatestReleaseTag +import flank.scripts.data.github.getPrDetailsByCommit +import flank.scripts.data.github.objects.GithubPullRequest +import flank.scripts.data.github.objects.GithubUser import flank.scripts.utils.markdownLink import flank.scripts.utils.runCommand import kotlinx.coroutines.async diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/ReleaseNotesWithType.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/ci/releasenotes/ReleaseNotesWithType.kt similarity index 92% rename from flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/ReleaseNotesWithType.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/ci/releasenotes/ReleaseNotesWithType.kt index 9401da86e5..587bceff9f 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/ci/releasenotes/ReleaseNotesWithType.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/ci/releasenotes/ReleaseNotesWithType.kt @@ -1,4 +1,4 @@ -package flank.scripts.ci.releasenotes +package flank.scripts.ops.ci.releasenotes import flank.scripts.utils.markdownH2 import flank.scripts.utils.markdownH3 diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/contribution/ApplyKtlintToIdea.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/contribution/ApplyKtlintToIdea.kt new file mode 100644 index 0000000000..4bb430c738 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/contribution/ApplyKtlintToIdea.kt @@ -0,0 +1,27 @@ +package flank.scripts.ops.contribution + +import flank.common.deleteFile +import flank.common.downloadFile +import flank.common.logLn +import flank.scripts.utils.getKtlintFilePath +import flank.scripts.utils.getRootDirFile +import flank.scripts.utils.runCommand + +suspend fun applyKtlintToIdea() { + logLn("Applying Ktlint code style to this idea project") + logLn("Retrieving Ktlint...") + retrieveKtlintResolveCommand() + applyKtlintToIdeaCommand() + tryCleanupKtlint() +} + +internal suspend fun retrieveKtlintResolveCommand() = + "https://github.com/pinterest/ktlint/releases/download/0.40.0/ktlint".downloadFile(getKtlintFilePath()) + +private fun applyKtlintToIdeaCommand() = + "java -jar ktlint applyToIDEAProject -y".runCommand(executionDirectory = getRootDirFile()) + +private fun tryCleanupKtlint() { + logLn("Cleanup Ktlint leftover files...") + (getKtlintFilePath()).deleteFile() +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/contribution/LinkGitHooks.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/contribution/LinkGitHooks.kt new file mode 100644 index 0000000000..7f9dad1d2d --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/contribution/LinkGitHooks.kt @@ -0,0 +1,9 @@ +package flank.scripts.ops.contribution + +import flank.common.logLn +import flank.scripts.utils.runCommand + +fun linkGitHooks(): Int = run { + logLn("Linking Githooks.") + "git config --local core.hooksPath .githooks/".runCommand() +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/DependenciesResultCheck.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/DependenciesResultCheck.kt similarity index 94% rename from flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/DependenciesResultCheck.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/DependenciesResultCheck.kt index 684b02c76e..2b987649e0 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/DependenciesResultCheck.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/DependenciesResultCheck.kt @@ -1,4 +1,4 @@ -package flank.scripts.dependencies.update +package flank.scripts.ops.dependencies import flank.scripts.utils.Version import kotlinx.serialization.SerialName diff --git a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/DependencyExtensions.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/DependencyExtensions.kt similarity index 89% rename from flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/DependencyExtensions.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/DependencyExtensions.kt index 904bdff207..9acef7ca49 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/DependencyExtensions.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/DependencyExtensions.kt @@ -1,4 +1,4 @@ -package flank.scripts.dependencies.update +package flank.scripts.ops.dependencies val Dependency.groupWithName get() = "$group:$name:" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/DependencyUpdate.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/DependencyUpdate.kt similarity index 80% rename from flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/DependencyUpdate.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/DependencyUpdate.kt index 164b659c06..b36d048271 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/DependencyUpdate.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/DependencyUpdate.kt @@ -1,4 +1,4 @@ -package flank.scripts.dependencies.update +package flank.scripts.ops.dependencies import flank.scripts.utils.Version diff --git a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/FindOutdatedDependencies.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/FindOutdatedDependencies.kt similarity index 85% rename from flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/FindOutdatedDependencies.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/FindOutdatedDependencies.kt index 136d0bb0c7..6c21177996 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/FindOutdatedDependencies.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/FindOutdatedDependencies.kt @@ -1,4 +1,4 @@ -package flank.scripts.dependencies.update +package flank.scripts.ops.dependencies import flank.scripts.utils.toObject import java.io.File diff --git a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/FindVersionInLines.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/FindVersionInLines.kt similarity index 90% rename from flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/FindVersionInLines.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/FindVersionInLines.kt index 78d67ae5e9..2e4343a96b 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/FindVersionInLines.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/FindVersionInLines.kt @@ -1,4 +1,4 @@ -package flank.scripts.dependencies.update +package flank.scripts.ops.dependencies fun List.matchingVersionVal(name: String) = find { it.contains(name) }?.findValName() ?: NOT_FOUND_VERSION diff --git a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/GradleDependency.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/GradleDependency.kt similarity index 91% rename from flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/GradleDependency.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/GradleDependency.kt index 5a183fb30a..5e82cefd6b 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/GradleDependency.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/GradleDependency.kt @@ -1,4 +1,4 @@ -package flank.scripts.dependencies.update +package flank.scripts.ops.dependencies import flank.scripts.utils.Version import kotlinx.serialization.Serializable diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/UpdateAllDependencies.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/UpdateAllDependencies.kt new file mode 100644 index 0000000000..8c36ed3558 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/UpdateAllDependencies.kt @@ -0,0 +1,19 @@ +package flank.scripts.ops.dependencies + +import java.io.File + +fun File.updateAllDependencies( + dependenciesFile: File, + versionsFile: File, + pluginsFile: File +) { + updateDependencies( + dependenciesFile = dependenciesFile, + versionsFile = versionsFile + ) + updateGradle() + updatePlugins( + pluginsFile = pluginsFile, + versionsFile = versionsFile + ) +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/UpdateDependencies.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/UpdateDependencies.kt similarity index 87% rename from flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/UpdateDependencies.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/UpdateDependencies.kt index c5583f87e8..b66108a251 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/UpdateDependencies.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/UpdateDependencies.kt @@ -1,8 +1,8 @@ -package flank.scripts.dependencies.update +package flank.scripts.ops.dependencies import java.io.File -fun File.updateDependencies(dependenciesFile: File, versionsFile: File) { +internal fun File.updateDependencies(dependenciesFile: File, versionsFile: File) { versionsFile.updateVersions( dependencies = outDatedDependencies().getDependenciesToUpdate(dependenciesFile) ) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/UpdateGradle.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/UpdateGradle.kt similarity index 91% rename from flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/UpdateGradle.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/UpdateGradle.kt index 0ddb09556c..fd86c4cf73 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/UpdateGradle.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/UpdateGradle.kt @@ -1,10 +1,10 @@ -package flank.scripts.dependencies.update +package flank.scripts.ops.dependencies import java.io.File import java.nio.file.Files import java.nio.file.Paths -fun File.updateGradle(gradleWrapperPropertiesPath: String = "") { +internal fun File.updateGradle(gradleWrapperPropertiesPath: String = "") { gradleDependency() .takeIf { it.needsUpdate() } ?.let { gradleDependency -> updateGradleWrapper(gradleDependency, gradleWrapperPropertiesPath) } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/UpdatePlugins.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/UpdatePlugins.kt similarity index 94% rename from flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/UpdatePlugins.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/UpdatePlugins.kt index 27863ba1c7..860199ff39 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/UpdatePlugins.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/UpdatePlugins.kt @@ -1,11 +1,11 @@ -package flank.scripts.dependencies.update +package flank.scripts.ops.dependencies import java.io.File import java.nio.file.Files import java.nio.file.Paths import java.util.stream.Collectors -fun File.updatePlugins(pluginsFile: File, versionsFile: File, buildGradleDirectory: String = "") { +internal fun File.updatePlugins(pluginsFile: File, versionsFile: File, buildGradleDirectory: String = "") { versionsFile.updateVersions( dependencies = getDependenciesUpdate(findPluginsValNames(pluginsFile), buildGradleDirectory) ) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/UpdateVersionsInFile.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/UpdateVersionsInFile.kt similarity index 95% rename from flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/UpdateVersionsInFile.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/UpdateVersionsInFile.kt index 7fd170c4d6..efff7122b3 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/dependencies/update/UpdateVersionsInFile.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/dependencies/UpdateVersionsInFile.kt @@ -1,4 +1,4 @@ -package flank.scripts.dependencies.update +package flank.scripts.ops.dependencies import flank.common.withNewLineAtTheEnd import java.io.File diff --git a/flank-scripts/src/main/kotlin/flank/scripts/integration/CommitList.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/integration/CommitList.kt similarity index 75% rename from flank-scripts/src/main/kotlin/flank/scripts/integration/CommitList.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/integration/CommitList.kt index 347ddb76f3..3609e7b0be 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/integration/CommitList.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/integration/CommitList.kt @@ -1,15 +1,15 @@ -package flank.scripts.integration +package flank.scripts.ops.integration import com.github.kittinunf.result.getOrElse import com.github.kittinunf.result.onError -import flank.scripts.github.getGitHubCommitList -import flank.scripts.github.getPrDetailsByCommit -import flank.scripts.github.objects.GithubPullRequest +import flank.scripts.data.github.getGitHubCommitList +import flank.scripts.data.github.getPrDetailsByCommit +import flank.scripts.data.github.objects.GithubPullRequest import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.coroutineScope -suspend fun getCommitListSinceDate( +internal suspend fun getCommitListSinceDate( token: String, since: String ): List> = coroutineScope { diff --git a/flank-scripts/src/main/kotlin/flank/scripts/integration/Extensions.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/integration/Extensions.kt similarity index 80% rename from flank-scripts/src/main/kotlin/flank/scripts/integration/Extensions.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/integration/Extensions.kt index 2a69514c1d..2162cb69ff 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/integration/Extensions.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/integration/Extensions.kt @@ -1,14 +1,14 @@ -package flank.scripts.integration +package flank.scripts.ops.integration import com.github.kittinunf.result.onError -import flank.scripts.github.objects.GitHubCreateIssueCommentRequest -import flank.scripts.github.objects.GitHubCreateIssueRequest -import flank.scripts.github.objects.GitHubCreateIssueResponse -import flank.scripts.github.objects.GitHubUpdateIssueRequest -import flank.scripts.github.objects.IssueState -import flank.scripts.github.patchIssue -import flank.scripts.github.postNewIssue -import flank.scripts.github.postNewIssueComment +import flank.scripts.data.github.objects.GitHubCreateIssueCommentRequest +import flank.scripts.data.github.objects.GitHubCreateIssueRequest +import flank.scripts.data.github.objects.GitHubCreateIssueResponse +import flank.scripts.data.github.objects.GitHubUpdateIssueRequest +import flank.scripts.data.github.objects.IssueState +import flank.scripts.data.github.patchIssue +import flank.scripts.data.github.postNewIssue +import flank.scripts.data.github.postNewIssueComment import flank.scripts.utils.toJson import kotlinx.coroutines.coroutineScope import kotlin.system.exitProcess diff --git a/flank-scripts/src/main/kotlin/flank/scripts/integration/IntegrationContext.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/integration/IntegrationContext.kt similarity index 76% rename from flank-scripts/src/main/kotlin/flank/scripts/integration/IntegrationContext.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/integration/IntegrationContext.kt index 772982f19c..5f359f668f 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/integration/IntegrationContext.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/integration/IntegrationContext.kt @@ -1,4 +1,4 @@ -package flank.scripts.integration +package flank.scripts.ops.integration data class IntegrationContext( val result: ITResults, @@ -6,7 +6,7 @@ data class IntegrationContext( val url: String, val runID: String, val lastRun: String, - private val openedIssue: Int?, + val openedIssue: Int?, ) { val issueNumber: Int get() = requireNotNull(openedIssue) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/integration/IssueList.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/integration/IssueList.kt similarity index 75% rename from flank-scripts/src/main/kotlin/flank/scripts/integration/IssueList.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/integration/IssueList.kt index be5f1b8003..5d13c8145e 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/integration/IssueList.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/integration/IssueList.kt @@ -1,11 +1,11 @@ -package flank.scripts.integration +package flank.scripts.ops.integration import com.github.kittinunf.result.getOrElse import com.github.kittinunf.result.onError import flank.common.config.integrationOpenedIssueUser -import flank.scripts.github.getGitHubIssueList +import flank.scripts.data.github.getGitHubIssueList -suspend fun checkForOpenedITIssues(token: String): Int? = getGitHubIssueList( +internal suspend fun checkForOpenedITIssues(token: String): Int? = getGitHubIssueList( githubToken = token, parameters = listOf( "creator" to integrationOpenedIssueUser, diff --git a/flank-scripts/src/main/kotlin/flank/scripts/integration/PrepareMessage.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/integration/PrepareMessage.kt similarity index 90% rename from flank-scripts/src/main/kotlin/flank/scripts/integration/PrepareMessage.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/integration/PrepareMessage.kt index d76f0aefc1..97015c43d6 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/integration/PrepareMessage.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/integration/PrepareMessage.kt @@ -1,19 +1,19 @@ -package flank.scripts.integration +package flank.scripts.ops.integration import flank.common.config.flankRepository -import flank.scripts.github.objects.GithubPullRequest +import flank.scripts.data.github.objects.GithubPullRequest import java.time.Instant import java.time.LocalDateTime import java.time.ZoneOffset import java.time.format.DateTimeFormatter -fun prepareSuccessMessage( +internal fun prepareSuccessMessage( lastRun: String, runId: String, url: String ): String = successTemplate(lastRun, runId, url) -fun prepareFailureMessage( +internal fun prepareFailureMessage( lastRun: String, runId: String, url: String, diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/integration/ProcessIntegrationTestsResult.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/integration/ProcessIntegrationTestsResult.kt new file mode 100644 index 0000000000..dad15f9fd7 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/integration/ProcessIntegrationTestsResult.kt @@ -0,0 +1,55 @@ +package flank.scripts.ops.integration + +import kotlinx.coroutines.runBlocking + +enum class ITResults { + SUCCESS, FAILURE +} + +fun processIntegrationTestsResult( + result: ITResults, + githubToken: String, + url: String, + runID: String +) { + logArgs(result, url, runID) + createContext(result, githubToken, url, runID).processIntegrationTestsResult() +} + +private fun logArgs( + result: ITResults, + url: String, + runID: String +) = println( + """ + ** Parameters: + result: $result + url: $url + runID: $runID + """.trimIndent() +) + +private fun createContext( + result: ITResults, + githubToken: String, + url: String, + runID: String +) = IntegrationContext( + result = result, + token = githubToken, + url = url, + runID = runID, + lastRun = runBlocking { getLastITWorkflowRunDate(githubToken) }, + openedIssue = runBlocking { checkForOpenedITIssues(githubToken) } +) + +private fun IntegrationContext.processIntegrationTestsResult() = runBlocking { + with(this) { + when { + result == ITResults.FAILURE && openedIssue == null -> createNewIssue() + result == ITResults.FAILURE && openedIssue != null -> postComment() + result == ITResults.SUCCESS && openedIssue != null -> closeIssue() + else -> return@with + } + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/integration/WorkflowSummary.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/integration/WorkflowSummary.kt new file mode 100644 index 0000000000..a72dd0a739 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/integration/WorkflowSummary.kt @@ -0,0 +1,9 @@ +package flank.scripts.ops.integration + +import flank.common.config.fullSuiteWorkflowFilename +import flank.scripts.data.github.commons.getLastWorkflowRunDate + +internal suspend fun getLastITWorkflowRunDate(token: String) = getLastWorkflowRunDate( + token = token, + workflowFileName = fullSuiteWorkflowFilename +) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/pullrequest/CopyGitHubProperties.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/pullrequest/CopyGitHubProperties.kt new file mode 100644 index 0000000000..981e48b0b1 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/pullrequest/CopyGitHubProperties.kt @@ -0,0 +1,54 @@ +package flank.scripts.ops.pullrequest + +import com.github.kittinunf.result.onError +import com.github.kittinunf.result.success +import flank.scripts.data.github.getGitHubPullRequest +import flank.scripts.data.zenhub.copyEstimation +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.joinAll +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking + +fun copyGitHubProperties(githubToken: String, zenhubToken: String, prNumber: Int) = runBlocking { + getGitHubPullRequest(githubToken, prNumber) + .onError { println("Could not copy properties, because of ${it.message}") } + .success { pullRequest -> + val issueNumber = pullRequest.findReferenceNumber() + checkNotNull(issueNumber) { "Reference issue not found on description and branch" } + println("Found referenced issue #$issueNumber") + launch(Dispatchers.IO) { + copyGitHubProperties( + githubToken, + issueNumber, + prNumber + ) + } + launch(Dispatchers.IO) { + copyZenhubProperties( + zenhubToken, + issueNumber, + prNumber + ) + } + } +} + +private suspend fun copyGitHubProperties( + githubToken: String, + baseIssueNumber: Int, + prNumber: Int +) = coroutineScope { + listOf( + launch { copyAssignees(githubToken, baseIssueNumber, prNumber) }, + launch { copyLabels(githubToken, baseIssueNumber, prNumber) }, + ).joinAll() +} + +private suspend fun copyZenhubProperties( + zenhubToken: String, + baseIssueNumber: Int, + prNumber: Int +) { + copyEstimation(zenhubToken, baseIssueNumber, prNumber) +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/FindReferenceIssue.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/pullrequest/FindReferenceIssue.kt similarity index 75% rename from flank-scripts/src/main/kotlin/flank/scripts/pullrequest/FindReferenceIssue.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/pullrequest/FindReferenceIssue.kt index 38a804d0f4..93af4bf9a0 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/FindReferenceIssue.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/pullrequest/FindReferenceIssue.kt @@ -1,8 +1,8 @@ -package flank.scripts.pullrequest +package flank.scripts.ops.pullrequest -import flank.scripts.github.objects.GithubPullRequest +import flank.scripts.data.github.objects.GithubPullRequest -fun GithubPullRequest.findReferenceNumber() = +internal fun GithubPullRequest.findReferenceNumber() = (tryGetReferenceNumberFromBody() ?: tryGetReferenceNumberFromBranch()) ?.trim() ?.replace("#", "") diff --git a/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/SetAssignees.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/pullrequest/SetAssignees.kt similarity index 63% rename from flank-scripts/src/main/kotlin/flank/scripts/pullrequest/SetAssignees.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/pullrequest/SetAssignees.kt index e33531d75d..e80d9e3282 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/SetAssignees.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/pullrequest/SetAssignees.kt @@ -1,12 +1,12 @@ -package flank.scripts.pullrequest +package flank.scripts.ops.pullrequest import com.github.kittinunf.result.getOrNull import com.github.kittinunf.result.map import com.github.kittinunf.result.onError -import flank.scripts.github.getGitHubIssue -import flank.scripts.github.setAssigneesToPullRequest +import flank.scripts.data.github.getGitHubIssue +import flank.scripts.data.github.setAssigneesToPullRequest -suspend fun copyAssignees(githubToken: String, baseIssueNumber: Int, pullRequestNumber: Int) { +internal suspend fun copyAssignees(githubToken: String, baseIssueNumber: Int, pullRequestNumber: Int) { getGitHubIssue(githubToken, baseIssueNumber) .onError { println("Could not copy assignees because of ${it.message}") } .map { githubIssue -> githubIssue.assignees.map { it.login } } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/SetLabels.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/pullrequest/SetLabels.kt similarity index 62% rename from flank-scripts/src/main/kotlin/flank/scripts/pullrequest/SetLabels.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/pullrequest/SetLabels.kt index 8d1f6a301c..06fe622e10 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/SetLabels.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/pullrequest/SetLabels.kt @@ -1,12 +1,12 @@ -package flank.scripts.pullrequest +package flank.scripts.ops.pullrequest import com.github.kittinunf.result.getOrNull import com.github.kittinunf.result.map import com.github.kittinunf.result.onError -import flank.scripts.github.getLabelsFromIssue -import flank.scripts.github.setLabelsToPullRequest +import flank.scripts.data.github.getLabelsFromIssue +import flank.scripts.data.github.setLabelsToPullRequest -suspend fun copyLabels(githubToken: String, issueNumber: Int, pullRequestNumber: Int) { +internal suspend fun copyLabels(githubToken: String, issueNumber: Int, pullRequestNumber: Int) { getLabelsFromIssue(githubToken, issueNumber) .onError { println("Could not copy labels because of ${it.message}") } .map { it.map { label -> label.name } } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/release/hub/DeleteOldRelease.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/release/hub/DeleteOldRelease.kt new file mode 100644 index 0000000000..c6be4bc9dc --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/release/hub/DeleteOldRelease.kt @@ -0,0 +1,7 @@ +package flank.scripts.ops.release.hub + +import flank.scripts.utils.runCommand + +fun deleteOldRelease(tag: String) = "$DELETE_RELEASE_COMMAND $tag".runCommand() + +private const val DELETE_RELEASE_COMMAND = "hub release delete" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/release/hub/DeleteOldTag.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/release/hub/DeleteOldTag.kt new file mode 100644 index 0000000000..bfb8990960 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/release/hub/DeleteOldTag.kt @@ -0,0 +1,30 @@ +package flank.scripts.ops.release.hub + +import com.github.kittinunf.result.Result +import flank.common.logLn +import flank.scripts.data.github.deleteOldTag + +fun tryDeleteOldTag( + gitTag: String, + username: String, + token: String +) = tryDeleteOldTag( + gitTag = gitTag, + username = username, + token = token, + success = { logLn("Tag $gitTag was deleted") }, + error = { logLn(it.error) } +) + +fun tryDeleteOldTag( + gitTag: String, + username: String, + token: String, + success: (response: Result.Success) -> Unit, + error: (response: Result.Failure) -> Unit +) { + when (val response = deleteOldTag(gitTag, username, token)) { + is Result.Success -> success(response) + is Result.Failure -> error(response) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/release/hub/ReleaseFlank.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/release/hub/ReleaseFlank.kt similarity index 53% rename from flank-scripts/src/main/kotlin/flank/scripts/release/hub/ReleaseFlank.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/release/hub/ReleaseFlank.kt index 67041a462b..1bba09a135 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/release/hub/ReleaseFlank.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/release/hub/ReleaseFlank.kt @@ -1,12 +1,33 @@ -package flank.scripts.release.hub +package flank.scripts.ops.release.hub -import flank.scripts.ci.releasenotes.asString -import flank.scripts.ci.releasenotes.generateReleaseNotes +import com.google.common.annotations.VisibleForTesting +import flank.scripts.ops.ci.releasenotes.asString +import flank.scripts.ops.ci.releasenotes.generateReleaseNotes +import flank.scripts.utils.ERROR_WHEN_RUNNING import flank.scripts.utils.runCommand import java.io.File import java.nio.file.Path -fun releaseFlank(path: Path, gitTag: String, commitHash: String, isSnapshotRelease: Boolean, token: String): Int { +fun tryReleaseFlank(path: Path, gitTag: String, commitHash: String, isSnapshotRelease: Boolean, token: String) = when { + isSnapshotRelease && commitHash.isBlank() -> { + println("Commit hash is required for snapshot release") + ERROR_WHEN_RUNNING + } + !isSnapshotRelease && token.isBlank() -> { + println("Git hub token is required for stable release") + ERROR_WHEN_RUNNING + } + else -> releaseFlank(path, gitTag, commitHash, isSnapshotRelease, token) +} + +@VisibleForTesting +internal fun releaseFlank( + path: Path, + gitTag: String, + commitHash: String, + isSnapshotRelease: Boolean, + token: String +): Int { val releasePath = moveFlankToReleaseDirectory(path) val releaseCommand = if (isSnapshotRelease) { hubStableSnapshotCommand(releasePath, gitTag, commitHash) @@ -17,7 +38,8 @@ fun releaseFlank(path: Path, gitTag: String, commitHash: String, isSnapshotRelea } private fun moveFlankToReleaseDirectory(inputPath: Path) = - if (inputPath.toFile().renameTo(File(RELEASE_DIRECTORY))) RELEASE_DIRECTORY else inputPath.toAbsolutePath().toString() + if (inputPath.toFile().renameTo(File(RELEASE_DIRECTORY))) RELEASE_DIRECTORY else inputPath.toAbsolutePath() + .toString() private fun hubStableSnapshotCommand(path: String, gitTag: String, commitHash: String) = listOf( diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/release/jfrog/DeleteOldSnapshot.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/release/jfrog/DeleteOldSnapshot.kt new file mode 100644 index 0000000000..4b19abdcec --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/release/jfrog/DeleteOldSnapshot.kt @@ -0,0 +1,7 @@ +package flank.scripts.ops.release.jfrog + +import flank.scripts.utils.runCommand + +fun jFrogDeleteOldSnapshot(version: String) { + "jfrog bt version-delete ${flankMaven(version)} --quiet".runCommand() +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/release/jfrog/JFrogCommandHelper.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/release/jfrog/JFrogCommandHelper.kt similarity index 67% rename from flank-scripts/src/main/kotlin/flank/scripts/release/jfrog/JFrogCommandHelper.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/release/jfrog/JFrogCommandHelper.kt index 9263f0acaa..1fee10c5db 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/release/jfrog/JFrogCommandHelper.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/release/jfrog/JFrogCommandHelper.kt @@ -1,3 +1,3 @@ -package flank.scripts.release.jfrog +package flank.scripts.ops.release.jfrog val flankMaven: (String) -> String = { version -> "flank/maven/flank/$version" } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/release/jfrog/SyncMaven.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/release/jfrog/SyncMaven.kt new file mode 100644 index 0000000000..79317373af --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/release/jfrog/SyncMaven.kt @@ -0,0 +1,5 @@ +package flank.scripts.ops.release.jfrog + +import flank.scripts.utils.runCommand + +fun jFrogSync(mavenTag: String) = "jfrog bt mcs ${flankMaven(mavenTag)}".runCommand(retryCount = 5) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/BuildFlank.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/BuildFlank.kt similarity index 71% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/BuildFlank.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/shell/BuildFlank.kt index 92fa0c5166..4599bdfa34 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/BuildFlank.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/BuildFlank.kt @@ -1,20 +1,13 @@ -package flank.scripts.shell +package flank.scripts.ops.shell -import com.github.ajalt.clikt.core.CliktCommand import flank.common.rootDirectoryPathString -import flank.scripts.shell.utils.createGradleCommand +import flank.scripts.utils.createGradleCommand 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() { - buildFlank() - } -} - -private fun buildFlank() { +fun buildFlank() { createGradleCommand( workingDir = rootDirectoryPathString, "-p", rootDirectoryPathString, ":test_runner:clean", ":test_runner:assemble", ":test_runner:shadowJar" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/InstallXcPretty.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/InstallXcPretty.kt new file mode 100644 index 0000000000..3b8551fe73 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/InstallXcPretty.kt @@ -0,0 +1,9 @@ +package flank.scripts.ops.shell + +import flank.scripts.utils.downloadXcPrettyIfNeeded +import flank.scripts.utils.failIfWindows + +fun installXcPretty() { + failIfWindows() + downloadXcPrettyIfNeeded() +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/SetupIosEnv.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/SetupIosEnv.kt new file mode 100644 index 0000000000..b89d119ff6 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/SetupIosEnv.kt @@ -0,0 +1,14 @@ +package flank.scripts.ops.shell + +import flank.common.iOSTestProjectsPath +import flank.scripts.ops.shell.buildexample.ios.EARL_GREY_EXAMPLE +import flank.scripts.utils.downloadCocoaPodsIfNeeded +import flank.scripts.utils.failIfWindows +import flank.scripts.utils.installPodsIfNeeded +import java.nio.file.Paths + +fun setupIosEnv() { + failIfWindows() + downloadCocoaPodsIfNeeded() + installPodsIfNeeded(Paths.get(iOSTestProjectsPath, EARL_GREY_EXAMPLE)) +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/BuildBaseAndroidApk.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/BuildBaseAndroidApk.kt new file mode 100644 index 0000000000..647bb7f81f --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/BuildBaseAndroidApk.kt @@ -0,0 +1,31 @@ +package flank.scripts.ops.shell.buildexample.android + +import flank.common.androidTestProjectsPath +import flank.common.flankFixturesTmpPath +import flank.scripts.utils.createGradleCommand +import flank.scripts.utils.runCommand +import java.nio.file.Files +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) +} + +data class AndroidBuildConfiguration(val artifacts: List, val generate: Boolean, val copy: Boolean) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/BuildBaseAndroidTests.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/BuildBaseAndroidTests.kt new file mode 100644 index 0000000000..3db1963c52 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/BuildBaseAndroidTests.kt @@ -0,0 +1,26 @@ +package flank.scripts.ops.shell.buildexample.android + +import flank.common.androidTestProjectsPath +import flank.common.flankFixturesTmpPath +import flank.scripts.utils.createGradleCommand +import flank.scripts.utils.runCommand +import java.nio.file.Files +import java.nio.file.Paths +import java.nio.file.StandardCopyOption + +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) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/BuildCucumberSampleApk.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/BuildCucumberSampleApk.kt new file mode 100644 index 0000000000..2781855030 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/BuildCucumberSampleApk.kt @@ -0,0 +1,27 @@ +package flank.scripts.ops.shell.buildexample.android + +import flank.common.androidTestProjectsPath +import flank.common.flankFixturesTmpPath +import flank.scripts.utils.createGradleCommand +import flank.scripts.utils.runCommand +import java.io.File +import java.nio.file.Paths + +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) +} + +internal fun Sequence.copyApksToPath(outputDirectory: String) = forEach { + it.copyApkToDirectory(Paths.get(outputDirectory, it.name)) +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/BuildDuplicatedNamesApks.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/BuildDuplicatedNamesApks.kt new file mode 100644 index 0000000000..09f5e81a5c --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/BuildDuplicatedNamesApks.kt @@ -0,0 +1,32 @@ +package flank.scripts.ops.shell.buildexample.android + +import flank.common.androidTestProjectsPath +import flank.common.flankFixturesTmpPath +import flank.scripts.utils.createGradleCommand +import flank.scripts.utils.runCommand +import java.nio.file.Files +import java.nio.file.Paths + +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)) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/BuildMultiModulesApks.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/BuildMultiModulesApks.kt new file mode 100644 index 0000000000..293e9d93c5 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/BuildMultiModulesApks.kt @@ -0,0 +1,26 @@ +package flank.scripts.ops.shell.buildexample.android + +import flank.common.androidTestProjectsPath +import flank.common.flankFixturesTmpPath +import flank.scripts.utils.createGradleCommand +import flank.scripts.utils.runCommand +import java.nio.file.Paths + +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)) } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/Common.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/Common.kt new file mode 100644 index 0000000000..6f85f77a34 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/Common.kt @@ -0,0 +1,15 @@ +package flank.scripts.ops.shell.buildexample.android + +import java.io.File +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.StandardCopyOption + +internal fun List.canExecute(actionName: String) = isEmpty() || any { it.equals(actionName, ignoreCase = true) } + +internal fun File.findApks() = walk().filter { it.extension == "apk" } + +internal 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) +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/RunAndroidOps.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/RunAndroidOps.kt new file mode 100644 index 0000000000..a07fd03d30 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/android/RunAndroidOps.kt @@ -0,0 +1,9 @@ +package flank.scripts.ops.shell.buildexample.android + +fun AndroidBuildConfiguration.runAndroidBuild() = takeIf { generate }?.let { + buildBaseApk() + buildBaseTestApk() + buildDuplicatedNamesApks() + buildMultiModulesApks() + buildCucumberSampleApp() +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/go/BuildGO.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/go/BuildGO.kt new file mode 100644 index 0000000000..e5348a9fbf --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/go/BuildGO.kt @@ -0,0 +1,39 @@ +package flank.scripts.ops.shell.buildexample.go + +import flank.common.flankFixturesTmpPath +import flank.common.testProjectsPath +import flank.scripts.utils.runCommand +import java.nio.file.Path +import java.nio.file.Paths + +fun generateGoArtifacts() { + val goHelloBinDirectoryPath = Paths.get(testProjectsPath, "gohello", "bin").apply { + toFile().deleteRecursively() + } + GoOS.values().forEach { createExecutable(it, goHelloBinDirectoryPath) } +} + +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 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/ops/shell/buildexample/ios/BuildEarlGreyExample.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildEarlGreyExample.kt new file mode 100644 index 0000000000..b6f9842096 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildEarlGreyExample.kt @@ -0,0 +1,22 @@ +package flank.scripts.ops.shell.buildexample.ios + +import flank.common.iOSTestProjectsPath +import flank.scripts.utils.failIfWindows +import java.nio.file.Paths + +fun buildEarlGreyExample(generate: Boolean?, copy: Boolean?) { + failIfWindows() + IosBuildConfiguration( + projectPath = Paths.get(iOSTestProjectsPath, EARL_GREY_EXAMPLE).toString(), + projectName = EARL_GREY_EXAMPLE, + buildConfigurations = listOf( + IosTestBuildConfiguration(EARL_GREY_EXAMPLE_SWIFT_TESTS, "swift"), + IosTestBuildConfiguration(EARL_GREY_EXAMPLE_TESTS, "objective_c") + ), + useWorkspace = true, + generate = generate ?: true, + copy = copy ?: true, + copyXCTestFiles = copy ?: true, + useLegacyBuildSystem = true + ).generateIosTestArtifacts() +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildExample.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildExample.kt similarity index 84% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildExample.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildExample.kt index 43838aadca..9a2459da1b 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildExample.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildExample.kt @@ -1,26 +1,22 @@ +package flank.scripts.ops.shell.ios -package flank.scripts.shell.ios - -import com.github.ajalt.clikt.core.CliktCommand import flank.common.archive import flank.common.currentPath import flank.common.iOSTestProjectsPath -import flank.scripts.shell.utils.failIfWindows -import flank.scripts.shell.utils.pipe import flank.scripts.utils.downloadXcPrettyIfNeeded +import flank.scripts.utils.failIfWindows import flank.scripts.utils.installPodsIfNeeded +import flank.scripts.utils.pipe 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() - } +fun buildIosExample() { + failIfWindows() + downloadXcPrettyIfNeeded() + buildExample() } private fun buildExample() { diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildFlankExampleCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildFlankExampleCommand.kt new file mode 100644 index 0000000000..f64f9e58c6 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildFlankExampleCommand.kt @@ -0,0 +1,22 @@ +package flank.scripts.ops.shell.buildexample.ios + +import flank.common.iOSTestProjectsPath +import flank.scripts.utils.failIfWindows +import java.nio.file.Paths + +fun buildIosFlankExample(generate: Boolean?, copy: Boolean?) { + 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 + ).generateIosTestArtifacts() +} + +private const val FLANK_EXAMPLE = "FlankExample" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildFtl.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildFtl.kt similarity index 75% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildFtl.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildFtl.kt index 715356de0e..bd3fda6075 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildFtl.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildFtl.kt @@ -1,24 +1,21 @@ -package flank.scripts.shell.ios +package flank.scripts.ops.shell.ios -import com.github.ajalt.clikt.core.CliktCommand import flank.common.archive -import flank.scripts.shell.utils.failIfWindows -import flank.scripts.shell.utils.pipe import flank.scripts.utils.downloadXcPrettyIfNeeded +import flank.scripts.utils.failIfWindows +import flank.scripts.utils.pipe 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() - } +fun buildFtl() { + failIfWindows() + downloadXcPrettyIfNeeded() + buildFtlExample() } -private fun buildFtl() { +private fun buildFtlExample() { val dataPath = Paths.get("", "dd_tmp").apply { toFile().deleteRecursively() }.toString() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildGameLoopExampleCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildGameLoopExampleCommand.kt new file mode 100644 index 0000000000..65d556f606 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildGameLoopExampleCommand.kt @@ -0,0 +1,22 @@ +package flank.scripts.ops.shell.buildexample.ios + +import flank.common.iOSTestProjectsPath +import flank.scripts.utils.failIfWindows +import java.nio.file.Paths + +fun buildIosGameLoopExampleCommand(generate: Boolean?, copy: Boolean?) { + failIfWindows() + + IosBuildConfiguration( + projectPath = Paths.get(iOSTestProjectsPath, FLANK_GAME_LOOP_EXAMPLE).toString(), + projectName = FLANK_GAME_LOOP_EXAMPLE, + buildConfigurations = listOf( + IosTestBuildConfiguration(FLANK_GAME_LOOP_EXAMPLE, "tests"), + ), + useWorkspace = false, + generate = generate ?: true, + copy = copy ?: true + ).generateIPA() +} + +private const val FLANK_GAME_LOOP_EXAMPLE = "FlankGameLoopExample" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIosIPA.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildIosIPA.kt similarity index 90% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIosIPA.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildIosIPA.kt index 745b00123e..35b203e8a6 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIosIPA.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildIosIPA.kt @@ -1,12 +1,12 @@ -package flank.scripts.shell.ops +package flank.scripts.ops.shell.buildexample.ios import flank.common.flankFixturesIosTmpPath -import flank.scripts.shell.ios.createXcodeArchiveCommand -import flank.scripts.shell.ios.createXcodeExportArchiveCommand -import flank.scripts.shell.utils.pipe +import flank.scripts.ops.shell.ios.createXcodeArchiveCommand +import flank.scripts.ops.shell.ios.createXcodeExportArchiveCommand import flank.scripts.utils.downloadCocoaPodsIfNeeded import flank.scripts.utils.downloadXcPrettyIfNeeded import flank.scripts.utils.installPodsIfNeeded +import flank.scripts.utils.pipe import java.nio.file.Path import java.nio.file.Paths diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIosTestArtifacts.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildIosTestArtifacts.kt similarity index 96% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIosTestArtifacts.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildIosTestArtifacts.kt index 4668ad181d..74e4df81b7 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIosTestArtifacts.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildIosTestArtifacts.kt @@ -1,12 +1,12 @@ -package flank.scripts.shell.ops +package flank.scripts.ops.shell.buildexample.ios import flank.common.archive import flank.common.flankFixturesIosTmpPath -import flank.scripts.shell.ios.createXcodeBuildForTestingCommand -import flank.scripts.shell.utils.pipe +import flank.scripts.ops.shell.ios.createXcodeBuildForTestingCommand import flank.scripts.utils.downloadCocoaPodsIfNeeded import flank.scripts.utils.downloadXcPrettyIfNeeded import flank.scripts.utils.installPodsIfNeeded +import flank.scripts.utils.pipe import java.io.File import java.nio.file.Path import java.nio.file.Paths diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildTestPlansExample.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildTestPlansExample.kt new file mode 100644 index 0000000000..af032dbf4f --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/BuildTestPlansExample.kt @@ -0,0 +1,22 @@ +package flank.scripts.ops.shell.buildexample.ios + +import flank.common.iOSTestProjectsPath +import flank.scripts.utils.failIfWindows +import java.nio.file.Paths + +fun buildTestPlansExample(generate: Boolean?, copy: Boolean?) { + failIfWindows() + + IosBuildConfiguration( + projectPath = Paths.get(iOSTestProjectsPath, FLANK_TEST_PLANS_EXAMPLE).toString(), + projectName = FLANK_TEST_PLANS_EXAMPLE, + buildConfigurations = listOf( + IosTestBuildConfiguration("AllTests", "AllTests"), + ), + useWorkspace = false, + generate = generate ?: true, + copy = copy ?: true + ).generateIosTestArtifacts() +} + +private const val FLANK_TEST_PLANS_EXAMPLE = "FlankTestPlansExample" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/EarlGreyExampleConsts.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/EarlGreyExampleConsts.kt new file mode 100644 index 0000000000..21cab12e7f --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/EarlGreyExampleConsts.kt @@ -0,0 +1,5 @@ +package flank.scripts.ops.shell.buildexample.ios + +const val EARL_GREY_EXAMPLE = "EarlGreyExample" +const val EARL_GREY_EXAMPLE_TESTS = "EarlGreyExampleTests" +const val EARL_GREY_EXAMPLE_SWIFT_TESTS = "EarlGreyExampleSwiftTests" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/IosBuildCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/IosBuildCommand.kt similarity index 97% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/ios/IosBuildCommand.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/IosBuildCommand.kt index 75def19e7e..f88eb8c839 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/IosBuildCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/IosBuildCommand.kt @@ -1,4 +1,4 @@ -package flank.scripts.shell.ios +package flank.scripts.ops.shell.ios fun createXcodeBuildForTestingCommand( buildDir: String, diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/LipoHelper.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/LipoHelper.kt similarity index 79% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/ios/LipoHelper.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/LipoHelper.kt index d442ed3176..bf25a353b3 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/LipoHelper.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/LipoHelper.kt @@ -1,4 +1,4 @@ -package flank.scripts.shell.ios +package flank.scripts.ops.shell.ios fun createLipoCommand( outputPath: String, diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/RunFtlLocal.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/RunFtlLocal.kt new file mode 100644 index 0000000000..53bb43f8e3 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/RunFtlLocal.kt @@ -0,0 +1,19 @@ +package flank.scripts.ops.shell.ios + +import flank.common.currentPath +import flank.scripts.utils.failIfWindows +import flank.scripts.utils.runCommand +import java.nio.file.Path +import java.nio.file.Paths + +fun runFtlLocal(deviceId: String) { + failIfWindows() + 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/ops/shell/buildexample/ios/UniversalFramework.kt similarity index 82% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/UniversalFramework.kt index 3b4f309acc..8e182702fe 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/buildexample/ios/UniversalFramework.kt @@ -1,22 +1,15 @@ -package flank.scripts.shell.ios +package flank.scripts.ops.shell.ios -import com.github.ajalt.clikt.core.CliktCommand import flank.common.currentPath -import flank.scripts.shell.utils.failIfWindows +import flank.scripts.utils.failIfWindows import flank.scripts.utils.runCommand import java.nio.file.Paths -object UniversalFrameworkCommand : CliktCommand(name = "iosUniversalFramework", help = "Create Universal Framework") { - override fun run() { - failIfWindows() - createUniversalFiles() - } -} - private const val APP_FRAMEWORK_FRAMEWORK = "AppFramework.framework" private const val APP_FRAMEWORK = "AppFramework" -private fun createUniversalFiles() { +fun createUniversalFrameworkFiles() { + failIfWindows() 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-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/apiclient/GenerateJavaClient.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/apiclient/GenerateJavaClient.kt new file mode 100644 index 0000000000..c8dba1da68 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/apiclient/GenerateJavaClient.kt @@ -0,0 +1,33 @@ +package flank.scripts.ops.shell.firebase.apiclient + +import flank.scripts.utils.checkIfPipInstalled +import flank.scripts.utils.exceptions.ShellCommandException +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 + +fun generateJavaClient() { + checkIfPipInstalled() + installClientGeneratorIfNeeded() + val firebaseApiPath = Paths.get("firebase_apis").toString() + val apiPath = Paths.get(firebaseApiPath, "test_api").toString() + val outputDirectory = Paths.get(apiPath, "src", "main", "java").toString() + val testingJsonInput = Paths.get(firebaseApiPath, "json", "testing_v1.json").toString() + Paths.get(apiPath, "src").toFile().deleteRecursively() + + val generateLibraryCommand = "generate_library " + + "--input=$testingJsonInput " + + "--language=java " + + "--output_dir=$outputDirectory" + + val result = generateLibraryCommand.runCommand() + if (result != 0) throw ShellCommandException("Error when execute generate_library command") + + 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/ops/shell/firebase/apiclient/UpdateApiJson.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/apiclient/UpdateApiJson.kt new file mode 100644 index 0000000000..c9d89ca420 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/apiclient/UpdateApiJson.kt @@ -0,0 +1,30 @@ +package flank.scripts.ops.shell.firebase.apiclient + +import flank.common.config.flankGcloudCLIRepository +import flank.common.currentPath +import flank.common.downloadFile +import flank.scripts.utils.downloadSortJsonIfNeeded +import flank.scripts.utils.runCommand +import java.nio.file.Paths + +fun updateApiJson() { + + val jsonDirectoryPath = Paths.get(currentPath.toString(), "firebase_apis", "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/$flankGcloudCLIRepository/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/testing_v1.json", + testingV1Path + ) + + downloadFile( + "https://raw.githubusercontent.com/$flankGcloudCLIRepository/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/toolresults_v1beta3.json", + testingV1Beta3Path + ) + + downloadSortJsonIfNeeded() + + "sort-json $testingV1Path".runCommand() + "sort-json $testingV1Beta3Path".runCommand() +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/CheckForSDKUpdateCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/CheckForSDKUpdateCommand.kt new file mode 100644 index 0000000000..629b5ed4db --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/CheckForSDKUpdateCommand.kt @@ -0,0 +1,61 @@ +package flank.scripts.ops.shell.firebase.sdk + +import com.github.kittinunf.fuel.Fuel +import flank.common.config.flankGcloudCLIRepository +import flank.common.currentPath +import flank.common.downloadFile +import flank.scripts.data.github.objects.GithubPullRequest +import flank.scripts.utils.parseToVersion +import kotlinx.coroutines.runBlocking +import java.nio.file.Paths +import java.time.Instant + +private val RAW_GITHUB = "https://raw.githubusercontent.com/$flankGcloudCLIRepository" + +fun checkForSDKUpdate(githubToken: String, zenhubToken: String) = runBlocking { + val lastRun by lazy { runBlocking { getLastSDKUpdateRunDate(githubToken) } } + val openedUpdates by lazy { runBlocking { checkForOpenedUpdates(githubToken) } } + + println("** Find previously checked commit") + val oldSha = getCommitsUntilLastCheck(githubToken, lastRun) ?: run { + println("** Unable to find previous commit") + return@runBlocking + } + println("** Find latest commit") + val newSha = getCommitsUntilLastCheck(githubToken, Instant.now().toString()) ?: run { + println("** Unable to find latest commit") + return@runBlocking + } + + if (oldSha == newSha) { + println("** No new commits since the last run") + return@runBlocking + } + + with(createContext(oldSha, githubToken, zenhubToken, openedUpdates)) { + println("** New version $newVersion") + println("** Old version $oldVersion") + when { + oldVersion >= newVersion -> println("** No new features") + openedUpdates != null -> updateOpenedEpic() + openedUpdates == null -> createEpicIssue() + } + } +} + +private fun createContext(sha: String, githubToken: String, zenhubToken: String, openedUpdates: GithubPullRequest?) = + SDKUpdateContext( + oldVersion = getVersionBySHA(sha), + newVersion = getVersionBySHA("master"), + updatesLazy = suspend { + val notes = Paths.get(currentPath.toString(), "notes.txt") + downloadFile("$RAW_GITHUB/master/google-cloud-sdk/RELEASE_NOTES", notes) + notes.toFile().apply { deleteOnExit() }.readText() + }, + githubToken = githubToken, + zenhubToken = zenhubToken, + openedIssue = openedUpdates + ) + +private fun getVersionBySHA(sha: String) = + parseToVersion(Fuel.get("$RAW_GITHUB/$sha/google-cloud-sdk/VERSION").responseString().third.get()) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CommitList.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/CommitList.kt similarity index 84% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CommitList.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/CommitList.kt index cf3b666a06..acc2611df4 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CommitList.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/CommitList.kt @@ -1,8 +1,8 @@ -package flank.scripts.shell.firebase.sdk +package flank.scripts.ops.shell.firebase.sdk import flank.common.config.flankGcloudCLIRepository -import flank.scripts.github.getGitHubCommitList -import flank.scripts.github.objects.GitHubCommit +import flank.scripts.data.github.getGitHubCommitList +import flank.scripts.data.github.objects.GitHubCommit import java.time.Instant import java.time.format.DateTimeFormatter diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/Extensions.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/Extensions.kt similarity index 86% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/Extensions.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/Extensions.kt index 70ad8115b7..e73c7769ee 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/Extensions.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/Extensions.kt @@ -1,19 +1,19 @@ -package flank.scripts.shell.firebase.sdk +package flank.scripts.ops.shell.firebase.sdk import com.github.kittinunf.result.Result import com.github.kittinunf.result.onError import flank.common.config.zenhubRepositoryID import flank.common.newLine -import flank.scripts.github.objects.GitHubCreateIssueRequest -import flank.scripts.github.objects.GitHubCreateIssueResponse -import flank.scripts.github.objects.GitHubUpdateIssueRequest -import flank.scripts.github.patchIssue -import flank.scripts.github.postNewIssue -import flank.scripts.zenhub.convertIssueToEpic -import flank.scripts.zenhub.objects.ConvertToEpicRequest -import flank.scripts.zenhub.objects.Issue -import flank.scripts.zenhub.objects.UpdateEpicRequest -import flank.scripts.zenhub.updateEpic +import flank.scripts.data.github.objects.GitHubCreateIssueRequest +import flank.scripts.data.github.objects.GitHubCreateIssueResponse +import flank.scripts.data.github.objects.GitHubUpdateIssueRequest +import flank.scripts.data.github.patchIssue +import flank.scripts.data.github.postNewIssue +import flank.scripts.data.zenhub.convertIssueToEpic +import flank.scripts.data.zenhub.objects.ConvertToEpicRequest +import flank.scripts.data.zenhub.objects.Issue +import flank.scripts.data.zenhub.objects.UpdateEpicRequest +import flank.scripts.data.zenhub.updateEpic import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.coroutineScope diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/LastSDKUpdateRun.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/LastSDKUpdateRun.kt similarity index 66% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/LastSDKUpdateRun.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/LastSDKUpdateRun.kt index ad5f5b31fc..a9c560ca93 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/LastSDKUpdateRun.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/LastSDKUpdateRun.kt @@ -1,7 +1,7 @@ -package flank.scripts.shell.firebase.sdk +package flank.scripts.ops.shell.firebase.sdk import flank.common.config.updateDependenciesWorkflowFilename -import flank.scripts.github.commons.getLastWorkflowRunDate +import flank.scripts.data.github.commons.getLastWorkflowRunDate suspend fun getLastSDKUpdateRunDate(token: String) = getLastWorkflowRunDate( token = token, diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/OpenedUpdates.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/OpenedUpdates.kt similarity index 85% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/OpenedUpdates.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/OpenedUpdates.kt index 290bc21574..fda07ea2cc 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/OpenedUpdates.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/OpenedUpdates.kt @@ -1,9 +1,9 @@ -package flank.scripts.shell.firebase.sdk +package flank.scripts.ops.shell.firebase.sdk import com.github.kittinunf.result.getOrElse import com.github.kittinunf.result.onError import flank.common.config.updatesOpenedUser -import flank.scripts.github.getGitHubIssueList +import flank.scripts.data.github.getGitHubIssueList suspend fun checkForOpenedUpdates(token: String) = getGitHubIssueList( githubToken = token, diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/SDKUpdateContext.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/SDKUpdateContext.kt similarity index 72% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/SDKUpdateContext.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/SDKUpdateContext.kt index 71871e35c7..42e8793163 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/SDKUpdateContext.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/firebase/sdk/SDKUpdateContext.kt @@ -1,6 +1,6 @@ -package flank.scripts.shell.firebase.sdk +package flank.scripts.ops.shell.firebase.sdk -import flank.scripts.github.objects.GithubPullRequest +import flank.scripts.data.github.objects.GithubPullRequest import flank.scripts.utils.Version data class SDKUpdateContext( diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateAtomic.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/updatebinaries/UpdateAtomic.kt similarity index 97% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateAtomic.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/shell/updatebinaries/UpdateAtomic.kt index 0e65e43c64..07a8d72128 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateAtomic.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/updatebinaries/UpdateAtomic.kt @@ -1,4 +1,4 @@ -package flank.scripts.shell.updatebinaries +package flank.scripts.ops.shell.updatebinaries import flank.common.downloadFile import flank.common.extract diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/updatebinaries/UpdateBinaries.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/updatebinaries/UpdateBinaries.kt new file mode 100644 index 0000000000..50ec6e1d0d --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/updatebinaries/UpdateBinaries.kt @@ -0,0 +1,15 @@ +package flank.scripts.ops.shell.updatebinaries + +import kotlinx.coroutines.joinAll +import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking + +fun updateBinaries() = runBlocking { + listOf( + launch { updateAtomic() }, + launch { updateLlvm() }, + launch { updateSwift() } + ).joinAll() + + println("Binaries updated") +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateLlvm.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/updatebinaries/UpdateLlvm.kt similarity index 98% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateLlvm.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/shell/updatebinaries/UpdateLlvm.kt index 8e87ae49ec..e2dbbc0455 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateLlvm.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/updatebinaries/UpdateLlvm.kt @@ -1,4 +1,4 @@ -package flank.scripts.shell.updatebinaries +package flank.scripts.ops.shell.updatebinaries import flank.common.downloadFile import flank.common.extract diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateSwift.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/updatebinaries/UpdateSwift.kt similarity index 98% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateSwift.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/shell/updatebinaries/UpdateSwift.kt index 3f5f626af8..927c0d894b 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateSwift.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/shell/updatebinaries/UpdateSwift.kt @@ -1,4 +1,4 @@ -package flank.scripts.shell.updatebinaries +package flank.scripts.ops.shell.updatebinaries import flank.common.downloadFile import flank.common.extract diff --git a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/ArtifactsArchive.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/ArtifactsArchive.kt similarity index 96% rename from flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/ArtifactsArchive.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/ArtifactsArchive.kt index c86b95f47e..9773bba890 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/ArtifactsArchive.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/ArtifactsArchive.kt @@ -1,4 +1,4 @@ -package flank.scripts.testartifacts.core +package flank.scripts.ops.testartifacts import flank.scripts.utils.currentGitBranch import java.io.File diff --git a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/Constants.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/Constants.kt similarity index 92% rename from flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/Constants.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/Constants.kt index 53d1541c2b..c4fe8b23ad 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/Constants.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/Constants.kt @@ -1,4 +1,4 @@ -package flank.scripts.testartifacts.core +package flank.scripts.ops.testartifacts import flank.scripts.utils.currentGitBranch import java.io.File diff --git a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/Context.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/Context.kt similarity index 90% rename from flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/Context.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/Context.kt index 2d3f2012f4..5a4dc3b933 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/Context.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/Context.kt @@ -1,4 +1,4 @@ -package flank.scripts.testartifacts.core +package flank.scripts.ops.testartifacts import flank.scripts.utils.currentGitBranch import java.io.File diff --git a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/DownloadFixtures.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/DownloadFixtures.kt similarity index 94% rename from flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/DownloadFixtures.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/DownloadFixtures.kt index 7908913826..efc4ffe810 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/DownloadFixtures.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/DownloadFixtures.kt @@ -1,8 +1,8 @@ -package flank.scripts.testartifacts.core +package flank.scripts.ops.testartifacts import com.jcabi.github.Release import flank.common.downloadFile -import flank.scripts.github.getRelease +import flank.scripts.data.github.getRelease import java.io.File fun Context.downloadFixtures( diff --git a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/IsNewVersionAvailable.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/IsNewVersionAvailable.kt similarity index 81% rename from flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/IsNewVersionAvailable.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/IsNewVersionAvailable.kt index 5e43c2688c..6faab73706 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/IsNewVersionAvailable.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/IsNewVersionAvailable.kt @@ -1,7 +1,7 @@ -package flank.scripts.testartifacts.core +package flank.scripts.ops.testartifacts import com.jcabi.github.Repo -import flank.scripts.github.getRelease +import flank.scripts.data.github.getRelease internal fun Context.isNewVersionAvailable( repo: Repo = testArtifactsRepo() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/LinkArtifacts.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/LinkArtifacts.kt similarity index 88% rename from flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/LinkArtifacts.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/LinkArtifacts.kt index 82172a5ef6..3a62e9abde 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/LinkArtifacts.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/LinkArtifacts.kt @@ -1,4 +1,4 @@ -package flank.scripts.testartifacts.core +package flank.scripts.ops.testartifacts import flank.common.linkFiles diff --git a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/PrepareTestArtifacts.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/PrepareTestArtifacts.kt similarity index 90% rename from flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/PrepareTestArtifacts.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/PrepareTestArtifacts.kt index fd058bdbcc..9163c68116 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/PrepareTestArtifacts.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/PrepareTestArtifacts.kt @@ -1,4 +1,4 @@ -package flank.scripts.testartifacts.core +package flank.scripts.ops.testartifacts fun Context.prepareTestArtifacts(src: String = "master") { print("* Creating artifacts directory for $branch based on $src - ") diff --git a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/RemoveRemoteCopy.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/RemoveRemoteCopy.kt similarity index 72% rename from flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/RemoveRemoteCopy.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/RemoveRemoteCopy.kt index 0cf9bbb4f8..16457b5f7d 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/RemoveRemoteCopy.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/RemoveRemoteCopy.kt @@ -1,6 +1,6 @@ -package flank.scripts.testartifacts.core +package flank.scripts.ops.testartifacts -import flank.scripts.github.getRelease +import flank.scripts.data.github.getRelease fun Context.removeRemoteCopy() { print("* Removing remote copy for $branch - ") diff --git a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/ResolveArtifacts.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/ResolveArtifacts.kt similarity index 95% rename from flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/ResolveArtifacts.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/ResolveArtifacts.kt index 579f890e38..833df6abff 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/ResolveArtifacts.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/ResolveArtifacts.kt @@ -1,4 +1,4 @@ -package flank.scripts.testartifacts.core +package flank.scripts.ops.testartifacts import com.jcabi.github.Repo diff --git a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/TestArtifactsRepo.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/TestArtifactsRepo.kt similarity index 73% rename from flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/TestArtifactsRepo.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/TestArtifactsRepo.kt index f9c2da896c..ed80effc05 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/TestArtifactsRepo.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/TestArtifactsRepo.kt @@ -1,8 +1,8 @@ -package flank.scripts.testartifacts.core +package flank.scripts.ops.testartifacts import com.jcabi.github.Repo import flank.common.config.flankTestArtifactsRepository -import flank.scripts.github.githubRepo +import flank.scripts.data.github.githubRepo import flank.scripts.utils.getEnv internal fun testArtifactsRepo(): Repo = githubRepo(getEnv(GITHUB_TOKEN_ENV_KEY), flankTestArtifactsRepository) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/UploadFixtures.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/UploadFixtures.kt similarity index 90% rename from flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/UploadFixtures.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/UploadFixtures.kt index d370da17bb..bcd4f68a06 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/UploadFixtures.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/UploadFixtures.kt @@ -1,8 +1,8 @@ -package flank.scripts.testartifacts.core +package flank.scripts.ops.testartifacts import com.jcabi.github.Release import com.jcabi.github.ReleaseAsset -import flank.scripts.github.getOrCreateRelease +import flank.scripts.data.github.getOrCreateRelease import java.io.File fun Context.uploadFixtures() { diff --git a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/ZipArtifacts.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/ZipArtifacts.kt similarity index 94% rename from flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/ZipArtifacts.kt rename to flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/ZipArtifacts.kt index acf769ce27..329e03636e 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/ZipArtifacts.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/testartifacts/ZipArtifacts.kt @@ -1,4 +1,4 @@ -package flank.scripts.testartifacts.core +package flank.scripts.ops.testartifacts import flank.common.unzipFile import flank.common.zip diff --git a/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/GitHubIssuePropertiesCopy.kt b/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/GitHubIssuePropertiesCopy.kt deleted file mode 100644 index 458759e2fa..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/GitHubIssuePropertiesCopy.kt +++ /dev/null @@ -1,54 +0,0 @@ -package flank.scripts.pullrequest - -import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.clikt.parameters.options.option -import com.github.ajalt.clikt.parameters.options.required -import com.github.ajalt.clikt.parameters.types.int -import com.github.kittinunf.result.onError -import com.github.kittinunf.result.success -import flank.scripts.github.getGitHubPullRequest -import flank.scripts.zenhub.copyEstimation -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.coroutineScope -import kotlinx.coroutines.joinAll -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking - -object CopyProperties : - CliktCommand(name = "copyProperties", help = "Copy properties from referenced issue to pull request") { - - private val githubToken by option(help = "Git Token").required() - private val zenhubToken by option(help = "ZenHub api Token").required() - private val prNumber by option(help = "Pull request number").int().required() - - override fun run() = runBlocking { - getGitHubPullRequest(githubToken, prNumber) - .onError { println("Could not copy properties, because of ${it.message}") } - .success { pullRequest -> - val issueNumber = pullRequest.findReferenceNumber() - checkNotNull(issueNumber) { "Reference issue not found on description and branch" } - println("Found referenced issue #$issueNumber") - launch(Dispatchers.IO) { copyGitHubProperties(githubToken, issueNumber, prNumber) } - launch(Dispatchers.IO) { copyZenhubProperties(zenhubToken, issueNumber, prNumber) } - } - } -} - -private suspend fun copyGitHubProperties( - githubToken: String, - baseIssueNumber: Int, - prNumber: Int -) = coroutineScope { - listOf( - launch { copyAssignees(githubToken, baseIssueNumber, prNumber) }, - launch { copyLabels(githubToken, baseIssueNumber, prNumber) }, - ).joinAll() -} - -private suspend fun copyZenhubProperties( - zenhubToken: String, - baseIssueNumber: Int, - prNumber: Int -) { - copyEstimation(zenhubToken, baseIssueNumber, prNumber) -} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/PullRequestCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/PullRequestCommand.kt deleted file mode 100644 index 2cf92a7bb3..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/PullRequestCommand.kt +++ /dev/null @@ -1,14 +0,0 @@ -package flank.scripts.pullrequest - -import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.clikt.core.subcommands - -object PullRequestCommand : CliktCommand(name = "pullRequest") { - - init { - subcommands(CopyProperties) - } - - @Suppress("EmptyFunctionBlock") - override fun run() {} -} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/release/ReleaseCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/release/ReleaseCommand.kt deleted file mode 100644 index 8485c56c75..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/release/ReleaseCommand.kt +++ /dev/null @@ -1,25 +0,0 @@ -package flank.scripts.release - -import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.clikt.core.subcommands -import flank.scripts.release.hub.DeleteOldReleaseCommand -import flank.scripts.release.hub.DeleteOldTagCommand -import flank.scripts.release.hub.ReleaseFlankCommand -import flank.scripts.release.jfrog.delete.DeleteOldSnapshotCommand -import flank.scripts.release.jfrog.sync.SyncMavenCommand - -class ReleaseCommand : CliktCommand(name = "release", help = "Contains all release commands") { - - init { - subcommands( - ReleaseFlankCommand(), - DeleteOldSnapshotCommand(), - SyncMavenCommand(), - DeleteOldReleaseCommand(), - DeleteOldTagCommand() - ) - } - - @Suppress("EmptyFunctionBlock") - override fun run() {} -} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/release/hub/DeleteOldRelease.kt b/flank-scripts/src/main/kotlin/flank/scripts/release/hub/DeleteOldRelease.kt deleted file mode 100644 index 184854ec7b..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/release/hub/DeleteOldRelease.kt +++ /dev/null @@ -1,19 +0,0 @@ -package flank.scripts.release.hub - -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.utils.runCommand - -class DeleteOldReleaseCommand : CliktCommand(name = "deleteOldRelease", help = "Delete old release on github") { - - private val gitTag by option(help = "Git Tag").required() - - override fun run() { - deleteOldRelease(gitTag) - } -} - -fun deleteOldRelease(tag: String) = "$DELETE_RELEASE_COMMAND $tag".runCommand() - -private const val DELETE_RELEASE_COMMAND = "hub release delete" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/release/hub/DeleteOldTagCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/release/hub/DeleteOldTagCommand.kt deleted file mode 100644 index 56903e16e3..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/release/hub/DeleteOldTagCommand.kt +++ /dev/null @@ -1,24 +0,0 @@ -package flank.scripts.release.hub - -import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.clikt.parameters.options.option -import com.github.ajalt.clikt.parameters.options.required -import com.github.kittinunf.result.Result -import flank.scripts.github.deleteOldTag -import kotlinx.coroutines.runBlocking - -class DeleteOldTagCommand : CliktCommand(name = "deleteOldTag", help = "Delete old tag on GitHub") { - - private val gitTag by option(help = "Git Tag").required() - private val username by option(help = "Git User").required() - private val token by option(help = "Git Token").required() - - override fun run() { - runBlocking { - when (val response = deleteOldTag(gitTag, username, token)) { - is Result.Success -> println("Tag $gitTag was deleted") - is Result.Failure -> println(response.error) - } - } - } -} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/release/jfrog/delete/DeleteOldSnapshot.kt b/flank-scripts/src/main/kotlin/flank/scripts/release/jfrog/delete/DeleteOldSnapshot.kt deleted file mode 100644 index a00e6dccd7..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/release/jfrog/delete/DeleteOldSnapshot.kt +++ /dev/null @@ -1,20 +0,0 @@ -package flank.scripts.release.jfrog.delete - -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.release.jfrog.flankMaven -import flank.scripts.utils.runCommand - -class DeleteOldSnapshotCommand : CliktCommand(name = "jFrogDelete", help = "Delete old version on bintray") { - - private val version by option(help = "Maven version to delete").required() - - override fun run() { - jFrogDeleteOldSnapshot(version) - } -} - -fun jFrogDeleteOldSnapshot(version: String) { - "jfrog bt version-delete ${flankMaven(version)} --quiet".runCommand() -} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ShellCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ShellCommand.kt deleted file mode 100644 index 69bcaf5ca2..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ShellCommand.kt +++ /dev/null @@ -1,33 +0,0 @@ -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.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 - -object ShellCommand : CliktCommand(name = "shell", help = "Task for shell commands") { - init { - subcommands( - FirebaseCommand, - BuildExampleCommand, - BuildFtlCommand, - RunFtlLocalCommand, - UniversalFrameworkCommand, - OpsCommand, - UpdateBinariesCommand, - BuildFlankCommand, - InstallXcPrettyCommand, - SetupIosEnvCommand - ) - } - - @Suppress("EmptyFunctionBlock") - override fun run() {} -} 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 deleted file mode 100644 index f3b44ac32e..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/FirebaseCommand.kt +++ /dev/null @@ -1,22 +0,0 @@ -package flank.scripts.shell.firebase - -import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.clikt.core.subcommands -import flank.scripts.shell.firebase.apiclient.GenerateJavaClientCommand -import flank.scripts.shell.firebase.apiclient.UpdateApiJsonCommand -import flank.scripts.shell.firebase.sdk.CheckForSDKUpdateCommand - -object FirebaseCommand : CliktCommand(name = "firebase", help = "Contains all firebase commands") { - - init { - subcommands( - UpdateApiJsonCommand, - GenerateJavaClientCommand, - CheckForSDKUpdateCommand - ) - } - - @Suppress("EmptyFunctionBlock") - override fun run() { - } -} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/apiclient/GenerateJavaClientCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/apiclient/GenerateJavaClientCommand.kt deleted file mode 100644 index 1995679c31..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/apiclient/GenerateJavaClientCommand.kt +++ /dev/null @@ -1,37 +0,0 @@ -package flank.scripts.shell.firebase.apiclient - -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 -import java.nio.file.Files -import java.nio.file.Paths -import java.nio.file.StandardCopyOption - -object GenerateJavaClientCommand : CliktCommand(name = "generateJavaClient", help = "Generate Java Client") { - - override fun run() { - checkIfPipInstalled() - installClientGeneratorIfNeeded() - val firebaseApiPath = Paths.get("firebase_apis").toString() - val apiPath = Paths.get(firebaseApiPath, "test_api").toString() - val outputDirectory = Paths.get(apiPath, "src", "main", "java").toString() - val testingJsonInput = Paths.get(firebaseApiPath, "json", "testing_v1.json").toString() - Paths.get(apiPath, "src").toFile().deleteRecursively() - - val generateLibraryCommand = "generate_library " + - "--input=$testingJsonInput " + - "--language=java " + - "--output_dir=$outputDirectory" - - val result = generateLibraryCommand.runCommand() - if (result != 0) throw ShellCommandException("Error when execute generate_library command") - - 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/shell/firebase/apiclient/UpdateApiJsonCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/apiclient/UpdateApiJsonCommand.kt deleted file mode 100644 index bce2aff3c9..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/apiclient/UpdateApiJsonCommand.kt +++ /dev/null @@ -1,32 +0,0 @@ -package flank.scripts.shell.firebase.apiclient - -import com.github.ajalt.clikt.core.CliktCommand -import flank.common.config.flankGcloudCLIRepository -import flank.common.currentPath -import flank.common.downloadFile -import flank.scripts.utils.downloadSortJsonIfNeeded -import flank.scripts.utils.runCommand -import java.nio.file.Paths - -object UpdateApiJsonCommand : CliktCommand(name = "updateApiJson", help = "Download file for generating client") { - override fun run() { - val jsonDirectoryPath = Paths.get(currentPath.toString(), "firebase_apis", "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/$flankGcloudCLIRepository/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/testing_v1.json", - testingV1Path - ) - - downloadFile( - "https://raw.githubusercontent.com/$flankGcloudCLIRepository/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/toolresults_v1beta3.json", - testingV1Beta3Path - ) - - downloadSortJsonIfNeeded() - - "sort-json $testingV1Path".runCommand() - "sort-json $testingV1Beta3Path".runCommand() - } -} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CheckForSDKUpdateCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CheckForSDKUpdateCommand.kt deleted file mode 100644 index 2c81f4bf84..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CheckForSDKUpdateCommand.kt +++ /dev/null @@ -1,70 +0,0 @@ -package flank.scripts.shell.firebase.sdk - -import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.clikt.parameters.options.option -import com.github.ajalt.clikt.parameters.options.required -import com.github.kittinunf.fuel.Fuel -import flank.common.config.flankGcloudCLIRepository -import flank.common.currentPath -import flank.common.downloadFile -import flank.scripts.utils.parseToVersion -import kotlinx.coroutines.runBlocking -import java.nio.file.Paths -import java.time.Instant - -private val RAW_GITHUB = "https://raw.githubusercontent.com/$flankGcloudCLIRepository" - -object CheckForSDKUpdateCommand : CliktCommand( - name = "checkForSdkUpdate", - help = "Verifies if there were changes in gcloud sdk that need to be implemented in flank" -) { - - private val githubToken by option(help = "Git Token").required() - private val zenhubToken by option(help = "Zenhub Token").required() - private val lastRun by lazy { runBlocking { getLastSDKUpdateRunDate(githubToken) } } - private val openedUpdates by lazy { runBlocking { checkForOpenedUpdates(githubToken) } } - - override fun run() = runBlocking { - println("** Find previously checked commit") - val oldSha = getCommitsUntilLastCheck(githubToken, lastRun) ?: run { - println("** Unable to find previous commit") - return@runBlocking - } - println("** Find latest commit") - val newSha = getCommitsUntilLastCheck(githubToken, Instant.now().toString()) ?: run { - println("** Unable to find latest commit") - return@runBlocking - } - - if (oldSha == newSha) { - println("** No new commits since the last run") - return@runBlocking - } - - with(createContext(oldSha)) { - println("** New version $newVersion") - println("** Old version $oldVersion") - when { - oldVersion >= newVersion -> println("** No new features") - openedUpdates != null -> updateOpenedEpic() - openedUpdates == null -> createEpicIssue() - } - } - } - - private fun createContext(sha: String) = SDKUpdateContext( - oldVersion = getVersionBySHA(sha), - newVersion = getVersionBySHA("master"), - updatesLazy = suspend { - val notes = Paths.get(currentPath.toString(), "notes.txt") - downloadFile("$RAW_GITHUB/master/google-cloud-sdk/RELEASE_NOTES", notes) - notes.toFile().apply { deleteOnExit() }.readText() - }, - githubToken = githubToken, - zenhubToken = zenhubToken, - openedIssue = openedUpdates - ) - - private fun getVersionBySHA(sha: String) = - parseToVersion(Fuel.get("$RAW_GITHUB/$sha/google-cloud-sdk/VERSION").responseString().third.get()) -} 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 deleted file mode 100644 index 86247fc3ab..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/InstallXcPrettyCommand.kt +++ /dev/null @@ -1,12 +0,0 @@ -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/RunFtlLocal.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt deleted file mode 100644 index c71c18f33f..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt +++ /dev/null @@ -1,32 +0,0 @@ -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.common.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 = "iosRunFtlLocal", help = "Run ftl locally ios app") { - - private val deviceId by option(help = "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/SetupIosEnvCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/SetupIosEnvCommand.kt deleted file mode 100644 index 40424ce04c..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/SetupIosEnvCommand.kt +++ /dev/null @@ -1,17 +0,0 @@ -package flank.scripts.shell.ios - -import com.github.ajalt.clikt.core.CliktCommand -import flank.common.iOSTestProjectsPath -import flank.scripts.shell.ops.EARL_GREY_EXAMPLE -import flank.scripts.shell.utils.failIfWindows -import flank.scripts.utils.downloadCocoaPodsIfNeeded -import flank.scripts.utils.installPodsIfNeeded -import java.nio.file.Paths - -object SetupIosEnvCommand : CliktCommand(name = "setup_ios_env", help = "Build ios app with tests") { - override fun run() { - failIfWindows() - downloadCocoaPodsIfNeeded() - installPodsIfNeeded(Paths.get(iOSTestProjectsPath, EARL_GREY_EXAMPLE)) - } -} 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 deleted file mode 100644 index 8bec169095..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildAndroid.kt +++ /dev/null @@ -1,121 +0,0 @@ -package flank.scripts.shell.ops - -import flank.common.androidTestProjectsPath -import flank.common.flankFixturesTmpPath -import flank.scripts.shell.utils.createGradleCommand -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/BuildEarlGreyExampleCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildEarlGreyExampleCommand.kt deleted file mode 100644 index 1abb73680a..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildEarlGreyExampleCommand.kt +++ /dev/null @@ -1,37 +0,0 @@ -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.common.iOSTestProjectsPath -import flank.scripts.shell.utils.failIfWindows -import java.nio.file.Paths - -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) - - 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, EARL_GREY_EXAMPLE).toString(), - projectName = EARL_GREY_EXAMPLE, - buildConfigurations = listOf( - IosTestBuildConfiguration(EARL_GREY_EXAMPLE_SWIFT_TESTS, "swift"), - IosTestBuildConfiguration(EARL_GREY_EXAMPLE_TESTS, "objective_c") - ), - useWorkspace = true, - generate = generate ?: true, - copy = copy ?: true, - copyXCTestFiles = copy ?: true, - useLegacyBuildSystem = true - ).generateIosTestArtifacts() - } -} - -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 deleted file mode 100644 index a4e0959999..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildFlankExampleCommand.kt +++ /dev/null @@ -1,32 +0,0 @@ -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.common.iOSTestProjectsPath -import flank.scripts.shell.utils.failIfWindows -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 - ).generateIosTestArtifacts() - } -} - -private const val FLANK_EXAMPLE = "FlankExample" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildGameLoopExampleCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildGameLoopExampleCommand.kt deleted file mode 100644 index 3dce78b843..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildGameLoopExampleCommand.kt +++ /dev/null @@ -1,35 +0,0 @@ -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.common.iOSTestProjectsPath -import flank.scripts.shell.utils.failIfWindows -import java.nio.file.Paths - -object BuildGameLoopExampleCommand : CliktCommand( - name = "build_ios_gameloop_example", - help = "Build ios game loop example app" -) { - - 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_GAME_LOOP_EXAMPLE).toString(), - projectName = FLANK_GAME_LOOP_EXAMPLE, - buildConfigurations = listOf( - IosTestBuildConfiguration(FLANK_GAME_LOOP_EXAMPLE, "tests"), - ), - useWorkspace = false, - generate = generate ?: true, - copy = copy ?: true - ).generateIPA() - } -} - -private const val FLANK_GAME_LOOP_EXAMPLE = "FlankGameLoopExample" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildTestPlansExample.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildTestPlansExample.kt deleted file mode 100644 index b7ddbc1749..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildTestPlansExample.kt +++ /dev/null @@ -1,32 +0,0 @@ -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.common.iOSTestProjectsPath -import flank.scripts.shell.utils.failIfWindows -import java.nio.file.Paths - -object BuildTestPlansExample : CliktCommand(name = "build_ios_testplans_example", help = "Build ios test plans example app") { - - 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_TEST_PLANS_EXAMPLE).toString(), - projectName = FLANK_TEST_PLANS_EXAMPLE, - buildConfigurations = listOf( - IosTestBuildConfiguration("AllTests", "AllTests"), - ), - useWorkspace = false, - generate = generate ?: true, - copy = copy ?: true - ).generateIosTestArtifacts() - } -} - -private const val FLANK_TEST_PLANS_EXAMPLE = "FlankTestPlansExample" 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 deleted file mode 100644 index a68d806cfa..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOS.kt +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index e03f0c0f07..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt +++ /dev/null @@ -1,36 +0,0 @@ -package flank.scripts.shell.ops - -import com.github.ajalt.clikt.core.CliktCommand -import flank.common.flankFixturesTmpPath -import flank.common.testProjectsPath -import flank.scripts.utils.runCommand -import java.nio.file.Path -import java.nio.file.Paths - -object GoOpsCommand : CliktCommand(name = "go", help = "Build go app with tests") { - override fun run() { - 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/updatebinaries/UpdateBinariesCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateBinariesCommand.kt deleted file mode 100644 index b42fe638ad..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/updatebinaries/UpdateBinariesCommand.kt +++ /dev/null @@ -1,21 +0,0 @@ -package flank.scripts.shell.updatebinaries - -import com.github.ajalt.clikt.core.CliktCommand -import kotlinx.coroutines.joinAll -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking - -object UpdateBinariesCommand : CliktCommand(name = "updateBinaries", help = "Update binaries used by Flank") { - - override fun run() { - runBlocking { - listOf( - launch { updateAtomic() }, - launch { updateLlvm() }, - launch { updateSwift() } - ).joinAll() - - println("Binaries updated") - } - } -} 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 deleted file mode 100644 index f086d9c36a..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/ShellHelper.kt +++ /dev/null @@ -1,12 +0,0 @@ -package flank.scripts.shell.utils - -import flank.scripts.utils.isWindows -import flank.scripts.utils.runCommand - -infix fun String.pipe(command: String) { - if (isWindows) { - listOf("cmd", "/C", "$this | $command").runCommand() - } else { - listOf("/bin/bash", "-c", "$this | $command").runCommand() - } -} 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 deleted file mode 100644 index 7a18faeeea..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/TestFilters.kt +++ /dev/null @@ -1,28 +0,0 @@ -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/testartifacts/TestArtifacts.kt b/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/TestArtifacts.kt deleted file mode 100644 index 5cf9713a63..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/TestArtifacts.kt +++ /dev/null @@ -1,145 +0,0 @@ -package flank.scripts.testartifacts - -import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.clikt.core.findOrSetObject -import com.github.ajalt.clikt.core.requireObject -import com.github.ajalt.clikt.core.subcommands -import com.github.ajalt.clikt.parameters.options.default -import com.github.ajalt.clikt.parameters.options.defaultLazy -import com.github.ajalt.clikt.parameters.options.flag -import com.github.ajalt.clikt.parameters.options.option -import com.github.ajalt.clikt.parameters.types.file -import flank.scripts.testartifacts.core.Context -import flank.scripts.testartifacts.core.downloadFixtures -import flank.scripts.testartifacts.core.flankRoot -import flank.scripts.testartifacts.core.linkArtifacts -import flank.scripts.testartifacts.core.prepareTestArtifacts -import flank.scripts.testartifacts.core.removeRemoteCopy -import flank.scripts.testartifacts.core.resolveArtifacts -import flank.scripts.testartifacts.core.unzipTestArtifacts -import flank.scripts.testartifacts.core.uploadFixtures -import flank.scripts.testartifacts.core.zipTestArtifacts -import flank.scripts.utils.currentGitBranch -import java.io.File - -class TestArtifactsCommand : CliktCommand( - name = "testArtifacts", - help = "The base command for artifacts management." -) { - - private val branch: String by option( - "--branch", "-b", - help = "Branch name that identify test artifacts to operate. The current git branch is a default." - ).defaultLazy { currentGitBranch() } - - private val projectRoot: File by option( - "--project-root", "-p", - help = "Path to local project repository root. By default it is resolved from FLANK_ROOT env variable." - ).file().defaultLazy { flankRoot() } - - private val artifacts by findOrSetObject { - Context( - branch = branch, - projectRoot = projectRoot - ) - } - - init { - subcommands( - DownloadCommand(), - UploadCommand(), - PrepareCommand(), - ZipCommand(), - UnzipCommand(), - LinkCommand(), - RemoveCommand(), - ResolveCommand() - ) - } - - override fun run() { - artifacts - } -} - -private class DownloadCommand : CliktCommand( - help = "Download test artifacts zip asset to test_artifacts directory." -) { - val artifacts by requireObject() - val overwrite by option( - "--overwrite", "-o", - help = "Flag which indicates if should overwrite old resources when downloading" - ).flag() - - override fun run() { - artifacts.downloadFixtures(overwrite) - } -} - -private class UploadCommand : CliktCommand( - help = "Upload test artifacts zip as github release asset." -) { - val artifacts by requireObject() - override fun run() { - artifacts.uploadFixtures() - } -} - -private class PrepareCommand : CliktCommand( - help = "Creates fresh copy of test artifacts for current working branch, basing on existing one." -) { - val artifacts by requireObject() - val source by option( - "--src", "-s", - help = "The name of branch that identify artifacts source. The master branch is a default." - ).default("master") - - override fun run() { - artifacts.prepareTestArtifacts(source) - } -} - -private class ZipCommand : CliktCommand( - help = "Create zip archive from test artifacts directory." -) { - val artifacts by requireObject() - override fun run() { - artifacts.zipTestArtifacts() - } -} - -private class UnzipCommand : CliktCommand( - help = "Unpack test artifacts zip archive." -) { - val artifacts by requireObject() - override fun run() { - artifacts.unzipTestArtifacts() - } -} - -private class LinkCommand : CliktCommand( - help = "Create symbolic link to under test_runner/src/test/kotlin/ftl/fixtures/tmp to test_artifacts/{branchName}." -) { - val artifacts by requireObject() - override fun run() { - artifacts.linkArtifacts() - } -} - -private class RemoveCommand : CliktCommand( - help = "Remove remote copy of test artifacts." -) { - val artifacts by requireObject() - override fun run() { - artifacts.removeRemoteCopy() - } -} - -private class ResolveCommand : CliktCommand( - help = "Automatically prepare local artifacts if needed." -) { - val artifacts by requireObject() - override fun run() { - artifacts.resolveArtifacts() - } -} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/FastFailForWindows.kt b/flank-scripts/src/main/kotlin/flank/scripts/utils/FastFailForWindows.kt similarity index 69% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/utils/FastFailForWindows.kt rename to flank-scripts/src/main/kotlin/flank/scripts/utils/FastFailForWindows.kt index 2aec5874d0..44653c95bf 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/FastFailForWindows.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/utils/FastFailForWindows.kt @@ -1,6 +1,5 @@ -package flank.scripts.shell.utils +package flank.scripts.utils -import flank.scripts.utils.isWindows import kotlin.system.exitProcess fun failIfWindows() { diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/GradleCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/utils/GradleCommand.kt similarity index 85% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/utils/GradleCommand.kt rename to flank-scripts/src/main/kotlin/flank/scripts/utils/GradleCommand.kt index c4021fe718..0167c8e73a 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/GradleCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/utils/GradleCommand.kt @@ -1,6 +1,5 @@ -package flank.scripts.shell.utils +package flank.scripts.utils -import flank.scripts.utils.isWindows import java.nio.file.Paths fun createGradleCommand( diff --git a/flank-scripts/src/main/kotlin/flank/scripts/utils/Path.kt b/flank-scripts/src/main/kotlin/flank/scripts/utils/Path.kt new file mode 100644 index 0000000000..169a414da1 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/utils/Path.kt @@ -0,0 +1,8 @@ +package flank.scripts.utils + +import flank.common.currentPath +import flank.common.goToRoot + +fun getRootPathString() = goToRoot(currentPath).toAbsolutePath().toString() +fun getRootDirFile() = goToRoot(currentPath).toAbsolutePath().toFile() +fun getKtlintFilePath() = getRootPathString() + (if (isWindows) "\\" else "/") + "ktlint" 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 7900c2a496..feceff14cb 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/utils/ShellExecute.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/utils/ShellExecute.kt @@ -43,6 +43,14 @@ fun String.commandInstalledOr(orAction: () -> Unit) = checkCommandExists().takeU orAction() } +infix fun String.pipe(command: String) { + if (isWindows) { + listOf("cmd", "/C", "$this | $command").runCommand() + } else { + listOf("/bin/bash", "-c", "$this | $command").runCommand() + } +} + internal fun ProcessBuilder.startWithRetry(retryCount: Int): Int { var retryTries = 0 var processResponse: Int diff --git a/flank-scripts/src/main/kotlin/flank/scripts/exceptions/FlankScriptsExceptionMappers.kt b/flank-scripts/src/main/kotlin/flank/scripts/utils/exceptions/FlankScriptsExceptionMappers.kt similarity index 95% rename from flank-scripts/src/main/kotlin/flank/scripts/exceptions/FlankScriptsExceptionMappers.kt rename to flank-scripts/src/main/kotlin/flank/scripts/utils/exceptions/FlankScriptsExceptionMappers.kt index a43da6c573..7e8efcf799 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/exceptions/FlankScriptsExceptionMappers.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/utils/exceptions/FlankScriptsExceptionMappers.kt @@ -1,4 +1,4 @@ -package flank.scripts.exceptions +package flank.scripts.utils.exceptions import com.github.kittinunf.fuel.core.FuelError import com.github.kittinunf.fuel.core.isClientError diff --git a/flank-scripts/src/main/kotlin/flank/scripts/exceptions/FlankScriptsExceptions.kt b/flank-scripts/src/main/kotlin/flank/scripts/utils/exceptions/FlankScriptsExceptions.kt similarity index 86% rename from flank-scripts/src/main/kotlin/flank/scripts/exceptions/FlankScriptsExceptions.kt rename to flank-scripts/src/main/kotlin/flank/scripts/utils/exceptions/FlankScriptsExceptions.kt index 3258f47fb5..fc560f3cfc 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/exceptions/FlankScriptsExceptions.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/utils/exceptions/FlankScriptsExceptions.kt @@ -1,6 +1,6 @@ -package flank.scripts.exceptions +package flank.scripts.utils.exceptions -import flank.scripts.github.GitHubErrorResponse +import flank.scripts.data.github.GitHubErrorResponse sealed class FlankScriptsExceptions : Exception() diff --git a/flank-scripts/src/test/kotlin/TestUtils.kt b/flank-scripts/src/test/kotlin/TestUtils.kt deleted file mode 100644 index 036eee8043..0000000000 --- a/flank-scripts/src/test/kotlin/TestUtils.kt +++ /dev/null @@ -1,8 +0,0 @@ -import org.junit.Assume.assumeFalse - -// TODO move to shared module -fun skipIfWindows() { - assumeFalse(isWindows) -} - -private val isWindows get() = System.getProperty("os.name")?.toLowerCase().orEmpty().indexOf("win") >= 0 diff --git a/flank-scripts/src/test/kotlin/flank/common/FilesTest.kt b/flank-scripts/src/test/kotlin/flank/common/FilesTest.kt deleted file mode 100644 index e664bc5666..0000000000 --- a/flank-scripts/src/test/kotlin/flank/common/FilesTest.kt +++ /dev/null @@ -1,62 +0,0 @@ -package flank.common - -import org.junit.Assert -import org.junit.Assume -import org.junit.Rule -import org.junit.Test -import org.junit.rules.TemporaryFolder -import java.nio.file.Files -import java.nio.file.Paths - -internal class FilesTest { - - @get:Rule - val root = TemporaryFolder() - - @Test - fun `Should create symbolic file at desired location`() { - Assume.assumeFalse(isWindows) - // given - val testFile = root.newFile("test.file").toPath() - val expectedDestination = Paths.get(root.newFolder("temp").toString(), "test.link") - - // when - createSymbolicLinkToFile(expectedDestination, testFile) - - // then - Assert.assertTrue(Files.isSymbolicLink(expectedDestination)) - - // clean - testFile.toFile().delete() - expectedDestination.toFile().delete() - } - - @Test - fun `Should check if directory contains all needed files`() { - // given - val testDirectory = root.newFolder("test").toPath() - val testFiles = listOf( - Paths.get(testDirectory.toString(), "testFile1"), - Paths.get(testDirectory.toString(), "testFile2"), - Paths.get(testDirectory.toString(), "testFile3"), - Paths.get(testDirectory.toString(), "testFile4") - ) - - testFiles.forEach { Files.createFile(it) } - - // when - val resultTrue = testDirectory.toFile().hasAllFiles(testFiles.map { it.fileName.toString() }) - val resultFalse = testDirectory.toFile() - .hasAllFiles( - (testFiles + Paths.get(testDirectory.toString(), "testFile5")) - .map { it.fileName.toString() } - ) - - // then - Assert.assertTrue(resultTrue) - Assert.assertFalse(resultFalse) - - // clean - testDirectory.toFile().deleteRecursively() - } -} diff --git a/flank-scripts/src/test/kotlin/flank/scripts/FuelMockServer.kt b/flank-scripts/src/test/kotlin/flank/scripts/FuelMockServer.kt index 773f523408..3940c0bf5f 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/FuelMockServer.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/FuelMockServer.kt @@ -4,7 +4,7 @@ import com.github.kittinunf.fuel.core.Client import com.github.kittinunf.fuel.core.Request import com.github.kittinunf.fuel.core.Response import com.github.kittinunf.fuel.core.requests.DefaultBody -import flank.scripts.zenhub.ZENHUB_BASE_URL +import flank.scripts.data.zenhub.ZENHUB_BASE_URL class FuelMockServer : Client { override fun executeRequest(request: Request): Response { diff --git a/flank-scripts/src/test/kotlin/flank/scripts/GithubMockServerHandler.kt b/flank-scripts/src/test/kotlin/flank/scripts/GithubMockServerHandler.kt index b03796ab63..a237a4b776 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/GithubMockServerHandler.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/GithubMockServerHandler.kt @@ -2,17 +2,17 @@ package flank.scripts import com.github.kittinunf.fuel.core.Method import com.github.kittinunf.fuel.core.Request -import flank.scripts.ci.releasenotes.GitHubRelease -import flank.scripts.github.objects.Author -import flank.scripts.github.objects.Commit -import flank.scripts.github.objects.GitHubCommit -import flank.scripts.github.objects.GitHubCreateIssueCommentResponse -import flank.scripts.github.objects.GitHubCreateIssueResponse -import flank.scripts.github.objects.GitHubLabel -import flank.scripts.github.objects.GitHubWorkflowRun -import flank.scripts.github.objects.GitHubWorkflowRunsSummary -import flank.scripts.github.objects.GithubPullRequest -import flank.scripts.github.objects.GithubUser +import flank.scripts.data.github.objects.Author +import flank.scripts.data.github.objects.Commit +import flank.scripts.data.github.objects.GitHubCommit +import flank.scripts.data.github.objects.GitHubCreateIssueCommentResponse +import flank.scripts.data.github.objects.GitHubCreateIssueResponse +import flank.scripts.data.github.objects.GitHubLabel +import flank.scripts.data.github.objects.GitHubRelease +import flank.scripts.data.github.objects.GitHubWorkflowRun +import flank.scripts.data.github.objects.GitHubWorkflowRunsSummary +import flank.scripts.data.github.objects.GithubPullRequest +import flank.scripts.data.github.objects.GithubUser import flank.scripts.utils.toJson import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json diff --git a/flank-scripts/src/test/kotlin/flank/scripts/ZenHubMockServerHandler.kt b/flank-scripts/src/test/kotlin/flank/scripts/ZenHubMockServerHandler.kt index 32b2930295..289908aa07 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/ZenHubMockServerHandler.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ZenHubMockServerHandler.kt @@ -2,9 +2,9 @@ package flank.scripts import com.github.kittinunf.fuel.core.Method import com.github.kittinunf.fuel.core.Request +import flank.scripts.data.zenhub.ZenHubEstimate +import flank.scripts.data.zenhub.ZenHubIssue import flank.scripts.utils.toJson -import flank.scripts.zenhub.ZenHubEstimate -import flank.scripts.zenhub.ZenHubIssue fun handleZenhubMockRequest(url: String, request: Request) = when { url.contains("issues") && request.isGet && request.isSuccessful() -> diff --git a/flank-scripts/src/test/kotlin/flank/scripts/ci/releasenotes/GenerateReleaseNotesCommandTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/cli/ci/GenerateReleaseNotesCommandTest.kt similarity index 85% rename from flank-scripts/src/test/kotlin/flank/scripts/ci/releasenotes/GenerateReleaseNotesCommandTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/cli/ci/GenerateReleaseNotesCommandTest.kt index 2e9429c73d..34e354142d 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/ci/releasenotes/GenerateReleaseNotesCommandTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/cli/ci/GenerateReleaseNotesCommandTest.kt @@ -1,4 +1,4 @@ -package flank.scripts.ci.releasenotes +package flank.scripts.cli.ci import com.google.common.truth.Truth.assertThat import org.junit.Test @@ -12,7 +12,7 @@ class GenerateReleaseNotesCommandTest { val expected = File.createTempFile("test", ".file").absolutePath // when - val command = GenerateReleaseNotesCommand().apply { + val command = GenerateReleaseNotesCommand.apply { main( listOf( "--token=token", diff --git a/flank-scripts/src/test/kotlin/flank/scripts/ci/nexttag/NextReleaseTagCommandTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/cli/ci/NextReleaseTagCommandTest.kt similarity index 83% rename from flank-scripts/src/test/kotlin/flank/scripts/ci/nexttag/NextReleaseTagCommandTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/cli/ci/NextReleaseTagCommandTest.kt index 4d41d3a13c..edf4d0224d 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/ci/nexttag/NextReleaseTagCommandTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/cli/ci/NextReleaseTagCommandTest.kt @@ -1,10 +1,10 @@ -package flank.scripts.ci.nexttag +package flank.scripts.cli.ci import com.github.kittinunf.result.Result import com.google.common.truth.Truth.assertThat import flank.scripts.FuelTestRunner -import flank.scripts.ci.releasenotes.GitHubRelease -import flank.scripts.github.getLatestReleaseTag +import flank.scripts.data.github.getLatestReleaseTag +import flank.scripts.data.github.objects.GitHubRelease import io.mockk.coEvery import io.mockk.every import io.mockk.mockkStatic @@ -35,7 +35,7 @@ class NextReleaseTagCommandTest { @Test fun `Should return properly message when success`() { mockkStatic( - "flank.scripts.github.GithubApiKt", + "flank.scripts.data.github.GithubApiKt", "java.time.LocalDate", "java.time.Year" ) { @@ -44,7 +44,7 @@ class NextReleaseTagCommandTest { coEvery { getLatestReleaseTag(any()) } returns Result.success(GitHubRelease("v20.09.0")) // when - NextReleaseTagCommand().main(arrayOf("--token=success")) + NextReleaseTagCommand.main(arrayOf("--token=success")) // expected assertThat(systemOutRule.log).contains("v20.09.1") @@ -59,6 +59,6 @@ class NextReleaseTagCommandTest { assertThat(systemOutRule.log).contains("Error while doing GitHub request") } // when - NextReleaseTagCommand().main(arrayOf("--token=failure")) + NextReleaseTagCommand.main(arrayOf("--token=failure")) } } diff --git a/flank-scripts/src/test/kotlin/flank/scripts/release/hub/DeleteOldTagCommandTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/cli/release/DeleteOldTagCommandTest.kt similarity index 76% rename from flank-scripts/src/test/kotlin/flank/scripts/release/hub/DeleteOldTagCommandTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/cli/release/DeleteOldTagCommandTest.kt index 268359bb70..7221e180c3 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/release/hub/DeleteOldTagCommandTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/cli/release/DeleteOldTagCommandTest.kt @@ -1,4 +1,4 @@ -package flank.scripts.release.hub +package flank.scripts.cli.release import com.google.common.truth.Truth.assertThat import flank.scripts.FuelTestRunner @@ -17,7 +17,7 @@ class DeleteOldTagCommandTest { @Test fun `Should return properly message when success`() { // when - DeleteOldTagCommand().main(arrayOf("--git-tag=success", "--username=1", "--token=1")) + DeleteOldTagCommand.main(arrayOf("--git-tag=success", "--username=1", "--token=1")) // then assertThat(systemOutRule.log).contains("Tag success was deleted") @@ -26,7 +26,7 @@ class DeleteOldTagCommandTest { @Test fun `Should return with exit code 1 when failure`() { // when - DeleteOldTagCommand().main(arrayOf("--git-tag=failure", "--username=1", "--token=1")) + DeleteOldTagCommand.main(arrayOf("--git-tag=failure", "--username=1", "--token=1")) // then assertThat(systemOutRule.log).contains("Error while doing GitHub request") diff --git a/flank-scripts/src/test/kotlin/flank/scripts/release/hub/ReleaseFlankCommandTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/cli/release/ReleaseFlankCommandTest.kt similarity index 66% rename from flank-scripts/src/test/kotlin/flank/scripts/release/hub/ReleaseFlankCommandTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/cli/release/ReleaseFlankCommandTest.kt index ac5d5cf84c..1e45107a6d 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/release/hub/ReleaseFlankCommandTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/cli/release/ReleaseFlankCommandTest.kt @@ -1,5 +1,6 @@ -package flank.scripts.release.hub +package flank.scripts.cli.release +import flank.scripts.ops.release.hub.releaseFlank import io.mockk.every import io.mockk.mockkStatic import org.junit.Rule @@ -18,7 +19,7 @@ class ReleaseFlankCommandTest { systemExit.expectSystemExitWithStatus(1) // when - ReleaseFlankCommand().main(listOf("--input-file=./", "--git-tag=T", "--snapshot")) + ReleaseFlankCommand.main(listOf("--input-file=./", "--git-tag=T", "--snapshot")) } @Test @@ -27,32 +28,32 @@ class ReleaseFlankCommandTest { systemExit.expectSystemExitWithStatus(1) // when - ReleaseFlankCommand().main(listOf("--input-file=./", "--git-tag=T")) + ReleaseFlankCommand.main(listOf("--input-file=./", "--git-tag=T")) } @Test fun `Should return successfully run release for snasphot`() { // given - mockkStatic("flank.scripts.release.hub.ReleaseFlankKt") + mockkStatic("flank.scripts.ops.release.hub.ReleaseFlankKt") every { releaseFlank(any(), any(), any(), any(), any()) } returns 0 // expect systemExit.expectSystemExitWithStatus(0) // when - ReleaseFlankCommand().main(listOf("--input-file=./", "--git-tag=T", "--commit-hash=X", "--snapshot")) + ReleaseFlankCommand.main(listOf("--input-file=./", "--git-tag=T", "--commit-hash=X", "--snapshot")) } @Test fun `Should return successfully run release for stable`() { // given - mockkStatic("flank.scripts.release.hub.ReleaseFlankKt") + mockkStatic("flank.scripts.ops.release.hub.ReleaseFlankKt") every { releaseFlank(any(), any(), any(), any(), any()) } returns 0 // expect systemExit.expectSystemExitWithStatus(0) // when - ReleaseFlankCommand().main(listOf("--input-file=./", "--git-tag=T", "--token=X")) + ReleaseFlankCommand.main(listOf("--input-file=./", "--git-tag=T", "--token=X")) } } diff --git a/flank-scripts/src/test/kotlin/flank/scripts/release/jfrog/sync/SyncMavenCommandTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/cli/release/SyncMavenCommandTest.kt similarity index 76% rename from flank-scripts/src/test/kotlin/flank/scripts/release/jfrog/sync/SyncMavenCommandTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/cli/release/SyncMavenCommandTest.kt index 9000044699..b5c24e946d 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/release/jfrog/sync/SyncMavenCommandTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/cli/release/SyncMavenCommandTest.kt @@ -1,5 +1,6 @@ -package flank.scripts.release.jfrog.sync +package flank.scripts.cli.release +import flank.scripts.ops.release.jfrog.jFrogSync import io.mockk.every import io.mockk.mockkStatic import io.mockk.verify @@ -16,14 +17,14 @@ class SyncMavenCommandTest { @Test fun `Should return same exit code as command`() { // given - mockkStatic("flank.scripts.release.jfrog.sync.SyncMavenKt") + mockkStatic(::jFrogSync) every { jFrogSync(any()) } returns 1 // expect systemExit.expectSystemExitWithStatus(1) // when - SyncMavenCommand().main(listOf("--git-tag=TAG")) + SyncMavenCommand.main(listOf("--git-tag=TAG")) // then verify { jFrogSync("TAG") } diff --git a/flank-scripts/src/test/kotlin/flank/scripts/github/GithubApiTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/data/github/GithubApiTest.kt similarity index 92% rename from flank-scripts/src/test/kotlin/flank/scripts/github/GithubApiTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/data/github/GithubApiTest.kt index 42ccdb15da..505d8b8e37 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/github/GithubApiTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/data/github/GithubApiTest.kt @@ -1,19 +1,19 @@ -package flank.scripts.github +package flank.scripts.data.github import com.github.kittinunf.result.Result import com.google.common.truth.Truth.assertThat import flank.scripts.FuelTestRunner -import flank.scripts.ci.releasenotes.GitHubRelease -import flank.scripts.exceptions.GitHubException -import flank.scripts.github.objects.GitHubCommit -import flank.scripts.github.objects.GitHubCreateIssueCommentRequest -import flank.scripts.github.objects.GitHubCreateIssueCommentResponse -import flank.scripts.github.objects.GitHubCreateIssueRequest -import flank.scripts.github.objects.GitHubCreateIssueResponse -import flank.scripts.github.objects.GitHubUpdateIssueRequest -import flank.scripts.github.objects.GitHubWorkflowRunsSummary -import flank.scripts.github.objects.GithubPullRequest -import flank.scripts.github.objects.IssueState +import flank.scripts.data.github.objects.GitHubCommit +import flank.scripts.data.github.objects.GitHubCreateIssueCommentRequest +import flank.scripts.data.github.objects.GitHubCreateIssueCommentResponse +import flank.scripts.data.github.objects.GitHubCreateIssueRequest +import flank.scripts.data.github.objects.GitHubCreateIssueResponse +import flank.scripts.data.github.objects.GitHubRelease +import flank.scripts.data.github.objects.GitHubUpdateIssueRequest +import flank.scripts.data.github.objects.GitHubWorkflowRunsSummary +import flank.scripts.data.github.objects.GithubPullRequest +import flank.scripts.data.github.objects.IssueState +import flank.scripts.utils.exceptions.GitHubException import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith diff --git a/flank-scripts/src/test/kotlin/flank/scripts/zenhub/ZenHubCopyEstimationsTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/data/zenhub/ZenHubCopyEstimationsTest.kt similarity index 97% rename from flank-scripts/src/test/kotlin/flank/scripts/zenhub/ZenHubCopyEstimationsTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/data/zenhub/ZenHubCopyEstimationsTest.kt index 98a8a66b6c..e08eddbf48 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/zenhub/ZenHubCopyEstimationsTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/data/zenhub/ZenHubCopyEstimationsTest.kt @@ -1,4 +1,4 @@ -package flank.scripts.zenhub +package flank.scripts.data.zenhub import flank.scripts.FuelTestRunner import flank.scripts.testZenHubIssue diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/UpdateDependenciesTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/UpdateDependenciesTest.kt deleted file mode 100644 index ae23a173ae..0000000000 --- a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/UpdateDependenciesTest.kt +++ /dev/null @@ -1,36 +0,0 @@ -package flank.scripts.dependencies.update - -import org.junit.Assert.assertEquals -import org.junit.Test -import skipIfWindows -import java.io.File - -class UpdateDependenciesTest { - private val testReport = File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/report.json") - private val testDependencies = - File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/TestDependencies") - private val testVersions = File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/TestVersions") - - @Test - fun `should update dependencies`() { - // assume - skipIfWindows() - - // given - val copyOfTestVersions = - testVersions.copyTo( - File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/VersionsAfterUpdateDependencies") - ) - val expectedVersions = - File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/ExpectedVersionAfterUpdateDependencies") - - // when - testReport.updateDependencies(testDependencies, copyOfTestVersions) - - // then - assertEquals(copyOfTestVersions.readText(), expectedVersions.readText()) - - // clean up - copyOfTestVersions.delete() - } -} diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/UpdatePluginsTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/UpdatePluginsTest.kt deleted file mode 100644 index e652624fc1..0000000000 --- a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/UpdatePluginsTest.kt +++ /dev/null @@ -1,47 +0,0 @@ -package flank.scripts.dependencies.update - -import org.junit.Assert.assertEquals -import org.junit.Test -import skipIfWindows -import java.io.File - -class UpdatePluginsTest { - private val testReport = File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/report.json") - private val testPlugins = File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/TestPlugins") - private val testVersions = File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/TestVersions") - - @Test - fun `should update plugin versions`() { - // assume - skipIfWindows() - - // given - val expectedVersions = - File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/ExpectedVersionAfterPluginDependencies") - val copyOfTestVersions = - testVersions.copyTo( - File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/VersionsAfterPluginDependencies") - ) - prepareBuildGradleForTest() - - // when - testReport.updatePlugins(testPlugins, copyOfTestVersions, "src/test/kotlin/flank/scripts/dependencies/update/testfiles") - - // then - assertEquals(expectedVersions.readText(), copyOfTestVersions.readText()) - - // then - makeBuildGradleNotPrepared() - copyOfTestVersions.delete() - } - - private fun prepareBuildGradleForTest() { - File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/build.gradle.kts.test") - .renameTo(File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/build.gradle.kts")) - } - - private fun makeBuildGradleNotPrepared() { - File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/build.gradle.kts") - .renameTo(File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/build.gradle.kts.test")) - } -} diff --git a/flank-scripts/src/test/kotlin/flank/scripts/ci/nexttag/NextReleaseTagGeneratorTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/ci/NextReleaseTagGeneratorTest.kt similarity index 98% rename from flank-scripts/src/test/kotlin/flank/scripts/ci/nexttag/NextReleaseTagGeneratorTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/ci/NextReleaseTagGeneratorTest.kt index 6318754229..7a97b7cbbe 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/ci/nexttag/NextReleaseTagGeneratorTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/ci/NextReleaseTagGeneratorTest.kt @@ -1,4 +1,4 @@ -package flank.scripts.ci.nexttag +package flank.scripts.ops.ci import com.google.common.truth.Truth.assertThat import io.mockk.every diff --git a/flank-scripts/src/test/kotlin/flank/scripts/ci/releasenotes/AppendReleaseNotesTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/ci/releasenotes/AppendReleaseNotesTest.kt similarity index 98% rename from flank-scripts/src/test/kotlin/flank/scripts/ci/releasenotes/AppendReleaseNotesTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/ci/releasenotes/AppendReleaseNotesTest.kt index 21815cfc91..0cfe36b84f 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/ci/releasenotes/AppendReleaseNotesTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/ci/releasenotes/AppendReleaseNotesTest.kt @@ -1,4 +1,4 @@ -package flank.scripts.ci.releasenotes +package flank.scripts.ops.ci.releasenotes import com.google.common.truth.Truth.assertThat import flank.scripts.utils.markdownH2 diff --git a/flank-scripts/src/test/kotlin/flank/scripts/ci/releasenotes/ConventionalCommitFormatterTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/ci/releasenotes/ConventionalCommitFormatterTest.kt similarity index 97% rename from flank-scripts/src/test/kotlin/flank/scripts/ci/releasenotes/ConventionalCommitFormatterTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/ci/releasenotes/ConventionalCommitFormatterTest.kt index 4772d51b4f..5b2d47efb9 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/ci/releasenotes/ConventionalCommitFormatterTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/ci/releasenotes/ConventionalCommitFormatterTest.kt @@ -1,4 +1,4 @@ -package flank.scripts.ci.releasenotes +package flank.scripts.ops.ci.releasenotes import com.google.common.truth.Truth.assertThat import org.junit.Test diff --git a/flank-scripts/src/test/kotlin/flank/scripts/ci/releasenotes/ReleaseNotesWithTypeTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/ci/releasenotes/ReleaseNotesWithTypeTest.kt similarity index 98% rename from flank-scripts/src/test/kotlin/flank/scripts/ci/releasenotes/ReleaseNotesWithTypeTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/ci/releasenotes/ReleaseNotesWithTypeTest.kt index 32852d5a4a..e610d8b917 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/ci/releasenotes/ReleaseNotesWithTypeTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/ci/releasenotes/ReleaseNotesWithTypeTest.kt @@ -1,4 +1,4 @@ -package flank.scripts.ci.releasenotes +package flank.scripts.ops.ci.releasenotes import org.junit.Assert.assertEquals import org.junit.Test diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/DependencyExtensionsTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/DependencyExtensionsTest.kt similarity index 98% rename from flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/DependencyExtensionsTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/DependencyExtensionsTest.kt index d0bb4149de..88de3020e2 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/DependencyExtensionsTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/DependencyExtensionsTest.kt @@ -1,4 +1,4 @@ -package flank.scripts.dependencies.update +package flank.scripts.ops.dependencies import flank.scripts.utils.toAvailableVersion import flank.scripts.utils.toDependency diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/FindVersionInLinesTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/FindVersionInLinesTest.kt similarity index 97% rename from flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/FindVersionInLinesTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/FindVersionInLinesTest.kt index 0ccecce461..c841fe5db2 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/FindVersionInLinesTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/FindVersionInLinesTest.kt @@ -1,4 +1,4 @@ -package flank.scripts.dependencies.update +package flank.scripts.ops.dependencies import org.junit.Assert.assertEquals import org.junit.Test diff --git a/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/UpdateDependenciesTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/UpdateDependenciesTest.kt new file mode 100644 index 0000000000..9345145bf9 --- /dev/null +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/UpdateDependenciesTest.kt @@ -0,0 +1,38 @@ +package flank.scripts.ops.dependencies + +import flank.common.isWindows +import flank.scripts.ops.dependencies.testfiles.testFilesPath +import org.junit.Assert.assertEquals +import org.junit.Assume.assumeFalse +import org.junit.Test +import java.io.File + +class UpdateDependenciesTest { + private val testReport = File("${testFilesPath}report.json") + private val testDependencies = + File("${testFilesPath}TestDependencies") + private val testVersions = File("${testFilesPath}TestVersions") + + @Test + fun `should update dependencies`() { + // assume + assumeFalse(isWindows) + + // given + val copyOfTestVersions = + testVersions.copyTo( + File("${testFilesPath}VersionsAfterUpdateDependencies") + ) + val expectedVersions = + File("${testFilesPath}ExpectedVersionAfterUpdateDependencies") + + // when + testReport.updateDependencies(testDependencies, copyOfTestVersions) + + // then + assertEquals(copyOfTestVersions.readText(), expectedVersions.readText()) + + // clean up + copyOfTestVersions.delete() + } +} diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/UpdateGradleTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/UpdateGradleTest.kt similarity index 92% rename from flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/UpdateGradleTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/UpdateGradleTest.kt index 7aa15dbd52..b34748f49e 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/UpdateGradleTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/UpdateGradleTest.kt @@ -1,5 +1,6 @@ -package flank.scripts.dependencies.update +package flank.scripts.ops.dependencies +import flank.scripts.ops.dependencies.testfiles.testFilesPath import org.junit.Assert.assertEquals import org.junit.Rule import org.junit.Test @@ -13,9 +14,9 @@ class UpdateGradleTest(private val settings: List) { @get:Rule val tempFolder = TemporaryFolder() - private val testReport = File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/report.json") + private val testReport = File("${testFilesPath}report.json") private val testGradleVersionFile = - File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/test_gradle-wrapper.properties.test") + File("${testFilesPath}test_gradle-wrapper.properties.test") companion object { @JvmStatic diff --git a/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/UpdatePluginsTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/UpdatePluginsTest.kt new file mode 100644 index 0000000000..036dd7d07a --- /dev/null +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/UpdatePluginsTest.kt @@ -0,0 +1,51 @@ +package flank.scripts.ops.dependencies + +import flank.common.isWindows +import flank.scripts.ops.dependencies.testfiles.testFilesPath +import org.junit.Assert.assertEquals +import org.junit.Assume.assumeFalse +import org.junit.Test +import java.io.File + +class UpdatePluginsTest { + private val testReport = File("${testFilesPath}report.json") + private val testPlugins = File("${testFilesPath}TestPlugins") + private val testVersions = File("${testFilesPath}TestVersions") + + @Test + fun `should update plugin versions`() { + // assume + assumeFalse(isWindows) + + // given + val expectedVersions = + File("${testFilesPath}ExpectedVersionAfterPluginDependencies") + val copyOfTestVersions = + testVersions.copyTo( + File("${testFilesPath}VersionsAfterPluginDependencies") + ) + prepareBuildGradleForTest() + + // when + testReport.updatePlugins(testPlugins, copyOfTestVersions, testFilesPath) + + // then + assertEquals(expectedVersions.readText(), copyOfTestVersions.readText()) + + // then + makeBuildGradleNotPrepared() + + // clean + copyOfTestVersions.delete() + } + + private fun prepareBuildGradleForTest() { + File("${testFilesPath}build.gradle.kts.test") + .renameTo(File("${testFilesPath}build.gradle.kts")) + } + + private fun makeBuildGradleNotPrepared() { + File("${testFilesPath}build.gradle.kts") + .renameTo(File("${testFilesPath}build.gradle.kts.test")) + } +} diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/UpdateVersionsInFileTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/UpdateVersionsInFileTest.kt similarity index 75% rename from flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/UpdateVersionsInFileTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/UpdateVersionsInFileTest.kt index 3b13c91293..2bae746e84 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/UpdateVersionsInFileTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/UpdateVersionsInFileTest.kt @@ -1,24 +1,26 @@ -package flank.scripts.dependencies.update +package flank.scripts.ops.dependencies +import flank.common.isWindows +import flank.scripts.ops.dependencies.testfiles.testFilesPath import flank.scripts.utils.toDependencyUpdate import org.junit.Assert.assertEquals +import org.junit.Assume.assumeFalse import org.junit.Test -import skipIfWindows import java.io.File class UpdateVersionsInFileTest { - private val testVersions = File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/TestVersions") + private val testVersions = File("${testFilesPath}TestVersions") @Test fun `should properly update versions file`() { // assume - skipIfWindows() + assumeFalse(isWindows) // given val copyOfTestVersions = testVersions.copyTo(File(testVersions.absolutePath + "After")) val expectedFileAfterChanged = - File("src/test/kotlin/flank/scripts/dependencies/update/testfiles/ExpectedTestVersionsAfterUpdateVersion") + File("${testFilesPath}ExpectedTestVersionsAfterUpdateVersion") val dependenciesToUpdate = listOf( toDependencyUpdate("DD_PLIST", "DD_PLIST", "1.23", "3.21"), toDependencyUpdate("DETEKT", "DETEKT", "1.11.0", "0.11.1"), diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/ExpectedTestVersionsAfterUpdateVersion b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/ExpectedTestVersionsAfterUpdateVersion similarity index 100% rename from flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/ExpectedTestVersionsAfterUpdateVersion rename to flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/ExpectedTestVersionsAfterUpdateVersion diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/ExpectedVersionAfterPluginDependencies b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/ExpectedVersionAfterPluginDependencies similarity index 100% rename from flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/ExpectedVersionAfterPluginDependencies rename to flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/ExpectedVersionAfterPluginDependencies diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/ExpectedVersionAfterUpdateDependencies b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/ExpectedVersionAfterUpdateDependencies similarity index 100% rename from flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/ExpectedVersionAfterUpdateDependencies rename to flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/ExpectedVersionAfterUpdateDependencies diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/PrepareFileForTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/PrepareFileForTest.kt similarity index 80% rename from flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/PrepareFileForTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/PrepareFileForTest.kt index 86cb687b77..63ccea864b 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/PrepareFileForTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/PrepareFileForTest.kt @@ -1,4 +1,4 @@ -package flank.scripts.dependencies.update.testfiles +package flank.scripts.ops.dependencies.testfiles import java.io.File diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/TestDependencies b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/TestDependencies similarity index 100% rename from flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/TestDependencies rename to flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/TestDependencies diff --git a/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/TestFilesPath.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/TestFilesPath.kt new file mode 100644 index 0000000000..2c9712c14d --- /dev/null +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/TestFilesPath.kt @@ -0,0 +1,3 @@ +package flank.scripts.ops.dependencies.testfiles + +internal val testFilesPath = "src/test/kotlin/flank/scripts/ops/dependencies/testfiles/" diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/TestPlugins b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/TestPlugins similarity index 100% rename from flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/TestPlugins rename to flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/TestPlugins diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/TestVersions b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/TestVersions similarity index 100% rename from flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/TestVersions rename to flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/TestVersions diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/actual_gradle-wrapper.properties b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/actual_gradle-wrapper.properties similarity index 100% rename from flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/actual_gradle-wrapper.properties rename to flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/actual_gradle-wrapper.properties diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/build.gradle.kts.test b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/build.gradle.kts.test similarity index 100% rename from flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/build.gradle.kts.test rename to flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/build.gradle.kts.test diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/expected_gradle-wrapper.properties.test b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/expected_gradle-wrapper.properties.test similarity index 100% rename from flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/expected_gradle-wrapper.properties.test rename to flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/expected_gradle-wrapper.properties.test diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/report.json b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/report.json similarity index 100% rename from flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/report.json rename to flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/report.json diff --git a/flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/test_gradle-wrapper.properties.test b/flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/test_gradle-wrapper.properties.test similarity index 100% rename from flank-scripts/src/test/kotlin/flank/scripts/dependencies/update/testfiles/test_gradle-wrapper.properties.test rename to flank-scripts/src/test/kotlin/flank/scripts/ops/dependencies/testfiles/test_gradle-wrapper.properties.test diff --git a/flank-scripts/src/test/kotlin/flank/scripts/integration/ProcessResultTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/integration/ProcessResultTest.kt similarity index 97% rename from flank-scripts/src/test/kotlin/flank/scripts/integration/ProcessResultTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/integration/ProcessResultTest.kt index 3d5c3aecca..097257cddd 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/integration/ProcessResultTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/integration/ProcessResultTest.kt @@ -1,8 +1,9 @@ -package flank.scripts.integration +package flank.scripts.ops.integration import com.google.common.truth.Truth.assertThat import flank.common.normalizeLineEnding import flank.scripts.FuelTestRunner +import flank.scripts.cli.integration.ProcessResultCommand import kotlinx.coroutines.runBlocking import org.junit.Rule import org.junit.Test diff --git a/flank-scripts/src/test/kotlin/flank/scripts/pullrequest/FindReferenceIssueTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/pullrequest/FindReferenceIssueTest.kt similarity index 94% rename from flank-scripts/src/test/kotlin/flank/scripts/pullrequest/FindReferenceIssueTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/pullrequest/FindReferenceIssueTest.kt index 752bf38563..8d4fa013f4 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/pullrequest/FindReferenceIssueTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/pullrequest/FindReferenceIssueTest.kt @@ -1,7 +1,7 @@ -package flank.scripts.pullrequest +package flank.scripts.ops.pullrequest import com.google.common.truth.Truth.assertThat -import flank.scripts.github.objects.GithubPullRequest +import flank.scripts.data.github.objects.GithubPullRequest import io.mockk.every import io.mockk.mockk import org.junit.Test diff --git a/flank-scripts/src/test/kotlin/flank/scripts/pullrequest/SetAssigneesTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/pullrequest/SetAssigneesTest.kt similarity index 96% rename from flank-scripts/src/test/kotlin/flank/scripts/pullrequest/SetAssigneesTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/pullrequest/SetAssigneesTest.kt index 5e33834ea8..7a30f7c708 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/pullrequest/SetAssigneesTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/pullrequest/SetAssigneesTest.kt @@ -1,4 +1,4 @@ -package flank.scripts.pullrequest +package flank.scripts.ops.pullrequest import flank.scripts.FuelTestRunner import flank.scripts.testAssignees diff --git a/flank-scripts/src/test/kotlin/flank/scripts/pullrequest/SetLabelsTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/pullrequest/SetLabelsTest.kt similarity index 96% rename from flank-scripts/src/test/kotlin/flank/scripts/pullrequest/SetLabelsTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/pullrequest/SetLabelsTest.kt index 6805d11dcd..10bcfcfd2d 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/pullrequest/SetLabelsTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/pullrequest/SetLabelsTest.kt @@ -1,4 +1,4 @@ -package flank.scripts.pullrequest +package flank.scripts.ops.pullrequest import flank.scripts.FuelTestRunner import flank.scripts.testGithubLabels diff --git a/flank-scripts/src/test/kotlin/flank/scripts/shell/firebase/sdk/SDKUpdateTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/shell/firebase/sdk/SDKUpdateTest.kt similarity index 96% rename from flank-scripts/src/test/kotlin/flank/scripts/shell/firebase/sdk/SDKUpdateTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/shell/firebase/sdk/SDKUpdateTest.kt index 54411d104b..28fce66dc4 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/shell/firebase/sdk/SDKUpdateTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/shell/firebase/sdk/SDKUpdateTest.kt @@ -1,9 +1,9 @@ -package flank.scripts.shell.firebase.sdk +package flank.scripts.ops.shell.firebase.sdk import com.google.common.truth.Truth.assertThat import flank.common.normalizeLineEnding import flank.scripts.FuelTestRunner -import flank.scripts.github.objects.GithubPullRequest +import flank.scripts.data.github.objects.GithubPullRequest import flank.scripts.utils.parseToVersion import kotlinx.coroutines.runBlocking import org.junit.Rule diff --git a/flank-scripts/src/test/kotlin/flank/scripts/testartifacts/core/ArtifactsArchiveTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/testartifacts/ArtifactsArchiveTest.kt similarity index 86% rename from flank-scripts/src/test/kotlin/flank/scripts/testartifacts/core/ArtifactsArchiveTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/testartifacts/ArtifactsArchiveTest.kt index 7690dbacfa..56d283b6c4 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/testartifacts/core/ArtifactsArchiveTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/testartifacts/ArtifactsArchiveTest.kt @@ -1,7 +1,5 @@ -package flank.scripts.testartifacts.core +package flank.scripts.ops.testartifacts -import flank.scripts.testartifacts.TEST_BRANCH_1 -import flank.scripts.testartifacts.testContext import org.junit.After import org.junit.Assert.assertEquals import org.junit.Before diff --git a/flank-scripts/src/test/kotlin/flank/scripts/testartifacts/core/PrepareTestArtifactsKtTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/testartifacts/PrepareTestArtifactsKtTest.kt similarity index 74% rename from flank-scripts/src/test/kotlin/flank/scripts/testartifacts/core/PrepareTestArtifactsKtTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/testartifacts/PrepareTestArtifactsKtTest.kt index 0e716f0b55..00553db42d 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/testartifacts/core/PrepareTestArtifactsKtTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/testartifacts/PrepareTestArtifactsKtTest.kt @@ -1,10 +1,5 @@ -package flank.scripts.testartifacts.core +package flank.scripts.ops.testartifacts -import flank.scripts.testartifacts.TEST_BRANCH_1 -import flank.scripts.testartifacts.TEST_BRANCH_2 -import flank.scripts.testartifacts.prepareTestDirectory -import flank.scripts.testartifacts.removeTestDirectory -import flank.scripts.testartifacts.testContext import org.junit.After import org.junit.Assert.assertEquals import org.junit.Before diff --git a/flank-scripts/src/test/kotlin/flank/scripts/testartifacts/TestArtifactsUtils.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/testartifacts/TestArtifactsUtils.kt similarity index 84% rename from flank-scripts/src/test/kotlin/flank/scripts/testartifacts/TestArtifactsUtils.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/testartifacts/TestArtifactsUtils.kt index 754aa5daa2..6a5ebeb9ea 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/testartifacts/TestArtifactsUtils.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/testartifacts/TestArtifactsUtils.kt @@ -1,7 +1,4 @@ -package flank.scripts.testartifacts - -import flank.scripts.testartifacts.core.Context -import flank.scripts.testartifacts.core.testArtifacts +package flank.scripts.ops.testartifacts const val TEST_BRANCH_1 = "1-unit-test-artifacts-management" const val TEST_BRANCH_2 = "2-unit-test-artifacts-management" diff --git a/flank-scripts/src/test/kotlin/flank/scripts/testartifacts/core/ZipTestArtifactsKt.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/testartifacts/ZipTestArtifactsKt.kt similarity index 77% rename from flank-scripts/src/test/kotlin/flank/scripts/testartifacts/core/ZipTestArtifactsKt.kt rename to flank-scripts/src/test/kotlin/flank/scripts/ops/testartifacts/ZipTestArtifactsKt.kt index 9844592300..05c19456a5 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/testartifacts/core/ZipTestArtifactsKt.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/testartifacts/ZipTestArtifactsKt.kt @@ -1,11 +1,5 @@ -package flank.scripts.testartifacts.core - -import flank.scripts.testartifacts.TEST_FILE_BODY -import flank.scripts.testartifacts.TEST_FILE_NAME -import flank.scripts.testartifacts.prepareTestDirectory -import flank.scripts.testartifacts.removeTestArchive -import flank.scripts.testartifacts.removeTestDirectory -import flank.scripts.testartifacts.testContext +package flank.scripts.ops.testartifacts + import org.junit.After import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull diff --git a/flank-scripts/src/test/kotlin/flank/scripts/utils/SerializationTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/utils/SerializationTest.kt index 16c1ffdc03..bf202259e2 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/utils/SerializationTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/utils/SerializationTest.kt @@ -1,7 +1,7 @@ package flank.scripts.utils import com.google.common.truth.Truth.assertThat -import flank.scripts.github.GitHubErrorResponse +import flank.scripts.data.github.GitHubErrorResponse import org.junit.Test class SerializationTest { diff --git a/flank-scripts/src/test/kotlin/flank/scripts/utils/TestParsers.kt b/flank-scripts/src/test/kotlin/flank/scripts/utils/TestParsers.kt index 87d54447a2..2404af0d18 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/utils/TestParsers.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/utils/TestParsers.kt @@ -1,9 +1,9 @@ package flank.scripts.utils -import flank.scripts.dependencies.update.AvailableVersion -import flank.scripts.dependencies.update.Dependency -import flank.scripts.dependencies.update.DependencyUpdate -import flank.scripts.dependencies.update.GradleReleaseChannel +import flank.scripts.ops.dependencies.AvailableVersion +import flank.scripts.ops.dependencies.Dependency +import flank.scripts.ops.dependencies.DependencyUpdate +import flank.scripts.ops.dependencies.GradleReleaseChannel fun toGradleReleaseChannel( version: String, diff --git a/flank-scripts/src/test/kotlin/flank/scripts/exceptions/FlankScriptsExceptionMappersTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/utils/exceptions/FlankScriptsExceptionMappersTest.kt similarity index 98% rename from flank-scripts/src/test/kotlin/flank/scripts/exceptions/FlankScriptsExceptionMappersTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/utils/exceptions/FlankScriptsExceptionMappersTest.kt index 033e0963b9..e2b2e4b8c7 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/exceptions/FlankScriptsExceptionMappersTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/utils/exceptions/FlankScriptsExceptionMappersTest.kt @@ -1,4 +1,4 @@ -package flank.scripts.exceptions +package flank.scripts.utils.exceptions import com.github.kittinunf.fuel.core.FuelError import com.github.kittinunf.result.Result diff --git a/flank-scripts/src/test/kotlin/flank/scripts/exceptions/FlankScriptsExceptionsTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/utils/exceptions/FlankScriptsExceptionsTest.kt similarity index 85% rename from flank-scripts/src/test/kotlin/flank/scripts/exceptions/FlankScriptsExceptionsTest.kt rename to flank-scripts/src/test/kotlin/flank/scripts/utils/exceptions/FlankScriptsExceptionsTest.kt index 23fa05249c..92f5a88a34 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/exceptions/FlankScriptsExceptionsTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/utils/exceptions/FlankScriptsExceptionsTest.kt @@ -1,7 +1,7 @@ -package flank.scripts.exceptions +package flank.scripts.utils.exceptions import com.google.common.truth.Truth.assertThat -import flank.scripts.github.GitHubErrorResponse +import flank.scripts.data.github.GitHubErrorResponse import org.junit.Test class FlankScriptsExceptionsTest {