From e69f31098866de9162b318689108a83d2e32d9d5 Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Mon, 4 Jan 2021 16:10:42 +0100 Subject: [PATCH 01/19] Implement properties support --- flank-scripts/.gitignore | 1 + flank-scripts/README.md | 18 +++++- flank-scripts/build.gradle.kts | 1 + flank-scripts/src/flank-scripts.properties | 11 ++++ .../scripts/config/FlankScriptsConfigs.kt | 54 ++++++++++++++++++ .../kotlin/flank/scripts/github/GithubApi.kt | 35 +++++++++++- .../github/commons/LastWorkflowRunDate.kt | 10 ++++ .../objects/GitHubSetAssigneesRequest.kt | 8 +++ .../github/objects/GitHubSetLabelsRequest.kt | 8 +++ .../flank/scripts/integration/IssueList.kt | 3 +- .../scripts/integration/PrepareMessage.kt | 5 +- .../scripts/integration/WorkflowSummary.kt | 3 +- .../flank/scripts/pullrequest/SetAssignees.kt | 24 +------- .../flank/scripts/pullrequest/SetLabels.kt | 31 +---------- .../release/updatebugsnag/UpdateBugSnag.kt | 3 +- .../apiclient/UpdateApiJsonCommand.kt | 5 +- .../firebase/sdk/CheckForSDKUpdateCommand.kt | 55 ++++++++++--------- .../scripts/shell/firebase/sdk/CommitList.kt | 3 +- .../scripts/shell/firebase/sdk/Extensions.kt | 4 +- .../shell/firebase/sdk/LastSDKUpdateRun.kt | 3 +- .../shell/firebase/sdk/OpenedUpdates.kt | 3 +- .../flank/scripts/shell/utils/PathHelper.kt | 2 + .../scripts/testartifacts/core/Constants.kt | 2 - .../testartifacts/core/TestArtifactsRepo.kt | 3 +- .../kotlin/flank/scripts/zenhub/ZenHubAPI.kt | 4 +- .../zenhub/objects/ConvertToEpicRequest.kt | 2 +- 26 files changed, 202 insertions(+), 99 deletions(-) create mode 100644 flank-scripts/src/flank-scripts.properties create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubSetAssigneesRequest.kt create mode 100644 flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubSetLabelsRequest.kt diff --git a/flank-scripts/.gitignore b/flank-scripts/.gitignore index f7c742d13e..e50c778fa2 100644 --- a/flank-scripts/.gitignore +++ b/flank-scripts/.gitignore @@ -24,3 +24,4 @@ out/ buildSrc/.gradle/ buildSrc/build local.properties +src/flank-scripts.properties diff --git a/flank-scripts/README.md b/flank-scripts/README.md index 9d1af1766d..eabfaa18c1 100644 --- a/flank-scripts/README.md +++ b/flank-scripts/README.md @@ -305,4 +305,20 @@ Available commands are: Applies a pre-commit hook that runs Ktlint on a commit and fails if there are lint issues. It is set to automatically fix issues if it can. ### `applyKtlintToIdea` -Applies Ktlint styling to the current idea project, so that correct code styling is upheld. \ No newline at end of file +Applies Ktlint styling to the current idea project, so that correct code styling is upheld. + +## Testing +To test your script with different settings use `flank-scripts.properties` file. Uncomment and replace with desired values. +Properties are skipped by git and should not be attached to a commit. Note, `test` task ignores your own properties and will use the default. + +#### List of possible configs +| Key | Description | Default value | +|:----------------|:---------------------|:---:| +|`zenhub.repo-id`|Flank's repo ID in zenhub app. Used to create new epics.|`84221974`| +|`repo.flank`|Flank test runner repo. Essential property for github client.|`Flank/flank`| +|`repo.gcloud_cli`|Flank's fork of gcloud sdk repo.|`Flank/gcloud_cli`| +|`repo.test-artifacts`|Flank's source of artifacts (apks, binaries, etc) used for testing|`Flank/test_artifacts`| +|`integration.workflow-filename`|GH Action integration tests workflow file. Used to fetch list of commits since it's last run.|`full_suite_integration_tests.yml`| +|`integration.issue-poster`|Name of account that creates IT issue|`github-actions[bot]`| +|`sdk-check.workflow-filename`|GH Action dependencies update workflow file. Used to fetch list of commits since it's last run.|`update_dependencies_and_client.yml`| +|`sdk-check.issue-poster`|Name of account that creates dependencies issues/epics|`github-actions[bot]`| diff --git a/flank-scripts/build.gradle.kts b/flank-scripts/build.gradle.kts index 8b53535cc4..75cbc48e56 100644 --- a/flank-scripts/build.gradle.kts +++ b/flank-scripts/build.gradle.kts @@ -99,6 +99,7 @@ publishing { tasks.test { maxHeapSize = "2048m" minHeapSize = "512m" + systemProperty("testScript", "") } repositories { diff --git a/flank-scripts/src/flank-scripts.properties b/flank-scripts/src/flank-scripts.properties new file mode 100644 index 0000000000..d4cde57fd8 --- /dev/null +++ b/flank-scripts/src/flank-scripts.properties @@ -0,0 +1,11 @@ +#zenhub.repo-id=84221974 +# +#repo.flank=Flank/flank +#repo.gcloud_cli=Flank/gcloud_cli +#repo.test-artifacts=Flank/test_artifacts +# +#integration.workflow-filename=full_suite_integration_tests.yml +#integration.issue-poster=github-actions[bot] +# +#sdk-check.workflow-filename=update_dependencies_and_client.yml +#sdk-check.issue-poster=github-actions[bot] diff --git a/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt b/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt new file mode 100644 index 0000000000..68e2b009e0 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt @@ -0,0 +1,54 @@ +package flank.scripts.config + +import flank.scripts.shell.utils.flankScriptsRootPathString +import java.nio.file.Paths +import java.util.Properties + +private const val ZENHUB_REPO_ID = "zenhub.repo-id" +private const val FLANK_REPO = "repo.flank" +private const val GCLOUD_REPO = "repo.gcloud_cli" +private const val ARTIFACTS_REPO = "repo.test-artifacts" +private const val IT_WORKFLOW_FILE = "integration.workflow-filename" +private const val IT_USER = "integration.issue-poster" +private const val SDK_WORKFLOW = "sdk-check.workflow-filename" +private const val SDK_USER = "sdk-check.issue-poster" + +private val defaults = Properties().apply { + setProperty(ZENHUB_REPO_ID, "84221974") + setProperty(FLANK_REPO, "Flank/flank") + setProperty(GCLOUD_REPO, "Flank/gcloud_cli") + setProperty(ARTIFACTS_REPO, "Flank/test_artifacts") + setProperty(IT_WORKFLOW_FILE, "full_suite_integration_tests.yml") + setProperty(IT_USER, "github-actions[bot]") + setProperty(SDK_WORKFLOW, "update_dependencies_and_client.yml") + setProperty(SDK_USER, "github-actions[bot]") +} + +private class SafeProperties(defaults: Properties) : Properties(defaults) { + override fun get(key: Any?) = (key as String).run { + requireNotNull( + if ( + // we want our CI to use defaults always + System.getenv("CI") != null || + // we don't want to use developers' properties during tests + System.getProperty("testScript") != null + ) defaults.getProperty(key) + else getProperty(key) + ) + } +} + +private val props = SafeProperties(defaults).also { prop -> + with(Paths.get("$flankScriptsRootPathString/src/flank-scripts.properties").toFile()) { + if (exists()) prop.load(inputStream()) + } +} + +val zenhubFlankRepoID = props[ZENHUB_REPO_ID] +val flankRepo = props[FLANK_REPO] +val flankGcloudCLIRepo = props[GCLOUD_REPO] +val flankTestArtifactsRepo = props[ARTIFACTS_REPO] +val integrationOpenedIssueUser = props[IT_USER] +val updatesOpenedUser = props[SDK_USER] +val fullSuiteWorkflowFilename = props[IT_WORKFLOW_FILE] +val updateDependenciesWorkflowFilename = props[SDK_WORKFLOW] diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt b/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt index 958cde340a..cfd6eae2f9 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt @@ -5,8 +5,10 @@ import com.github.kittinunf.fuel.core.Parameters import com.github.kittinunf.fuel.core.Request import com.github.kittinunf.fuel.core.extensions.authentication import com.github.kittinunf.fuel.coroutines.awaitResult +import com.github.kittinunf.fuel.coroutines.awaitStringResult import com.github.kittinunf.result.Result import com.github.kittinunf.result.onError +import com.github.kittinunf.result.success import com.jcabi.github.Coordinates import com.jcabi.github.Release import com.jcabi.github.Releases @@ -14,6 +16,7 @@ import com.jcabi.github.Repo import com.jcabi.github.RtGithub import flank.scripts.ci.releasenotes.GitHubRelease import flank.scripts.ci.releasenotes.GithubReleaseDeserializable +import flank.scripts.config.flankRepo import flank.scripts.exceptions.mapClientErrorToGithubException import flank.scripts.github.objects.GitHubCommit import flank.scripts.github.objects.GitHubCommitListDeserializer @@ -23,6 +26,9 @@ 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 @@ -32,7 +38,7 @@ import flank.scripts.github.objects.GithubWorkflowRunsSummaryDeserializer import flank.scripts.utils.toJson import java.lang.Exception -private const val FLANK_REPO = "Flank/flank" +private val FLANK_REPO = flankRepo private const val URL_BASE = "https://api.github.com/repos" // ============= HTTP GITHUB API ============= @@ -93,6 +99,33 @@ suspend fun postNewIssue(githubToken: String, payload: GitHubCreateIssueRequest, .awaitResult(GitHubCreateIssueResponseDeserializer) .mapClientErrorToGithubException() +suspend fun getLabelsFromIssue(githubToken: String, issueNumber: Int, repo: String = FLANK_REPO) = + Fuel.get("$URL_BASE/$repo/issues/$issueNumber/labels") + .appendGitHubHeaders(githubToken) + .awaitResult(GitHubLabelDeserializable) + .mapClientErrorToGithubException() + +suspend fun setLabelsToPullRequest(githubToken: String, pullRequestNumber: Int, labels: List, repo: String = FLANK_REPO) { + Fuel.post("$URL_BASE/$repo/issues/$pullRequestNumber/labels") + .appendGitHubHeaders(githubToken) + .body(GitHubSetLabelsRequest(labels).toJson()) + .awaitStringResult() + .onError { println("Could not set assignees because of ${it.message}") } + .success { println("$labels set to pull request #$pullRequestNumber") } +} + +suspend fun setAssigneesToPullRequest(githubToken: String, pullRequestNumber: Int, assignees: List, repo: String = FLANK_REPO) { + Fuel.post("$URL_BASE/$repo/issues/$pullRequestNumber/assignees") + .appendGitHubHeaders(githubToken) + .body(GitHubSetAssigneesRequest(assignees).toJson()) + .awaitStringResult() + .onError { + println("Could not set assignees because of ${it.message}") + it.printStackTrace() + } + .success { println("$assignees set to pull request #$pullRequestNumber") } +} + fun patchIssue(githubToken: String, issueNumber: Int, payload: GitHubUpdateIssueRequest, repo: String = FLANK_REPO): Result = Fuel.patch("$URL_BASE/$repo/issues/$issueNumber") .appendGitHubHeaders(githubToken) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/commons/LastWorkflowRunDate.kt b/flank-scripts/src/main/kotlin/flank/scripts/github/commons/LastWorkflowRunDate.kt index cf1c5d6030..3004d7318c 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/commons/LastWorkflowRunDate.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/github/commons/LastWorkflowRunDate.kt @@ -3,6 +3,7 @@ package flank.scripts.github.commons import com.github.kittinunf.result.getOrNull import flank.scripts.github.getGitHubWorkflowRunsSummary import flank.scripts.github.objects.GitHubWorkflowRun +import kotlinx.coroutines.runBlocking import java.time.Instant import java.time.format.DateTimeFormatter @@ -42,3 +43,12 @@ private fun GitHubWorkflowRun?.logRun() = this?.also { """.trimIndent() ) } + +fun main() { + runBlocking { + getLastWorkflowRunDate( + token = "46b81695ce4a71ca20e7d618d20c75bcc6a5268e", + workflowFileName = "full_suite_integration_tests.yml" + ) + } +} diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubSetAssigneesRequest.kt b/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubSetAssigneesRequest.kt new file mode 100644 index 0000000000..56da1afdf9 --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubSetAssigneesRequest.kt @@ -0,0 +1,8 @@ +package flank.scripts.github.objects + +import kotlinx.serialization.Serializable + +@Serializable +data class GitHubSetAssigneesRequest( + val assignees: List +) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubSetLabelsRequest.kt b/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubSetLabelsRequest.kt new file mode 100644 index 0000000000..bb5300149a --- /dev/null +++ b/flank-scripts/src/main/kotlin/flank/scripts/github/objects/GitHubSetLabelsRequest.kt @@ -0,0 +1,8 @@ +package flank.scripts.github.objects + +import kotlinx.serialization.Serializable + +@Serializable +data class GitHubSetLabelsRequest( + val labels: List +) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/integration/IssueList.kt b/flank-scripts/src/main/kotlin/flank/scripts/integration/IssueList.kt index c3e29a123f..90e1282108 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/integration/IssueList.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/integration/IssueList.kt @@ -2,12 +2,13 @@ package flank.scripts.integration import com.github.kittinunf.result.getOrElse import com.github.kittinunf.result.onError +import flank.scripts.config.integrationOpenedIssueUser import flank.scripts.github.getGitHubIssueList suspend fun checkForOpenedITIssues(token: String): Int? = getGitHubIssueList( githubToken = token, parameters = listOf( - "creator" to "github-actions[bot]", + "creator" to integrationOpenedIssueUser, "state" to "open", "labels" to "IT_Failed" ) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/integration/PrepareMessage.kt b/flank-scripts/src/main/kotlin/flank/scripts/integration/PrepareMessage.kt index 1dc412c26d..a273ecf962 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/integration/PrepareMessage.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/integration/PrepareMessage.kt @@ -1,5 +1,6 @@ package flank.scripts.integration +import flank.scripts.config.flankRepo import flank.scripts.github.objects.GithubPullRequest import java.time.Instant import java.time.LocalDateTime @@ -33,7 +34,7 @@ private val successTemplate = { lastRun: String, runId: String, url: String -> """ |### Full suite IT run :white_check_mark: SUCCEEDED :white_check_mark: |**Timestamp:** ${makeHumanFriendly(lastRun)} - |**Job run:** [$runId](https://github.com/Flank/flank/actions/runs/$runId) + |**Job run:** [$runId](https://github.com/$flankRepo/actions/runs/$runId) |**Build scan URL:** $url |**Closing issue** """.trimMargin() @@ -43,7 +44,7 @@ private val failureTemplate = { lastRun: String, runId: String, url: String -> """ |### Full suite IT run :x: FAILED :x: |**Timestamp:** ${makeHumanFriendly(lastRun)} - |**Job run:** [$runId](https://github.com/Flank/flank/actions/runs/$runId) + |**Job run:** [$runId](https://github.com/$flankRepo/actions/runs/$runId) |**Build scan URL:** $url """.trimMargin() } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/integration/WorkflowSummary.kt b/flank-scripts/src/main/kotlin/flank/scripts/integration/WorkflowSummary.kt index 7b8457366d..fdbe80a379 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/integration/WorkflowSummary.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/integration/WorkflowSummary.kt @@ -1,8 +1,9 @@ package flank.scripts.integration +import flank.scripts.config.fullSuiteWorkflowFilename import flank.scripts.github.commons.getLastWorkflowRunDate suspend fun getLastITWorkflowRunDate(token: String) = getLastWorkflowRunDate( token = token, - workflowFileName = "integration_tests_pointer.yml" + workflowFileName = fullSuiteWorkflowFilename ) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/SetAssignees.kt b/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/SetAssignees.kt index 2d82a6937d..e33531d75d 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/SetAssignees.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/SetAssignees.kt @@ -1,15 +1,10 @@ package flank.scripts.pullrequest -import com.github.kittinunf.fuel.Fuel -import com.github.kittinunf.fuel.coroutines.awaitStringResult import com.github.kittinunf.result.getOrNull import com.github.kittinunf.result.map import com.github.kittinunf.result.onError -import com.github.kittinunf.result.success -import flank.scripts.github.appendGitHubHeaders import flank.scripts.github.getGitHubIssue -import flank.scripts.utils.toJson -import kotlinx.serialization.Serializable +import flank.scripts.github.setAssigneesToPullRequest suspend fun copyAssignees(githubToken: String, baseIssueNumber: Int, pullRequestNumber: Int) { getGitHubIssue(githubToken, baseIssueNumber) @@ -18,20 +13,3 @@ suspend fun copyAssignees(githubToken: String, baseIssueNumber: Int, pullRequest .getOrNull() ?.let { setAssigneesToPullRequest(githubToken, pullRequestNumber, it) } } - -private suspend fun setAssigneesToPullRequest(githubToken: String, pullRequestNumber: Int, assignees: List) { - Fuel.post("https://api.github.com/repos/Flank/flank/issues/$pullRequestNumber/assignees") - .appendGitHubHeaders(githubToken) - .body(SetAssigneesRequest(assignees).toJson()) - .awaitStringResult() - .onError { - println("Could not set assignees because of ${it.message}") - it.printStackTrace() - } - .success { println("$assignees set to pull request #$pullRequestNumber") } -} - -@Serializable -private data class SetAssigneesRequest( - val assignees: List -) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/SetLabels.kt b/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/SetLabels.kt index f1c726548a..8d1f6a301c 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/SetLabels.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/pullrequest/SetLabels.kt @@ -1,17 +1,10 @@ package flank.scripts.pullrequest -import com.github.kittinunf.fuel.Fuel -import com.github.kittinunf.fuel.coroutines.awaitResult -import com.github.kittinunf.fuel.coroutines.awaitStringResult import com.github.kittinunf.result.getOrNull import com.github.kittinunf.result.map import com.github.kittinunf.result.onError -import com.github.kittinunf.result.success -import flank.scripts.exceptions.mapClientErrorToGithubException -import flank.scripts.github.appendGitHubHeaders -import flank.scripts.github.objects.GitHubLabelDeserializable -import flank.scripts.utils.toJson -import kotlinx.serialization.Serializable +import flank.scripts.github.getLabelsFromIssue +import flank.scripts.github.setLabelsToPullRequest suspend fun copyLabels(githubToken: String, issueNumber: Int, pullRequestNumber: Int) { getLabelsFromIssue(githubToken, issueNumber) @@ -20,23 +13,3 @@ suspend fun copyLabels(githubToken: String, issueNumber: Int, pullRequestNumber: .getOrNull() ?.run { setLabelsToPullRequest(githubToken, pullRequestNumber, this) } } - -private suspend fun getLabelsFromIssue(githubToken: String, issueNumber: Int) = - Fuel.get("https://api.github.com/repos/Flank/flank/issues/$issueNumber/labels") - .appendGitHubHeaders(githubToken) - .awaitResult(GitHubLabelDeserializable) - .mapClientErrorToGithubException() - -private suspend fun setLabelsToPullRequest(githubToken: String, pullRequestNumber: Int, labels: List) { - Fuel.post("https://api.github.com/repos/Flank/flank/issues/$pullRequestNumber/labels") - .appendGitHubHeaders(githubToken) - .body(SetLabelsRequest(labels).toJson()) - .awaitStringResult() - .onError { println("Could not set assignees because of ${it.message}") } - .success { println("$labels set to pull request #$pullRequestNumber") } -} - -@Serializable -private data class SetLabelsRequest( - val labels: List -) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/release/updatebugsnag/UpdateBugSnag.kt b/flank-scripts/src/main/kotlin/flank/scripts/release/updatebugsnag/UpdateBugSnag.kt index e3055041d3..e4ef3d532b 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/release/updatebugsnag/UpdateBugSnag.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/release/updatebugsnag/UpdateBugSnag.kt @@ -3,6 +3,7 @@ package flank.scripts.release.updatebugsnag import com.github.kittinunf.fuel.Fuel import com.github.kittinunf.fuel.core.extensions.jsonBody import com.github.kittinunf.fuel.coroutines.awaitResult +import flank.scripts.config.flankRepo import flank.scripts.exceptions.mapClientError import flank.scripts.exceptions.toBugsnagException import flank.scripts.utils.toJson @@ -33,4 +34,4 @@ private fun githubActionsSourceControl(appVersion: String) = SourceControl( ) private const val BUGNSAG_URL = "https://build.bugsnag.com/" -private const val REPOSITORY = "https://github.com/Flank/flank" +private val REPOSITORY = "https://github.com/$flankRepo" 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 index 138fa85004..ecfd14d39a 100644 --- 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 @@ -2,6 +2,7 @@ package flank.scripts.shell.firebase.apiclient import com.github.ajalt.clikt.core.CliktCommand import flank.common.downloadFile +import flank.scripts.config.flankGcloudCLIRepo import flank.scripts.shell.utils.currentPath import flank.scripts.utils.downloadSortJsonIfNeeded import flank.scripts.utils.runCommand @@ -14,12 +15,12 @@ object UpdateApiJsonCommand : CliktCommand(name = "updateApiJson", help = "Downl val testingV1Beta3Path = Paths.get(jsonDirectoryPath.toString(), "toolresults_v1beta3.json").toString() downloadFile( - "https://raw.githubusercontent.com/Flank/gcloud_cli/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/testing_v1.json", + "https://raw.githubusercontent.com/$flankGcloudCLIRepo/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/testing_v1.json", testingV1Path ) downloadFile( - "https://raw.githubusercontent.com/Flank/gcloud_cli/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/toolresults_v1beta3.json", + "https://raw.githubusercontent.com/$flankGcloudCLIRepo/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/toolresults_v1beta3.json", testingV1Beta3Path ) 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 index 0983fed7c5..d62857245d 100644 --- 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 @@ -5,13 +5,13 @@ 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.downloadFile +import flank.scripts.config.flankGcloudCLIRepo import flank.scripts.shell.utils.currentPath import flank.scripts.utils.parseToVersion import kotlinx.coroutines.runBlocking import java.nio.file.Paths -import java.time.Instant -private const val RAW_GITHUB = "https://raw.githubusercontent.com/Flank/gcloud_cli" +private val RAW_GITHUB = "https://raw.githubusercontent.com/$flankGcloudCLIRepo" object CheckForSDKUpdateCommand : CliktCommand( name = "checkForSdkUpdate", @@ -24,31 +24,32 @@ object CheckForSDKUpdateCommand : CliktCommand( 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() - } - } + println(lastRun) +// 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( diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CommitList.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CommitList.kt index bf003e0445..4cdd80639c 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CommitList.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CommitList.kt @@ -1,5 +1,6 @@ package flank.scripts.shell.firebase.sdk +import flank.scripts.config.flankGcloudCLIRepo import flank.scripts.github.getGitHubCommitList import flank.scripts.github.objects.GitHubCommit import java.time.Instant @@ -12,7 +13,7 @@ suspend fun getCommitsUntilLastCheck(token: String, until: String): String? = ge "per_page" to 10, "until" to until ), - repo = "Flank/gcloud_cli" + repo = flankGcloudCLIRepo ) .get() .maxByOrNull { Instant.from(DateTimeFormatter.ISO_INSTANT.parse(it.commit.author.date)) } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/Extensions.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/Extensions.kt index d007781c92..4a020d63d0 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/Extensions.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/Extensions.kt @@ -3,12 +3,12 @@ package flank.scripts.shell.firebase.sdk import com.github.kittinunf.result.Result import com.github.kittinunf.result.onError import flank.common.newLine +import flank.scripts.config.zenhubFlankRepoID 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.FLANK_REPO_ID import flank.scripts.zenhub.convertIssueToEpic import flank.scripts.zenhub.objects.ConvertToEpicRequest import flank.scripts.zenhub.objects.Issue @@ -74,7 +74,7 @@ private suspend fun SDKUpdateContext.createSubIssues() = coroutineScope { } } .awaitAll() - .map { Issue(FLANK_REPO_ID, it.number) } + .map { Issue(zenhubFlankRepoID, it.number) } } } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/LastSDKUpdateRun.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/LastSDKUpdateRun.kt index c7ae5b9653..188aa6283b 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/LastSDKUpdateRun.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/LastSDKUpdateRun.kt @@ -1,8 +1,9 @@ package flank.scripts.shell.firebase.sdk +import flank.scripts.config.updateDependenciesWorkflowFilename import flank.scripts.github.commons.getLastWorkflowRunDate suspend fun getLastSDKUpdateRunDate(token: String) = getLastWorkflowRunDate( token = token, - workflowFileName = "update_dependencies_pointer.yml" + workflowFileName = updateDependenciesWorkflowFilename ) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/OpenedUpdates.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/OpenedUpdates.kt index 72ef8f60ec..ba10601d21 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/OpenedUpdates.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/OpenedUpdates.kt @@ -2,12 +2,13 @@ package flank.scripts.shell.firebase.sdk import com.github.kittinunf.result.getOrElse import com.github.kittinunf.result.onError +import flank.scripts.config.updatesOpenedUser import flank.scripts.github.getGitHubIssueList suspend fun checkForOpenedUpdates(token: String) = getGitHubIssueList( githubToken = token, parameters = listOf( - "creator" to "github-actions[bot]", + "creator" to updatesOpenedUser, "state" to "open", "labels" to "gcloud SDK" ) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt index 067d48796d..0393d343cd 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt @@ -20,3 +20,5 @@ val flankFixturesTmpPath = Paths.get(rootDirectoryPathString, "test_runner", "src", "test", "kotlin", "ftl", "fixtures", "tmp").toString() val flankFixturesIosTmpPath = Paths.get(flankFixturesTmpPath, "ios").toString() + +val flankScriptsRootPathString = Paths.get(rootDirectoryPathString, "flank-scripts").toString() diff --git a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/Constants.kt b/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/Constants.kt index ca05fb88e5..53d1541c2b 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/Constants.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/Constants.kt @@ -4,8 +4,6 @@ import flank.scripts.utils.currentGitBranch import java.io.File const val GITHUB_TOKEN_ENV_KEY = "GITHUB_TOKEN" -const val TEST_ARTIFACTS_REPO = "Flank/test_artifacts" - const val FIXTURES_PATH = "test_runner/src/test/kotlin/ftl/fixtures/tmp" const val TEST_ARTIFACTS_PATH = "test_artifacts" diff --git a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/TestArtifactsRepo.kt b/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/TestArtifactsRepo.kt index 5cbe0d79c4..2f4d1989d2 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/TestArtifactsRepo.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/TestArtifactsRepo.kt @@ -1,7 +1,8 @@ package flank.scripts.testartifacts.core import com.jcabi.github.Repo +import flank.scripts.config.flankTestArtifactsRepo import flank.scripts.github.githubRepo import flank.scripts.utils.getEnv -internal fun testArtifactsRepo(): Repo = githubRepo(getEnv(GITHUB_TOKEN_ENV_KEY), TEST_ARTIFACTS_REPO) +internal fun testArtifactsRepo(): Repo = githubRepo(getEnv(GITHUB_TOKEN_ENV_KEY), flankTestArtifactsRepo) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubAPI.kt b/flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubAPI.kt index ce84aa7088..8691b1271c 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubAPI.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubAPI.kt @@ -7,13 +7,13 @@ import com.github.kittinunf.fuel.coroutines.awaitStringResult import com.github.kittinunf.result.getOrNull import com.github.kittinunf.result.onError import com.github.kittinunf.result.success +import flank.scripts.config.zenhubFlankRepoID import flank.scripts.utils.toJson import flank.scripts.zenhub.objects.ConvertToEpicRequest import flank.scripts.zenhub.objects.UpdateEpicRequest import kotlinx.serialization.Serializable -const val FLANK_REPO_ID = 84221974 -internal const val ZENHUB_BASE_URL = "https://api.zenhub.com/p1/repositories/$FLANK_REPO_ID" +internal val ZENHUB_BASE_URL = "https://api.zenhub.com/p1/repositories/$zenhubFlankRepoID" suspend fun copyEstimation(zenhubToken: String, issueNumber: Int, pullRequestNumber: Int) { getEstimation(zenhubToken, issueNumber) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/zenhub/objects/ConvertToEpicRequest.kt b/flank-scripts/src/main/kotlin/flank/scripts/zenhub/objects/ConvertToEpicRequest.kt index 8274751b46..55e95866ca 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/zenhub/objects/ConvertToEpicRequest.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/zenhub/objects/ConvertToEpicRequest.kt @@ -20,7 +20,7 @@ data class ConvertToEpicRequest( @Serializable data class Issue( @SerialName("repo_id") - val repo: Int, + val repo: String, @SerialName("issue_number") val issueNumber: Int ) From c1c6aad1f8bd8fda436bcd365d9fb5099aa9f917 Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Mon, 4 Jan 2021 16:23:16 +0100 Subject: [PATCH 02/19] .gitignore fix --- flank-scripts/src/flank-scripts.properties | 11 ----------- .../scripts/github/commons/LastWorkflowRunDate.kt | 9 --------- 2 files changed, 20 deletions(-) delete mode 100644 flank-scripts/src/flank-scripts.properties diff --git a/flank-scripts/src/flank-scripts.properties b/flank-scripts/src/flank-scripts.properties deleted file mode 100644 index d4cde57fd8..0000000000 --- a/flank-scripts/src/flank-scripts.properties +++ /dev/null @@ -1,11 +0,0 @@ -#zenhub.repo-id=84221974 -# -#repo.flank=Flank/flank -#repo.gcloud_cli=Flank/gcloud_cli -#repo.test-artifacts=Flank/test_artifacts -# -#integration.workflow-filename=full_suite_integration_tests.yml -#integration.issue-poster=github-actions[bot] -# -#sdk-check.workflow-filename=update_dependencies_and_client.yml -#sdk-check.issue-poster=github-actions[bot] diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/commons/LastWorkflowRunDate.kt b/flank-scripts/src/main/kotlin/flank/scripts/github/commons/LastWorkflowRunDate.kt index 3004d7318c..01573bec9c 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/commons/LastWorkflowRunDate.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/github/commons/LastWorkflowRunDate.kt @@ -43,12 +43,3 @@ private fun GitHubWorkflowRun?.logRun() = this?.also { """.trimIndent() ) } - -fun main() { - runBlocking { - getLastWorkflowRunDate( - token = "46b81695ce4a71ca20e7d618d20c75bcc6a5268e", - workflowFileName = "full_suite_integration_tests.yml" - ) - } -} From 22439cefecbd1efb4295e0ab17cdfa3af95b3c26 Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Mon, 4 Jan 2021 17:00:28 +0100 Subject: [PATCH 03/19] Refactor --- .../scripts/config/FlankScriptsConfigs.kt | 2 +- .../github/commons/LastWorkflowRunDate.kt | 1 - .../firebase/sdk/CheckForSDKUpdateCommand.kt | 52 +++++++++---------- .../zenhub/objects/ConvertToEpicRequest.kt | 2 +- 4 files changed, 28 insertions(+), 29 deletions(-) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt b/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt index 68e2b009e0..3c64bf137f 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt @@ -44,7 +44,7 @@ private val props = SafeProperties(defaults).also { prop -> } } -val zenhubFlankRepoID = props[ZENHUB_REPO_ID] +val zenhubFlankRepoID = Integer.parseInt(props[ZENHUB_REPO_ID]) val flankRepo = props[FLANK_REPO] val flankGcloudCLIRepo = props[GCLOUD_REPO] val flankTestArtifactsRepo = props[ARTIFACTS_REPO] diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/commons/LastWorkflowRunDate.kt b/flank-scripts/src/main/kotlin/flank/scripts/github/commons/LastWorkflowRunDate.kt index 01573bec9c..cf1c5d6030 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/commons/LastWorkflowRunDate.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/github/commons/LastWorkflowRunDate.kt @@ -3,7 +3,6 @@ package flank.scripts.github.commons import com.github.kittinunf.result.getOrNull import flank.scripts.github.getGitHubWorkflowRunsSummary import flank.scripts.github.objects.GitHubWorkflowRun -import kotlinx.coroutines.runBlocking import java.time.Instant import java.time.format.DateTimeFormatter 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 index d62857245d..e0e21bc212 100644 --- 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 @@ -10,6 +10,7 @@ import flank.scripts.shell.utils.currentPath 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/$flankGcloudCLIRepo" @@ -24,32 +25,31 @@ object CheckForSDKUpdateCommand : CliktCommand( private val openedUpdates by lazy { runBlocking { checkForOpenedUpdates(githubToken) } } override fun run() = runBlocking { - println(lastRun) -// 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() -// } -// } + 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( diff --git a/flank-scripts/src/main/kotlin/flank/scripts/zenhub/objects/ConvertToEpicRequest.kt b/flank-scripts/src/main/kotlin/flank/scripts/zenhub/objects/ConvertToEpicRequest.kt index 55e95866ca..8274751b46 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/zenhub/objects/ConvertToEpicRequest.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/zenhub/objects/ConvertToEpicRequest.kt @@ -20,7 +20,7 @@ data class ConvertToEpicRequest( @Serializable data class Issue( @SerialName("repo_id") - val repo: String, + val repo: Int, @SerialName("issue_number") val issueNumber: Int ) From 8958558133135fd7402b8d8d4cb2b46914e54b8e Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Mon, 4 Jan 2021 17:02:27 +0100 Subject: [PATCH 04/19] Use repo from config --- .../kotlin/flank/scripts/github/GithubApi.kt | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt b/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt index cfd6eae2f9..88b5ed2448 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt @@ -38,74 +38,73 @@ import flank.scripts.github.objects.GithubWorkflowRunsSummaryDeserializer import flank.scripts.utils.toJson import java.lang.Exception -private val FLANK_REPO = flankRepo private const val URL_BASE = "https://api.github.com/repos" // ============= HTTP GITHUB API ============= -suspend fun getPrDetailsByCommit(commitSha: String, githubToken: String, repo: String = FLANK_REPO): Result, Exception> = +suspend fun getPrDetailsByCommit(commitSha: String, githubToken: String, repo: String = flankRepo): Result, Exception> = Fuel.get("$URL_BASE/$repo/commits/$commitSha/pulls") .appendGitHubHeaders(githubToken, "application/vnd.github.groot-preview+json") .awaitResult(GithubPullRequestListDeserializer) .mapClientErrorToGithubException() .onError { println("Could not download info for commit $commitSha, because of ${it.message}") } -suspend fun getLatestReleaseTag(githubToken: String, repo: String = FLANK_REPO): Result = +suspend fun getLatestReleaseTag(githubToken: String, repo: String = flankRepo): Result = Fuel.get("$URL_BASE/$repo/releases/latest") .appendGitHubHeaders(githubToken) .awaitResult(GithubReleaseDeserializable) .mapClientErrorToGithubException() -suspend fun getGitHubPullRequest(githubToken: String, issueNumber: Int, repo: String = FLANK_REPO): Result = +suspend fun getGitHubPullRequest(githubToken: String, issueNumber: Int, repo: String = flankRepo): Result = Fuel.get("$URL_BASE/$repo/pulls/$issueNumber") .appendGitHubHeaders(githubToken) .awaitResult(GithubPullRequestDeserializer) .mapClientErrorToGithubException() -suspend fun getGitHubIssue(githubToken: String, issueNumber: Int, repo: String = FLANK_REPO): Result = +suspend fun getGitHubIssue(githubToken: String, issueNumber: Int, repo: String = flankRepo): Result = Fuel.get("$URL_BASE/$repo/issues/$issueNumber") .appendGitHubHeaders(githubToken) .awaitResult(GithubPullRequestDeserializer) .mapClientErrorToGithubException() -suspend fun getGitHubIssueList(githubToken: String, parameters: Parameters = emptyList(), repo: String = FLANK_REPO): Result, Exception> = +suspend fun getGitHubIssueList(githubToken: String, parameters: Parameters = emptyList(), repo: String = flankRepo): Result, Exception> = Fuel.get("$URL_BASE/$repo/issues", parameters) .appendGitHubHeaders(githubToken) .awaitResult(GithubPullRequestListDeserializer) .mapClientErrorToGithubException() -suspend fun getGitHubCommitList(githubToken: String, parameters: Parameters = emptyList(), repo: String = FLANK_REPO): Result, Exception> = +suspend fun getGitHubCommitList(githubToken: String, parameters: Parameters = emptyList(), repo: String = flankRepo): Result, Exception> = Fuel.get("$URL_BASE/$repo/commits", parameters) .appendGitHubHeaders(githubToken) .awaitResult(GitHubCommitListDeserializer) .mapClientErrorToGithubException() -suspend fun getGitHubWorkflowRunsSummary(githubToken: String, workflow: String, parameters: Parameters = emptyList(), repo: String = FLANK_REPO): Result = +suspend fun getGitHubWorkflowRunsSummary(githubToken: String, workflow: String, parameters: Parameters = emptyList(), repo: String = flankRepo): Result = Fuel.get("$URL_BASE/$repo/actions/workflows/$workflow/runs", parameters) .appendGitHubHeaders(githubToken) .awaitResult(GithubWorkflowRunsSummaryDeserializer) .mapClientErrorToGithubException() -suspend fun postNewIssueComment(githubToken: String, issueNumber: Int, payload: GitHubCreateIssueCommentRequest, repo: String = FLANK_REPO): Result = +suspend fun postNewIssueComment(githubToken: String, issueNumber: Int, payload: GitHubCreateIssueCommentRequest, repo: String = flankRepo): Result = Fuel.post("$URL_BASE/$repo/issues/$issueNumber/comments") .appendGitHubHeaders(githubToken) .body(payload.toJson()) .awaitResult(GitHubCreateIssueCommentResponseDeserializer) .mapClientErrorToGithubException() -suspend fun postNewIssue(githubToken: String, payload: GitHubCreateIssueRequest, repo: String = FLANK_REPO): Result = +suspend fun postNewIssue(githubToken: String, payload: GitHubCreateIssueRequest, repo: String = flankRepo): Result = Fuel.post("$URL_BASE/$repo/issues") .appendGitHubHeaders(githubToken) .body(payload.toJson()) .awaitResult(GitHubCreateIssueResponseDeserializer) .mapClientErrorToGithubException() -suspend fun getLabelsFromIssue(githubToken: String, issueNumber: Int, repo: String = FLANK_REPO) = +suspend fun getLabelsFromIssue(githubToken: String, issueNumber: Int, repo: String = flankRepo) = Fuel.get("$URL_BASE/$repo/issues/$issueNumber/labels") .appendGitHubHeaders(githubToken) .awaitResult(GitHubLabelDeserializable) .mapClientErrorToGithubException() -suspend fun setLabelsToPullRequest(githubToken: String, pullRequestNumber: Int, labels: List, repo: String = FLANK_REPO) { +suspend fun setLabelsToPullRequest(githubToken: String, pullRequestNumber: Int, labels: List, repo: String = flankRepo) { Fuel.post("$URL_BASE/$repo/issues/$pullRequestNumber/labels") .appendGitHubHeaders(githubToken) .body(GitHubSetLabelsRequest(labels).toJson()) @@ -114,7 +113,7 @@ suspend fun setLabelsToPullRequest(githubToken: String, pullRequestNumber: Int, .success { println("$labels set to pull request #$pullRequestNumber") } } -suspend fun setAssigneesToPullRequest(githubToken: String, pullRequestNumber: Int, assignees: List, repo: String = FLANK_REPO) { +suspend fun setAssigneesToPullRequest(githubToken: String, pullRequestNumber: Int, assignees: List, repo: String = flankRepo) { Fuel.post("$URL_BASE/$repo/issues/$pullRequestNumber/assignees") .appendGitHubHeaders(githubToken) .body(GitHubSetAssigneesRequest(assignees).toJson()) @@ -126,7 +125,7 @@ suspend fun setAssigneesToPullRequest(githubToken: String, pullRequestNumber: In .success { println("$assignees set to pull request #$pullRequestNumber") } } -fun patchIssue(githubToken: String, issueNumber: Int, payload: GitHubUpdateIssueRequest, repo: String = FLANK_REPO): Result = +fun patchIssue(githubToken: String, issueNumber: Int, payload: GitHubUpdateIssueRequest, repo: String = flankRepo): Result = Fuel.patch("$URL_BASE/$repo/issues/$issueNumber") .appendGitHubHeaders(githubToken) .body(payload.toJson()) @@ -134,7 +133,7 @@ fun patchIssue(githubToken: String, issueNumber: Int, payload: GitHubUpdateIssue .third .mapClientErrorToGithubException() -fun deleteOldTag(tag: String, username: String, password: String, repo: String = FLANK_REPO): Result = +fun deleteOldTag(tag: String, username: String, password: String, repo: String = flankRepo): Result = Fuel.delete("$URL_BASE/$repo/git/refs/tags/$tag") .authentication() .basic(username, password) From 4472f5d0ce160ec63c34c8597f5dcff03ec505f1 Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Wed, 6 Jan 2021 07:28:56 +0100 Subject: [PATCH 05/19] Change root --- flank-scripts/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flank-scripts/.gitignore b/flank-scripts/.gitignore index e50c778fa2..d3537fc23d 100644 --- a/flank-scripts/.gitignore +++ b/flank-scripts/.gitignore @@ -24,4 +24,4 @@ out/ buildSrc/.gradle/ buildSrc/build local.properties -src/flank-scripts.properties +flank-scripts.properties From 81f55fda76d6934b87a82447d7bbbef7ff05ab27 Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Wed, 6 Jan 2021 07:53:52 +0100 Subject: [PATCH 06/19] Add missing properties file --- flank-scripts/flank-scripts.properties | 11 +++++++++++ .../flank/scripts/config/FlankScriptsConfigs.kt | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 flank-scripts/flank-scripts.properties diff --git a/flank-scripts/flank-scripts.properties b/flank-scripts/flank-scripts.properties new file mode 100644 index 0000000000..d4cde57fd8 --- /dev/null +++ b/flank-scripts/flank-scripts.properties @@ -0,0 +1,11 @@ +#zenhub.repo-id=84221974 +# +#repo.flank=Flank/flank +#repo.gcloud_cli=Flank/gcloud_cli +#repo.test-artifacts=Flank/test_artifacts +# +#integration.workflow-filename=full_suite_integration_tests.yml +#integration.issue-poster=github-actions[bot] +# +#sdk-check.workflow-filename=update_dependencies_and_client.yml +#sdk-check.issue-poster=github-actions[bot] diff --git a/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt b/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt index 3c64bf137f..c5c87c5831 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt @@ -39,7 +39,7 @@ private class SafeProperties(defaults: Properties) : Properties(defaults) { } private val props = SafeProperties(defaults).also { prop -> - with(Paths.get("$flankScriptsRootPathString/src/flank-scripts.properties").toFile()) { + with(Paths.get("$flankScriptsRootPathString/flank-scripts.properties").toFile()) { if (exists()) prop.load(inputStream()) } } From dcc72a5225ac11f310397789aadfc4f257ad00fc Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Wed, 6 Jan 2021 07:56:10 +0100 Subject: [PATCH 07/19] Do not use shortcuts --- .../scripts/config/FlankScriptsConfigs.kt | 8 ++--- .../kotlin/flank/scripts/github/GithubApi.kt | 30 +++++++++---------- .../scripts/integration/PrepareMessage.kt | 6 ++-- .../release/updatebugsnag/UpdateBugSnag.kt | 4 +-- .../apiclient/UpdateApiJsonCommand.kt | 6 ++-- .../firebase/sdk/CheckForSDKUpdateCommand.kt | 4 +-- .../scripts/shell/firebase/sdk/CommitList.kt | 4 +-- .../scripts/shell/firebase/sdk/Extensions.kt | 4 +-- .../testartifacts/core/TestArtifactsRepo.kt | 4 +-- .../kotlin/flank/scripts/zenhub/ZenHubAPI.kt | 4 +-- 10 files changed, 37 insertions(+), 37 deletions(-) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt b/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt index c5c87c5831..04a0e1a0c0 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt @@ -44,10 +44,10 @@ private val props = SafeProperties(defaults).also { prop -> } } -val zenhubFlankRepoID = Integer.parseInt(props[ZENHUB_REPO_ID]) -val flankRepo = props[FLANK_REPO] -val flankGcloudCLIRepo = props[GCLOUD_REPO] -val flankTestArtifactsRepo = props[ARTIFACTS_REPO] +val zenhubRepositoryID = Integer.parseInt(props[ZENHUB_REPO_ID]) +val flankRepository = props[FLANK_REPO] +val flankGcloudCLIRepository = props[GCLOUD_REPO] +val flankTestArtifactsRepository = props[ARTIFACTS_REPO] val integrationOpenedIssueUser = props[IT_USER] val updatesOpenedUser = props[SDK_USER] val fullSuiteWorkflowFilename = props[IT_WORKFLOW_FILE] diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt b/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt index 88b5ed2448..fb4f236c75 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt @@ -16,7 +16,7 @@ import com.jcabi.github.Repo import com.jcabi.github.RtGithub import flank.scripts.ci.releasenotes.GitHubRelease import flank.scripts.ci.releasenotes.GithubReleaseDeserializable -import flank.scripts.config.flankRepo +import flank.scripts.config.flankRepository import flank.scripts.exceptions.mapClientErrorToGithubException import flank.scripts.github.objects.GitHubCommit import flank.scripts.github.objects.GitHubCommitListDeserializer @@ -41,70 +41,70 @@ import java.lang.Exception private const val URL_BASE = "https://api.github.com/repos" // ============= HTTP GITHUB API ============= -suspend fun getPrDetailsByCommit(commitSha: String, githubToken: String, repo: String = flankRepo): Result, Exception> = +suspend fun getPrDetailsByCommit(commitSha: String, githubToken: String, repo: String = flankRepository): Result, Exception> = Fuel.get("$URL_BASE/$repo/commits/$commitSha/pulls") .appendGitHubHeaders(githubToken, "application/vnd.github.groot-preview+json") .awaitResult(GithubPullRequestListDeserializer) .mapClientErrorToGithubException() .onError { println("Could not download info for commit $commitSha, because of ${it.message}") } -suspend fun getLatestReleaseTag(githubToken: String, repo: String = flankRepo): Result = +suspend fun getLatestReleaseTag(githubToken: String, repo: String = flankRepository): Result = Fuel.get("$URL_BASE/$repo/releases/latest") .appendGitHubHeaders(githubToken) .awaitResult(GithubReleaseDeserializable) .mapClientErrorToGithubException() -suspend fun getGitHubPullRequest(githubToken: String, issueNumber: Int, repo: String = flankRepo): Result = +suspend fun getGitHubPullRequest(githubToken: String, issueNumber: Int, repo: String = flankRepository): Result = Fuel.get("$URL_BASE/$repo/pulls/$issueNumber") .appendGitHubHeaders(githubToken) .awaitResult(GithubPullRequestDeserializer) .mapClientErrorToGithubException() -suspend fun getGitHubIssue(githubToken: String, issueNumber: Int, repo: String = flankRepo): Result = +suspend fun getGitHubIssue(githubToken: String, issueNumber: Int, repo: String = flankRepository): Result = Fuel.get("$URL_BASE/$repo/issues/$issueNumber") .appendGitHubHeaders(githubToken) .awaitResult(GithubPullRequestDeserializer) .mapClientErrorToGithubException() -suspend fun getGitHubIssueList(githubToken: String, parameters: Parameters = emptyList(), repo: String = flankRepo): Result, Exception> = +suspend fun getGitHubIssueList(githubToken: String, parameters: Parameters = emptyList(), repo: String = flankRepository): Result, Exception> = Fuel.get("$URL_BASE/$repo/issues", parameters) .appendGitHubHeaders(githubToken) .awaitResult(GithubPullRequestListDeserializer) .mapClientErrorToGithubException() -suspend fun getGitHubCommitList(githubToken: String, parameters: Parameters = emptyList(), repo: String = flankRepo): Result, Exception> = +suspend fun getGitHubCommitList(githubToken: String, parameters: Parameters = emptyList(), repo: String = flankRepository): Result, Exception> = Fuel.get("$URL_BASE/$repo/commits", parameters) .appendGitHubHeaders(githubToken) .awaitResult(GitHubCommitListDeserializer) .mapClientErrorToGithubException() -suspend fun getGitHubWorkflowRunsSummary(githubToken: String, workflow: String, parameters: Parameters = emptyList(), repo: String = flankRepo): Result = +suspend fun getGitHubWorkflowRunsSummary(githubToken: String, workflow: String, parameters: Parameters = emptyList(), repo: String = flankRepository): Result = Fuel.get("$URL_BASE/$repo/actions/workflows/$workflow/runs", parameters) .appendGitHubHeaders(githubToken) .awaitResult(GithubWorkflowRunsSummaryDeserializer) .mapClientErrorToGithubException() -suspend fun postNewIssueComment(githubToken: String, issueNumber: Int, payload: GitHubCreateIssueCommentRequest, repo: String = flankRepo): Result = +suspend fun postNewIssueComment(githubToken: String, issueNumber: Int, payload: GitHubCreateIssueCommentRequest, repo: String = flankRepository): Result = Fuel.post("$URL_BASE/$repo/issues/$issueNumber/comments") .appendGitHubHeaders(githubToken) .body(payload.toJson()) .awaitResult(GitHubCreateIssueCommentResponseDeserializer) .mapClientErrorToGithubException() -suspend fun postNewIssue(githubToken: String, payload: GitHubCreateIssueRequest, repo: String = flankRepo): Result = +suspend fun postNewIssue(githubToken: String, payload: GitHubCreateIssueRequest, repo: String = flankRepository): Result = Fuel.post("$URL_BASE/$repo/issues") .appendGitHubHeaders(githubToken) .body(payload.toJson()) .awaitResult(GitHubCreateIssueResponseDeserializer) .mapClientErrorToGithubException() -suspend fun getLabelsFromIssue(githubToken: String, issueNumber: Int, repo: String = flankRepo) = +suspend fun getLabelsFromIssue(githubToken: String, issueNumber: Int, repo: String = flankRepository) = Fuel.get("$URL_BASE/$repo/issues/$issueNumber/labels") .appendGitHubHeaders(githubToken) .awaitResult(GitHubLabelDeserializable) .mapClientErrorToGithubException() -suspend fun setLabelsToPullRequest(githubToken: String, pullRequestNumber: Int, labels: List, repo: String = flankRepo) { +suspend fun setLabelsToPullRequest(githubToken: String, pullRequestNumber: Int, labels: List, repo: String = flankRepository) { Fuel.post("$URL_BASE/$repo/issues/$pullRequestNumber/labels") .appendGitHubHeaders(githubToken) .body(GitHubSetLabelsRequest(labels).toJson()) @@ -113,7 +113,7 @@ suspend fun setLabelsToPullRequest(githubToken: String, pullRequestNumber: Int, .success { println("$labels set to pull request #$pullRequestNumber") } } -suspend fun setAssigneesToPullRequest(githubToken: String, pullRequestNumber: Int, assignees: List, repo: String = flankRepo) { +suspend fun setAssigneesToPullRequest(githubToken: String, pullRequestNumber: Int, assignees: List, repo: String = flankRepository) { Fuel.post("$URL_BASE/$repo/issues/$pullRequestNumber/assignees") .appendGitHubHeaders(githubToken) .body(GitHubSetAssigneesRequest(assignees).toJson()) @@ -125,7 +125,7 @@ suspend fun setAssigneesToPullRequest(githubToken: String, pullRequestNumber: In .success { println("$assignees set to pull request #$pullRequestNumber") } } -fun patchIssue(githubToken: String, issueNumber: Int, payload: GitHubUpdateIssueRequest, repo: String = flankRepo): Result = +fun patchIssue(githubToken: String, issueNumber: Int, payload: GitHubUpdateIssueRequest, repo: String = flankRepository): Result = Fuel.patch("$URL_BASE/$repo/issues/$issueNumber") .appendGitHubHeaders(githubToken) .body(payload.toJson()) @@ -133,7 +133,7 @@ fun patchIssue(githubToken: String, issueNumber: Int, payload: GitHubUpdateIssue .third .mapClientErrorToGithubException() -fun deleteOldTag(tag: String, username: String, password: String, repo: String = flankRepo): Result = +fun deleteOldTag(tag: String, username: String, password: String, repo: String = flankRepository): Result = Fuel.delete("$URL_BASE/$repo/git/refs/tags/$tag") .authentication() .basic(username, password) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/integration/PrepareMessage.kt b/flank-scripts/src/main/kotlin/flank/scripts/integration/PrepareMessage.kt index a273ecf962..a787387134 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/integration/PrepareMessage.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/integration/PrepareMessage.kt @@ -1,6 +1,6 @@ package flank.scripts.integration -import flank.scripts.config.flankRepo +import flank.scripts.config.flankRepository import flank.scripts.github.objects.GithubPullRequest import java.time.Instant import java.time.LocalDateTime @@ -34,7 +34,7 @@ private val successTemplate = { lastRun: String, runId: String, url: String -> """ |### Full suite IT run :white_check_mark: SUCCEEDED :white_check_mark: |**Timestamp:** ${makeHumanFriendly(lastRun)} - |**Job run:** [$runId](https://github.com/$flankRepo/actions/runs/$runId) + |**Job run:** [$runId](https://github.com/$flankRepository/actions/runs/$runId) |**Build scan URL:** $url |**Closing issue** """.trimMargin() @@ -44,7 +44,7 @@ private val failureTemplate = { lastRun: String, runId: String, url: String -> """ |### Full suite IT run :x: FAILED :x: |**Timestamp:** ${makeHumanFriendly(lastRun)} - |**Job run:** [$runId](https://github.com/$flankRepo/actions/runs/$runId) + |**Job run:** [$runId](https://github.com/$flankRepository/actions/runs/$runId) |**Build scan URL:** $url """.trimMargin() } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/release/updatebugsnag/UpdateBugSnag.kt b/flank-scripts/src/main/kotlin/flank/scripts/release/updatebugsnag/UpdateBugSnag.kt index e4ef3d532b..903529a3f1 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/release/updatebugsnag/UpdateBugSnag.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/release/updatebugsnag/UpdateBugSnag.kt @@ -3,7 +3,7 @@ package flank.scripts.release.updatebugsnag import com.github.kittinunf.fuel.Fuel import com.github.kittinunf.fuel.core.extensions.jsonBody import com.github.kittinunf.fuel.coroutines.awaitResult -import flank.scripts.config.flankRepo +import flank.scripts.config.flankRepository import flank.scripts.exceptions.mapClientError import flank.scripts.exceptions.toBugsnagException import flank.scripts.utils.toJson @@ -34,4 +34,4 @@ private fun githubActionsSourceControl(appVersion: String) = SourceControl( ) private const val BUGNSAG_URL = "https://build.bugsnag.com/" -private val REPOSITORY = "https://github.com/$flankRepo" +private val REPOSITORY = "https://github.com/$flankRepository" 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 index ecfd14d39a..175d60127a 100644 --- 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 @@ -2,7 +2,7 @@ package flank.scripts.shell.firebase.apiclient import com.github.ajalt.clikt.core.CliktCommand import flank.common.downloadFile -import flank.scripts.config.flankGcloudCLIRepo +import flank.scripts.config.flankGcloudCLIRepository import flank.scripts.shell.utils.currentPath import flank.scripts.utils.downloadSortJsonIfNeeded import flank.scripts.utils.runCommand @@ -15,12 +15,12 @@ object UpdateApiJsonCommand : CliktCommand(name = "updateApiJson", help = "Downl val testingV1Beta3Path = Paths.get(jsonDirectoryPath.toString(), "toolresults_v1beta3.json").toString() downloadFile( - "https://raw.githubusercontent.com/$flankGcloudCLIRepo/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/testing_v1.json", + "https://raw.githubusercontent.com/$flankGcloudCLIRepository/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/testing_v1.json", testingV1Path ) downloadFile( - "https://raw.githubusercontent.com/$flankGcloudCLIRepo/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/toolresults_v1beta3.json", + "https://raw.githubusercontent.com/$flankGcloudCLIRepository/master/google-cloud-sdk/lib/googlecloudsdk/third_party/apis/toolresults_v1beta3.json", testingV1Beta3Path ) 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 index e0e21bc212..1d0ec50035 100644 --- 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 @@ -5,14 +5,14 @@ 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.downloadFile -import flank.scripts.config.flankGcloudCLIRepo +import flank.scripts.config.flankGcloudCLIRepository import flank.scripts.shell.utils.currentPath 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/$flankGcloudCLIRepo" +private val RAW_GITHUB = "https://raw.githubusercontent.com/$flankGcloudCLIRepository" object CheckForSDKUpdateCommand : CliktCommand( name = "checkForSdkUpdate", diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CommitList.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CommitList.kt index 4cdd80639c..18474b6fab 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CommitList.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CommitList.kt @@ -1,6 +1,6 @@ package flank.scripts.shell.firebase.sdk -import flank.scripts.config.flankGcloudCLIRepo +import flank.scripts.config.flankGcloudCLIRepository import flank.scripts.github.getGitHubCommitList import flank.scripts.github.objects.GitHubCommit import java.time.Instant @@ -13,7 +13,7 @@ suspend fun getCommitsUntilLastCheck(token: String, until: String): String? = ge "per_page" to 10, "until" to until ), - repo = flankGcloudCLIRepo + repo = flankGcloudCLIRepository ) .get() .maxByOrNull { Instant.from(DateTimeFormatter.ISO_INSTANT.parse(it.commit.author.date)) } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/Extensions.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/Extensions.kt index 4a020d63d0..f3deb12f9a 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/Extensions.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/Extensions.kt @@ -3,7 +3,7 @@ package flank.scripts.shell.firebase.sdk import com.github.kittinunf.result.Result import com.github.kittinunf.result.onError import flank.common.newLine -import flank.scripts.config.zenhubFlankRepoID +import flank.scripts.config.zenhubRepositoryID import flank.scripts.github.objects.GitHubCreateIssueRequest import flank.scripts.github.objects.GitHubCreateIssueResponse import flank.scripts.github.objects.GitHubUpdateIssueRequest @@ -74,7 +74,7 @@ private suspend fun SDKUpdateContext.createSubIssues() = coroutineScope { } } .awaitAll() - .map { Issue(zenhubFlankRepoID, it.number) } + .map { Issue(zenhubRepositoryID, it.number) } } } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/TestArtifactsRepo.kt b/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/TestArtifactsRepo.kt index 2f4d1989d2..049e175e5d 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/TestArtifactsRepo.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/TestArtifactsRepo.kt @@ -1,8 +1,8 @@ package flank.scripts.testartifacts.core import com.jcabi.github.Repo -import flank.scripts.config.flankTestArtifactsRepo +import flank.scripts.config.flankTestArtifactsRepository import flank.scripts.github.githubRepo import flank.scripts.utils.getEnv -internal fun testArtifactsRepo(): Repo = githubRepo(getEnv(GITHUB_TOKEN_ENV_KEY), flankTestArtifactsRepo) +internal fun testArtifactsRepo(): Repo = githubRepo(getEnv(GITHUB_TOKEN_ENV_KEY), flankTestArtifactsRepository) diff --git a/flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubAPI.kt b/flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubAPI.kt index 8691b1271c..cbf79b666d 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubAPI.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubAPI.kt @@ -7,13 +7,13 @@ import com.github.kittinunf.fuel.coroutines.awaitStringResult import com.github.kittinunf.result.getOrNull import com.github.kittinunf.result.onError import com.github.kittinunf.result.success -import flank.scripts.config.zenhubFlankRepoID +import flank.scripts.config.zenhubRepositoryID 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/$zenhubFlankRepoID" +internal val ZENHUB_BASE_URL = "https://api.zenhub.com/p1/repositories/$zenhubRepositoryID" suspend fun copyEstimation(zenhubToken: String, issueNumber: Int, pullRequestNumber: Int) { getEstimation(zenhubToken, issueNumber) From 70f167e0c1f0aaf858bf0cbd469f9cec3ac22cd2 Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Wed, 6 Jan 2021 08:33:40 +0100 Subject: [PATCH 08/19] Move to common --- common/.gitignore | 1 + .../main/kotlin/flank.common/Environment.kt | 3 ++ .../main/kotlin/flank.common}/PathHelper.kt | 4 +- .../flank/common/config/FlankProperties.kt | 43 +++++++++++++++ flank-scripts/.gitignore | 1 - flank-scripts/README.md | 2 +- flank-scripts/flank-scripts.properties | 11 ---- .../scripts/config/FlankScriptsConfigs.kt | 52 ++++--------------- .../ideaktlint/IdeaKtlintCodeStyleCommand.kt | 4 +- .../kotlin/flank/scripts/shell/BuildFlank.kt | 2 +- .../apiclient/UpdateApiJsonCommand.kt | 2 +- .../firebase/sdk/CheckForSDKUpdateCommand.kt | 2 +- .../flank/scripts/shell/ios/BuildExample.kt | 4 +- .../flank/scripts/shell/ios/RunFtlLocal.kt | 2 +- .../scripts/shell/ios/SetupIosEnvCommand.kt | 2 +- .../scripts/shell/ios/UniversalFramework.kt | 2 +- .../flank/scripts/shell/ops/BuildAndroid.kt | 4 +- .../shell/ops/BuildEarlGreyExampleCommand.kt | 2 +- .../shell/ops/BuildFlankExampleCommand.kt | 2 +- .../shell/ops/BuildGameLoopExampleCommand.kt | 2 +- .../flank/scripts/shell/ops/BuildIosIPA.kt | 2 +- .../shell/ops/BuildIosTestArtifacts.kt | 2 +- .../shell/ops/BuildTestPlansExample.kt | 2 +- .../flank/scripts/shell/ops/GoOpsCommand.kt | 4 +- 24 files changed, 80 insertions(+), 77 deletions(-) create mode 100644 common/src/main/kotlin/flank.common/Environment.kt rename {flank-scripts/src/main/kotlin/flank/scripts/shell/utils => common/src/main/kotlin/flank.common}/PathHelper.kt (87%) create mode 100644 common/src/main/kotlin/flank/common/config/FlankProperties.kt delete mode 100644 flank-scripts/flank-scripts.properties diff --git a/common/.gitignore b/common/.gitignore index d5d0c34476..cab5a533b9 100644 --- a/common/.gitignore +++ b/common/.gitignore @@ -12,3 +12,4 @@ build/ out/ .gradle/ local.properties +flank-debug.properties diff --git a/common/src/main/kotlin/flank.common/Environment.kt b/common/src/main/kotlin/flank.common/Environment.kt new file mode 100644 index 0000000000..264bf2c34b --- /dev/null +++ b/common/src/main/kotlin/flank.common/Environment.kt @@ -0,0 +1,3 @@ +package flank.common + +fun isCI() = System.getenv("CI") != null diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt b/common/src/main/kotlin/flank.common/PathHelper.kt similarity index 87% rename from flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt rename to common/src/main/kotlin/flank.common/PathHelper.kt index 0393d343cd..52d0852a69 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/utils/PathHelper.kt +++ b/common/src/main/kotlin/flank.common/PathHelper.kt @@ -1,4 +1,4 @@ -package flank.scripts.shell.utils +package flank.common import java.nio.file.Files import java.nio.file.Path @@ -21,4 +21,4 @@ val flankFixturesTmpPath = val flankFixturesIosTmpPath = Paths.get(flankFixturesTmpPath, "ios").toString() -val flankScriptsRootPathString = Paths.get(rootDirectoryPathString, "flank-scripts").toString() +val flankCommonRootPathString = Paths.get(rootDirectoryPathString, "common").toString() diff --git a/common/src/main/kotlin/flank/common/config/FlankProperties.kt b/common/src/main/kotlin/flank/common/config/FlankProperties.kt new file mode 100644 index 0000000000..c2bb4dae14 --- /dev/null +++ b/common/src/main/kotlin/flank/common/config/FlankProperties.kt @@ -0,0 +1,43 @@ +package flank.common.config + +import flank.common.flankCommonRootPathString +import flank.common.isCI +import java.nio.file.Paths +import java.util.Properties + +const val ZENHUB_REPO_ID = "zenhub.repo-id" +const val FLANK_REPO = "repo.flank" +const val GCLOUD_REPO = "repo.gcloud_cli" +const val ARTIFACTS_REPO = "repo.test-artifacts" +const val IT_WORKFLOW_FILE = "integration.workflow-filename" +const val IT_USER = "integration.issue-poster" +const val SDK_WORKFLOW = "sdk-check.workflow-filename" +const val SDK_USER = "sdk-check.issue-poster" + +private val defaults = Properties().apply { + setProperty(ZENHUB_REPO_ID, "84221974") + setProperty(FLANK_REPO, "Flank/flank") + setProperty(GCLOUD_REPO, "Flank/gcloud_cli") + setProperty(ARTIFACTS_REPO, "Flank/test_artifacts") + setProperty(IT_WORKFLOW_FILE, "full_suite_integration_tests.yml") + setProperty(IT_USER, "github-actions[bot]") + setProperty(SDK_WORKFLOW, "update_dependencies_and_client.yml") + setProperty(SDK_USER, "github-actions[bot]") +} + +class SafeProperties(defaults: Properties) : Properties(defaults) { + override fun get(key: Any?) = (key as String).run { + requireNotNull(if (shouldUseDefaults()) defaults.getProperty(key) else getProperty(key)) + } +} + +// default properties should be used in CI and during tests +private fun shouldUseDefaults() = isCI() || isTest() + +private fun isTest() = System.getProperty("testScript") != null + +val flankProjectProperties = SafeProperties(defaults).also { prop -> + with(Paths.get("$flankCommonRootPathString/flank-debug.properties").toFile()) { + if (exists()) prop.load(inputStream()) + } +} diff --git a/flank-scripts/.gitignore b/flank-scripts/.gitignore index d3537fc23d..f7c742d13e 100644 --- a/flank-scripts/.gitignore +++ b/flank-scripts/.gitignore @@ -24,4 +24,3 @@ out/ buildSrc/.gradle/ buildSrc/build local.properties -flank-scripts.properties diff --git a/flank-scripts/README.md b/flank-scripts/README.md index eabfaa18c1..036f019edf 100644 --- a/flank-scripts/README.md +++ b/flank-scripts/README.md @@ -308,7 +308,7 @@ Applies a pre-commit hook that runs Ktlint on a commit and fails if there are li Applies Ktlint styling to the current idea project, so that correct code styling is upheld. ## Testing -To test your script with different settings use `flank-scripts.properties` file. Uncomment and replace with desired values. +To test your script with different settings use `flank-debug.properties` file. Uncomment and replace with desired values. Properties are skipped by git and should not be attached to a commit. Note, `test` task ignores your own properties and will use the default. #### List of possible configs diff --git a/flank-scripts/flank-scripts.properties b/flank-scripts/flank-scripts.properties deleted file mode 100644 index d4cde57fd8..0000000000 --- a/flank-scripts/flank-scripts.properties +++ /dev/null @@ -1,11 +0,0 @@ -#zenhub.repo-id=84221974 -# -#repo.flank=Flank/flank -#repo.gcloud_cli=Flank/gcloud_cli -#repo.test-artifacts=Flank/test_artifacts -# -#integration.workflow-filename=full_suite_integration_tests.yml -#integration.issue-poster=github-actions[bot] -# -#sdk-check.workflow-filename=update_dependencies_and_client.yml -#sdk-check.issue-poster=github-actions[bot] diff --git a/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt b/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt index 04a0e1a0c0..182286795b 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt @@ -1,48 +1,16 @@ package flank.scripts.config -import flank.scripts.shell.utils.flankScriptsRootPathString -import java.nio.file.Paths -import java.util.Properties +import flank.common.config.ARTIFACTS_REPO +import flank.common.config.FLANK_REPO +import flank.common.config.GCLOUD_REPO +import flank.common.config.IT_USER +import flank.common.config.IT_WORKFLOW_FILE +import flank.common.config.SDK_USER +import flank.common.config.SDK_WORKFLOW +import flank.common.config.ZENHUB_REPO_ID +import flank.common.config.flankProjectProperties -private const val ZENHUB_REPO_ID = "zenhub.repo-id" -private const val FLANK_REPO = "repo.flank" -private const val GCLOUD_REPO = "repo.gcloud_cli" -private const val ARTIFACTS_REPO = "repo.test-artifacts" -private const val IT_WORKFLOW_FILE = "integration.workflow-filename" -private const val IT_USER = "integration.issue-poster" -private const val SDK_WORKFLOW = "sdk-check.workflow-filename" -private const val SDK_USER = "sdk-check.issue-poster" - -private val defaults = Properties().apply { - setProperty(ZENHUB_REPO_ID, "84221974") - setProperty(FLANK_REPO, "Flank/flank") - setProperty(GCLOUD_REPO, "Flank/gcloud_cli") - setProperty(ARTIFACTS_REPO, "Flank/test_artifacts") - setProperty(IT_WORKFLOW_FILE, "full_suite_integration_tests.yml") - setProperty(IT_USER, "github-actions[bot]") - setProperty(SDK_WORKFLOW, "update_dependencies_and_client.yml") - setProperty(SDK_USER, "github-actions[bot]") -} - -private class SafeProperties(defaults: Properties) : Properties(defaults) { - override fun get(key: Any?) = (key as String).run { - requireNotNull( - if ( - // we want our CI to use defaults always - System.getenv("CI") != null || - // we don't want to use developers' properties during tests - System.getProperty("testScript") != null - ) defaults.getProperty(key) - else getProperty(key) - ) - } -} - -private val props = SafeProperties(defaults).also { prop -> - with(Paths.get("$flankScriptsRootPathString/flank-scripts.properties").toFile()) { - if (exists()) prop.load(inputStream()) - } -} +private val props = flankProjectProperties val zenhubRepositoryID = Integer.parseInt(props[ZENHUB_REPO_ID]) val flankRepository = props[FLANK_REPO] 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 index e28c3c978c..e9b87f5cf8 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/contribution/ideaktlint/IdeaKtlintCodeStyleCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/contribution/ideaktlint/IdeaKtlintCodeStyleCommand.kt @@ -1,11 +1,11 @@ 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.shell.utils.currentPath -import flank.scripts.shell.utils.goToRoot import flank.scripts.utils.isWindows import flank.scripts.utils.runCommand import kotlinx.coroutines.runBlocking diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/BuildFlank.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/BuildFlank.kt index c8fe356b00..92fa0c5166 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/BuildFlank.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/BuildFlank.kt @@ -1,8 +1,8 @@ package flank.scripts.shell import com.github.ajalt.clikt.core.CliktCommand +import flank.common.rootDirectoryPathString import flank.scripts.shell.utils.createGradleCommand -import flank.scripts.shell.utils.rootDirectoryPathString import flank.scripts.utils.runCommand import java.nio.file.Files import java.nio.file.Paths 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 index 175d60127a..0a24f68781 100644 --- 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 @@ -1,9 +1,9 @@ package flank.scripts.shell.firebase.apiclient import com.github.ajalt.clikt.core.CliktCommand +import flank.common.currentPath import flank.common.downloadFile import flank.scripts.config.flankGcloudCLIRepository -import flank.scripts.shell.utils.currentPath import flank.scripts.utils.downloadSortJsonIfNeeded import flank.scripts.utils.runCommand import java.nio.file.Paths 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 index 1d0ec50035..239845b3fd 100644 --- 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 @@ -4,9 +4,9 @@ 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.currentPath import flank.common.downloadFile import flank.scripts.config.flankGcloudCLIRepository -import flank.scripts.shell.utils.currentPath import flank.scripts.utils.parseToVersion import kotlinx.coroutines.runBlocking import java.nio.file.Paths diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildExample.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildExample.kt index 090b670c68..43838aadca 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildExample.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/BuildExample.kt @@ -3,9 +3,9 @@ package flank.scripts.shell.ios import com.github.ajalt.clikt.core.CliktCommand import flank.common.archive -import flank.scripts.shell.utils.currentPath +import flank.common.currentPath +import flank.common.iOSTestProjectsPath import flank.scripts.shell.utils.failIfWindows -import flank.scripts.shell.utils.iOSTestProjectsPath import flank.scripts.shell.utils.pipe import flank.scripts.utils.downloadXcPrettyIfNeeded import flank.scripts.utils.installPodsIfNeeded diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt index ff20f624ab..c71c18f33f 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/RunFtlLocal.kt @@ -3,7 +3,7 @@ package flank.scripts.shell.ios import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.parameters.options.option import com.github.ajalt.clikt.parameters.options.required -import flank.scripts.shell.utils.currentPath +import flank.common.currentPath import flank.scripts.shell.utils.failIfWindows import flank.scripts.utils.runCommand import java.nio.file.Path 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 index b7d2f160a6..40424ce04c 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/SetupIosEnvCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/SetupIosEnvCommand.kt @@ -1,9 +1,9 @@ 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.shell.utils.iOSTestProjectsPath import flank.scripts.utils.downloadCocoaPodsIfNeeded import flank.scripts.utils.installPodsIfNeeded import java.nio.file.Paths diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt index d96be8649e..3b4f309acc 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ios/UniversalFramework.kt @@ -1,7 +1,7 @@ package flank.scripts.shell.ios import com.github.ajalt.clikt.core.CliktCommand -import flank.scripts.shell.utils.currentPath +import flank.common.currentPath import flank.scripts.shell.utils.failIfWindows import flank.scripts.utils.runCommand import java.nio.file.Paths diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildAndroid.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildAndroid.kt index 4d3cea1131..8bec169095 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildAndroid.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildAndroid.kt @@ -1,8 +1,8 @@ package flank.scripts.shell.ops -import flank.scripts.shell.utils.androidTestProjectsPath +import flank.common.androidTestProjectsPath +import flank.common.flankFixturesTmpPath import flank.scripts.shell.utils.createGradleCommand -import flank.scripts.shell.utils.flankFixturesTmpPath import flank.scripts.utils.runCommand import java.io.File import java.nio.file.Files 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 index 8da01cfa1d..1abb73680a 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildEarlGreyExampleCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildEarlGreyExampleCommand.kt @@ -3,8 +3,8 @@ package flank.scripts.shell.ops import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.parameters.options.flag import com.github.ajalt.clikt.parameters.options.option +import flank.common.iOSTestProjectsPath import flank.scripts.shell.utils.failIfWindows -import flank.scripts.shell.utils.iOSTestProjectsPath import java.nio.file.Paths object BuildEarlGreyExampleCommand : CliktCommand(name = "build_earl_grey_example", help = "Build ios earl grey example app with tests") { 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 index 873339867e..a4e0959999 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildFlankExampleCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildFlankExampleCommand.kt @@ -3,8 +3,8 @@ package flank.scripts.shell.ops import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.parameters.options.flag import com.github.ajalt.clikt.parameters.options.option +import flank.common.iOSTestProjectsPath import flank.scripts.shell.utils.failIfWindows -import flank.scripts.shell.utils.iOSTestProjectsPath import java.nio.file.Paths object BuildFlankExampleCommand : CliktCommand(name = "build_flank_example", help = "Build ios flank example app with tests") { 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 index d77902d2f5..3dce78b843 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildGameLoopExampleCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildGameLoopExampleCommand.kt @@ -3,8 +3,8 @@ package flank.scripts.shell.ops import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.parameters.options.flag import com.github.ajalt.clikt.parameters.options.option +import flank.common.iOSTestProjectsPath import flank.scripts.shell.utils.failIfWindows -import flank.scripts.shell.utils.iOSTestProjectsPath import java.nio.file.Paths object BuildGameLoopExampleCommand : CliktCommand( diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIosIPA.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIosIPA.kt index 71055673f2..745b00123e 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIosIPA.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIosIPA.kt @@ -1,8 +1,8 @@ package flank.scripts.shell.ops +import flank.common.flankFixturesIosTmpPath import flank.scripts.shell.ios.createXcodeArchiveCommand import flank.scripts.shell.ios.createXcodeExportArchiveCommand -import flank.scripts.shell.utils.flankFixturesIosTmpPath import flank.scripts.shell.utils.pipe import flank.scripts.utils.downloadCocoaPodsIfNeeded import flank.scripts.utils.downloadXcPrettyIfNeeded diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIosTestArtifacts.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIosTestArtifacts.kt index 42fe48f0e3..4668ad181d 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIosTestArtifacts.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildIosTestArtifacts.kt @@ -1,8 +1,8 @@ package flank.scripts.shell.ops import flank.common.archive +import flank.common.flankFixturesIosTmpPath import flank.scripts.shell.ios.createXcodeBuildForTestingCommand -import flank.scripts.shell.utils.flankFixturesIosTmpPath import flank.scripts.shell.utils.pipe import flank.scripts.utils.downloadCocoaPodsIfNeeded import flank.scripts.utils.downloadXcPrettyIfNeeded 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 index 916bb5f4ac..b7ddbc1749 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildTestPlansExample.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/BuildTestPlansExample.kt @@ -3,8 +3,8 @@ package flank.scripts.shell.ops import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.parameters.options.flag import com.github.ajalt.clikt.parameters.options.option +import flank.common.iOSTestProjectsPath import flank.scripts.shell.utils.failIfWindows -import flank.scripts.shell.utils.iOSTestProjectsPath import java.nio.file.Paths object BuildTestPlansExample : CliktCommand(name = "build_ios_testplans_example", help = "Build ios test plans example app") { diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt index 761ca0703e..e03f0c0f07 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/ops/GoOpsCommand.kt @@ -1,8 +1,8 @@ package flank.scripts.shell.ops import com.github.ajalt.clikt.core.CliktCommand -import flank.scripts.shell.utils.flankFixturesTmpPath -import flank.scripts.shell.utils.testProjectsPath +import flank.common.flankFixturesTmpPath +import flank.common.testProjectsPath import flank.scripts.utils.runCommand import java.nio.file.Path import java.nio.file.Paths From b00c2279daa5402506120ea45b1876800566816c Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Wed, 6 Jan 2021 08:48:56 +0100 Subject: [PATCH 09/19] Change package --- .../src/main/kotlin/{flank.common => flank/common}/Environment.kt | 0 .../src/main/kotlin/{flank.common => flank/common}/PathHelper.kt | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename common/src/main/kotlin/{flank.common => flank/common}/Environment.kt (100%) rename common/src/main/kotlin/{flank.common => flank/common}/PathHelper.kt (100%) diff --git a/common/src/main/kotlin/flank.common/Environment.kt b/common/src/main/kotlin/flank/common/Environment.kt similarity index 100% rename from common/src/main/kotlin/flank.common/Environment.kt rename to common/src/main/kotlin/flank/common/Environment.kt diff --git a/common/src/main/kotlin/flank.common/PathHelper.kt b/common/src/main/kotlin/flank/common/PathHelper.kt similarity index 100% rename from common/src/main/kotlin/flank.common/PathHelper.kt rename to common/src/main/kotlin/flank/common/PathHelper.kt From a0225fb634d21bfbb510f3fcb060fff9ef4733b4 Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Wed, 6 Jan 2021 09:20:56 +0100 Subject: [PATCH 10/19] Change gradle file --- build.gradle.kts | 7 +++++ .../flank/common/config/FlankProperties.kt | 29 ++++++++++++------- flank-scripts/build.gradle.kts | 1 - .../scripts/config/FlankScriptsConfigs.kt | 22 -------------- .../kotlin/flank/scripts/github/GithubApi.kt | 2 +- .../flank/scripts/integration/IssueList.kt | 2 +- .../scripts/integration/PrepareMessage.kt | 2 +- .../scripts/integration/WorkflowSummary.kt | 2 +- .../release/updatebugsnag/UpdateBugSnag.kt | 2 +- .../apiclient/UpdateApiJsonCommand.kt | 2 +- .../firebase/sdk/CheckForSDKUpdateCommand.kt | 2 +- .../scripts/shell/firebase/sdk/CommitList.kt | 2 +- .../scripts/shell/firebase/sdk/Extensions.kt | 2 +- .../shell/firebase/sdk/LastSDKUpdateRun.kt | 2 +- .../shell/firebase/sdk/OpenedUpdates.kt | 2 +- .../testartifacts/core/TestArtifactsRepo.kt | 2 +- .../kotlin/flank/scripts/zenhub/ZenHubAPI.kt | 2 +- 17 files changed, 39 insertions(+), 46 deletions(-) delete mode 100644 flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt diff --git a/build.gradle.kts b/build.gradle.kts index 5f73346022..d2013ea7f6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -30,6 +30,13 @@ tasks { subprojects { apply(plugin = Plugins.KTLINT_GRADLE_PLUGIN) + afterEvaluate { + if (tasks.findByName("test") != null) { + tasks.test { + systemProperty("useDefaultProperties", "") + } + } + } } repositories { diff --git a/common/src/main/kotlin/flank/common/config/FlankProperties.kt b/common/src/main/kotlin/flank/common/config/FlankProperties.kt index c2bb4dae14..996c96d039 100644 --- a/common/src/main/kotlin/flank/common/config/FlankProperties.kt +++ b/common/src/main/kotlin/flank/common/config/FlankProperties.kt @@ -5,14 +5,14 @@ import flank.common.isCI import java.nio.file.Paths import java.util.Properties -const val ZENHUB_REPO_ID = "zenhub.repo-id" -const val FLANK_REPO = "repo.flank" -const val GCLOUD_REPO = "repo.gcloud_cli" -const val ARTIFACTS_REPO = "repo.test-artifacts" -const val IT_WORKFLOW_FILE = "integration.workflow-filename" -const val IT_USER = "integration.issue-poster" -const val SDK_WORKFLOW = "sdk-check.workflow-filename" -const val SDK_USER = "sdk-check.issue-poster" +private const val ZENHUB_REPO_ID = "zenhub.repo-id" +private const val FLANK_REPO = "repo.flank" +private const val GCLOUD_REPO = "repo.gcloud_cli" +private const val ARTIFACTS_REPO = "repo.test-artifacts" +private const val IT_WORKFLOW_FILE = "integration.workflow-filename" +private const val IT_USER = "integration.issue-poster" +private const val SDK_WORKFLOW = "sdk-check.workflow-filename" +private const val SDK_USER = "sdk-check.issue-poster" private val defaults = Properties().apply { setProperty(ZENHUB_REPO_ID, "84221974") @@ -34,10 +34,19 @@ class SafeProperties(defaults: Properties) : Properties(defaults) { // default properties should be used in CI and during tests private fun shouldUseDefaults() = isCI() || isTest() -private fun isTest() = System.getProperty("testScript") != null +private fun isTest() = System.getProperty("useDefaultProperties") != null -val flankProjectProperties = SafeProperties(defaults).also { prop -> +private val props = SafeProperties(defaults).also { prop -> with(Paths.get("$flankCommonRootPathString/flank-debug.properties").toFile()) { if (exists()) prop.load(inputStream()) } } + +val zenhubRepositoryID = Integer.parseInt(props[ZENHUB_REPO_ID]) +val flankRepository = props[FLANK_REPO] +val flankGcloudCLIRepository = props[GCLOUD_REPO] +val flankTestArtifactsRepository = props[ARTIFACTS_REPO] +val integrationOpenedIssueUser = props[IT_USER] +val updatesOpenedUser = props[SDK_USER] +val fullSuiteWorkflowFilename = props[IT_WORKFLOW_FILE] +val updateDependenciesWorkflowFilename = props[SDK_WORKFLOW] diff --git a/flank-scripts/build.gradle.kts b/flank-scripts/build.gradle.kts index 75cbc48e56..8b53535cc4 100644 --- a/flank-scripts/build.gradle.kts +++ b/flank-scripts/build.gradle.kts @@ -99,7 +99,6 @@ publishing { tasks.test { maxHeapSize = "2048m" minHeapSize = "512m" - systemProperty("testScript", "") } repositories { diff --git a/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt b/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt deleted file mode 100644 index 182286795b..0000000000 --- a/flank-scripts/src/main/kotlin/flank/scripts/config/FlankScriptsConfigs.kt +++ /dev/null @@ -1,22 +0,0 @@ -package flank.scripts.config - -import flank.common.config.ARTIFACTS_REPO -import flank.common.config.FLANK_REPO -import flank.common.config.GCLOUD_REPO -import flank.common.config.IT_USER -import flank.common.config.IT_WORKFLOW_FILE -import flank.common.config.SDK_USER -import flank.common.config.SDK_WORKFLOW -import flank.common.config.ZENHUB_REPO_ID -import flank.common.config.flankProjectProperties - -private val props = flankProjectProperties - -val zenhubRepositoryID = Integer.parseInt(props[ZENHUB_REPO_ID]) -val flankRepository = props[FLANK_REPO] -val flankGcloudCLIRepository = props[GCLOUD_REPO] -val flankTestArtifactsRepository = props[ARTIFACTS_REPO] -val integrationOpenedIssueUser = props[IT_USER] -val updatesOpenedUser = props[SDK_USER] -val fullSuiteWorkflowFilename = props[IT_WORKFLOW_FILE] -val updateDependenciesWorkflowFilename = props[SDK_WORKFLOW] diff --git a/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt b/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt index fb4f236c75..833e55de34 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/github/GithubApi.kt @@ -14,9 +14,9 @@ import com.jcabi.github.Release 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.config.flankRepository import flank.scripts.exceptions.mapClientErrorToGithubException import flank.scripts.github.objects.GitHubCommit import flank.scripts.github.objects.GitHubCommitListDeserializer diff --git a/flank-scripts/src/main/kotlin/flank/scripts/integration/IssueList.kt b/flank-scripts/src/main/kotlin/flank/scripts/integration/IssueList.kt index 90e1282108..be5f1b8003 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/integration/IssueList.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/integration/IssueList.kt @@ -2,7 +2,7 @@ package flank.scripts.integration import com.github.kittinunf.result.getOrElse import com.github.kittinunf.result.onError -import flank.scripts.config.integrationOpenedIssueUser +import flank.common.config.integrationOpenedIssueUser import flank.scripts.github.getGitHubIssueList suspend fun checkForOpenedITIssues(token: String): Int? = getGitHubIssueList( diff --git a/flank-scripts/src/main/kotlin/flank/scripts/integration/PrepareMessage.kt b/flank-scripts/src/main/kotlin/flank/scripts/integration/PrepareMessage.kt index a787387134..d76f0aefc1 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/integration/PrepareMessage.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/integration/PrepareMessage.kt @@ -1,6 +1,6 @@ package flank.scripts.integration -import flank.scripts.config.flankRepository +import flank.common.config.flankRepository import flank.scripts.github.objects.GithubPullRequest import java.time.Instant import java.time.LocalDateTime diff --git a/flank-scripts/src/main/kotlin/flank/scripts/integration/WorkflowSummary.kt b/flank-scripts/src/main/kotlin/flank/scripts/integration/WorkflowSummary.kt index fdbe80a379..7350ea4be0 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/integration/WorkflowSummary.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/integration/WorkflowSummary.kt @@ -1,6 +1,6 @@ package flank.scripts.integration -import flank.scripts.config.fullSuiteWorkflowFilename +import flank.common.config.fullSuiteWorkflowFilename import flank.scripts.github.commons.getLastWorkflowRunDate suspend fun getLastITWorkflowRunDate(token: String) = getLastWorkflowRunDate( diff --git a/flank-scripts/src/main/kotlin/flank/scripts/release/updatebugsnag/UpdateBugSnag.kt b/flank-scripts/src/main/kotlin/flank/scripts/release/updatebugsnag/UpdateBugSnag.kt index 903529a3f1..49ebbab51d 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/release/updatebugsnag/UpdateBugSnag.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/release/updatebugsnag/UpdateBugSnag.kt @@ -3,7 +3,7 @@ package flank.scripts.release.updatebugsnag import com.github.kittinunf.fuel.Fuel import com.github.kittinunf.fuel.core.extensions.jsonBody import com.github.kittinunf.fuel.coroutines.awaitResult -import flank.scripts.config.flankRepository +import flank.common.config.flankRepository import flank.scripts.exceptions.mapClientError import flank.scripts.exceptions.toBugsnagException import flank.scripts.utils.toJson 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 index 0a24f68781..bce2aff3c9 100644 --- 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 @@ -1,9 +1,9 @@ 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.config.flankGcloudCLIRepository import flank.scripts.utils.downloadSortJsonIfNeeded import flank.scripts.utils.runCommand import java.nio.file.Paths 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 index 239845b3fd..2c81f4bf84 100644 --- 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 @@ -4,9 +4,9 @@ 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.config.flankGcloudCLIRepository import flank.scripts.utils.parseToVersion import kotlinx.coroutines.runBlocking import java.nio.file.Paths diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CommitList.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CommitList.kt index 18474b6fab..cf3b666a06 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CommitList.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/CommitList.kt @@ -1,6 +1,6 @@ package flank.scripts.shell.firebase.sdk -import flank.scripts.config.flankGcloudCLIRepository +import flank.common.config.flankGcloudCLIRepository import flank.scripts.github.getGitHubCommitList import flank.scripts.github.objects.GitHubCommit import java.time.Instant diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/Extensions.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/Extensions.kt index f3deb12f9a..70ad8115b7 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/Extensions.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/Extensions.kt @@ -2,8 +2,8 @@ package flank.scripts.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.config.zenhubRepositoryID import flank.scripts.github.objects.GitHubCreateIssueRequest import flank.scripts.github.objects.GitHubCreateIssueResponse import flank.scripts.github.objects.GitHubUpdateIssueRequest diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/LastSDKUpdateRun.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/LastSDKUpdateRun.kt index 188aa6283b..ad5f5b31fc 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/LastSDKUpdateRun.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/LastSDKUpdateRun.kt @@ -1,6 +1,6 @@ package flank.scripts.shell.firebase.sdk -import flank.scripts.config.updateDependenciesWorkflowFilename +import flank.common.config.updateDependenciesWorkflowFilename import flank.scripts.github.commons.getLastWorkflowRunDate suspend fun getLastSDKUpdateRunDate(token: String) = getLastWorkflowRunDate( diff --git a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/OpenedUpdates.kt b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/OpenedUpdates.kt index ba10601d21..290bc21574 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/OpenedUpdates.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/shell/firebase/sdk/OpenedUpdates.kt @@ -2,7 +2,7 @@ package flank.scripts.shell.firebase.sdk import com.github.kittinunf.result.getOrElse import com.github.kittinunf.result.onError -import flank.scripts.config.updatesOpenedUser +import flank.common.config.updatesOpenedUser import flank.scripts.github.getGitHubIssueList suspend fun checkForOpenedUpdates(token: String) = getGitHubIssueList( diff --git a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/TestArtifactsRepo.kt b/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/TestArtifactsRepo.kt index 049e175e5d..f9c2da896c 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/TestArtifactsRepo.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/testartifacts/core/TestArtifactsRepo.kt @@ -1,7 +1,7 @@ package flank.scripts.testartifacts.core import com.jcabi.github.Repo -import flank.scripts.config.flankTestArtifactsRepository +import flank.common.config.flankTestArtifactsRepository import flank.scripts.github.githubRepo import flank.scripts.utils.getEnv diff --git a/flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubAPI.kt b/flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubAPI.kt index cbf79b666d..2e5a4faff6 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubAPI.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/zenhub/ZenHubAPI.kt @@ -7,7 +7,7 @@ import com.github.kittinunf.fuel.coroutines.awaitStringResult import com.github.kittinunf.result.getOrNull import com.github.kittinunf.result.onError import com.github.kittinunf.result.success -import flank.scripts.config.zenhubRepositoryID +import flank.common.config.zenhubRepositoryID import flank.scripts.utils.toJson import flank.scripts.zenhub.objects.ConvertToEpicRequest import flank.scripts.zenhub.objects.UpdateEpicRequest From 5ab298fe69f75f04e6346c5a60cedb0595e11e8a Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Thu, 7 Jan 2021 14:27:08 +0100 Subject: [PATCH 11/19] Add default properties file --- common/flank-debug.properties | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 common/flank-debug.properties diff --git a/common/flank-debug.properties b/common/flank-debug.properties new file mode 100644 index 0000000000..d4cde57fd8 --- /dev/null +++ b/common/flank-debug.properties @@ -0,0 +1,11 @@ +#zenhub.repo-id=84221974 +# +#repo.flank=Flank/flank +#repo.gcloud_cli=Flank/gcloud_cli +#repo.test-artifacts=Flank/test_artifacts +# +#integration.workflow-filename=full_suite_integration_tests.yml +#integration.issue-poster=github-actions[bot] +# +#sdk-check.workflow-filename=update_dependencies_and_client.yml +#sdk-check.issue-poster=github-actions[bot] From 2f64a674478aaa22f210396a2078a1cbcaba035b Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Thu, 7 Jan 2021 14:29:15 +0100 Subject: [PATCH 12/19] Make properties file ignored --- common/flank-debug.properties | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 common/flank-debug.properties diff --git a/common/flank-debug.properties b/common/flank-debug.properties deleted file mode 100644 index d4cde57fd8..0000000000 --- a/common/flank-debug.properties +++ /dev/null @@ -1,11 +0,0 @@ -#zenhub.repo-id=84221974 -# -#repo.flank=Flank/flank -#repo.gcloud_cli=Flank/gcloud_cli -#repo.test-artifacts=Flank/test_artifacts -# -#integration.workflow-filename=full_suite_integration_tests.yml -#integration.issue-poster=github-actions[bot] -# -#sdk-check.workflow-filename=update_dependencies_and_client.yml -#sdk-check.issue-poster=github-actions[bot] From 5f900b59e6e50a10acb84285260c95657c42dd0a Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Thu, 7 Jan 2021 14:55:43 +0100 Subject: [PATCH 13/19] Add feature to automatically create properties template --- common/build.gradle.kts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 5afd106b06..69c6fc1a09 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,4 +1,5 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile +import java.nio.file.Paths plugins { application @@ -39,3 +40,21 @@ val compileTestKotlin: KotlinCompile by tasks compileTestKotlin.kotlinOptions { jvmTarget = "1.8" } + +file("flank-debug.properties").run { + if (!exists() && System.getenv("CI") != null) writeText( + """ + #zenhub.repo-id=84221974 + # + #repo.flank=Flank/flank + #repo.gcloud_cli=Flank/gcloud_cli + #repo.test-artifacts=Flank/test_artifacts + # + #integration.workflow-filename=full_suite_integration_tests.yml + #integration.issue-poster=github-actions[bot] + # + #sdk-check.workflow-filename=update_dependencies_and_client.yml + #sdk-check.issue-poster=github-actions[bot] + """.trimIndent() + ) +} From 81d023919909994ba4676766123e0d1d5112eb7a Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Thu, 7 Jan 2021 14:57:25 +0100 Subject: [PATCH 14/19] Remove unused import --- common/build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 69c6fc1a09..261a13a08c 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,5 +1,4 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import java.nio.file.Paths plugins { application From 13eb2148224aca625b50e3edc7919f251b18a6ba Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Thu, 7 Jan 2021 15:00:13 +0100 Subject: [PATCH 15/19] Fix condition --- common/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 261a13a08c..82af1ac20f 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -41,7 +41,7 @@ compileTestKotlin.kotlinOptions { } file("flank-debug.properties").run { - if (!exists() && System.getenv("CI") != null) writeText( + if (!exists() && System.getenv("CI") == null) writeText( """ #zenhub.repo-id=84221974 # From faf11823e51e30701b7ed7bf8cf292188d0b605b Mon Sep 17 00:00:00 2001 From: piotradamczyk5 <65554637+piotradamczyk5@users.noreply.github.com> Date: Fri, 8 Jan 2021 18:11:16 +0100 Subject: [PATCH 16/19] flank-scripts version update --- flank-scripts/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flank-scripts/build.gradle.kts b/flank-scripts/build.gradle.kts index 8b53535cc4..f198f3653b 100644 --- a/flank-scripts/build.gradle.kts +++ b/flank-scripts/build.gradle.kts @@ -28,7 +28,7 @@ shadowJar.apply { } } // .. -version = "1.3.4" +version = "1.4.0" group = "com.github.flank" application { From a53a60d183194e57321d05bef829af1073cc7f4c Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Mon, 11 Jan 2021 07:35:02 +0100 Subject: [PATCH 17/19] Refactor --- common/src/main/kotlin/flank/common/config/FlankProperties.kt | 4 ++-- flank-scripts/build.gradle.kts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/main/kotlin/flank/common/config/FlankProperties.kt b/common/src/main/kotlin/flank/common/config/FlankProperties.kt index 996c96d039..4a68568e79 100644 --- a/common/src/main/kotlin/flank/common/config/FlankProperties.kt +++ b/common/src/main/kotlin/flank/common/config/FlankProperties.kt @@ -19,9 +19,9 @@ private val defaults = Properties().apply { setProperty(FLANK_REPO, "Flank/flank") setProperty(GCLOUD_REPO, "Flank/gcloud_cli") setProperty(ARTIFACTS_REPO, "Flank/test_artifacts") - setProperty(IT_WORKFLOW_FILE, "full_suite_integration_tests.yml") + setProperty(IT_WORKFLOW_FILE, "integration_tests_pointer.yml") setProperty(IT_USER, "github-actions[bot]") - setProperty(SDK_WORKFLOW, "update_dependencies_and_client.yml") + setProperty(SDK_WORKFLOW, "update_dependencies_pointer.yml") setProperty(SDK_USER, "github-actions[bot]") } diff --git a/flank-scripts/build.gradle.kts b/flank-scripts/build.gradle.kts index f198f3653b..33c8250f7c 100644 --- a/flank-scripts/build.gradle.kts +++ b/flank-scripts/build.gradle.kts @@ -28,7 +28,7 @@ shadowJar.apply { } } // .. -version = "1.4.0" +version = "1.5.0" group = "com.github.flank" application { From 1fcde061afb7032557f8b8822a057e40f08684be Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Mon, 11 Jan 2021 07:43:55 +0100 Subject: [PATCH 18/19] Update gradle file in common --- common/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 82af1ac20f..d5827a2931 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -49,10 +49,10 @@ file("flank-debug.properties").run { #repo.gcloud_cli=Flank/gcloud_cli #repo.test-artifacts=Flank/test_artifacts # - #integration.workflow-filename=full_suite_integration_tests.yml + #integration.workflow-filename=integration_tests_pointer.yml #integration.issue-poster=github-actions[bot] # - #sdk-check.workflow-filename=update_dependencies_and_client.yml + #sdk-check.workflow-filename=update_dependencies_pointer.yml #sdk-check.issue-poster=github-actions[bot] """.trimIndent() ) From a1e160de0ceaa074cc6d40eae325673f2c9008de Mon Sep 17 00:00:00 2001 From: Pawel Pasterz Date: Mon, 11 Jan 2021 07:56:59 +0100 Subject: [PATCH 19/19] Change version --- flank-scripts/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flank-scripts/build.gradle.kts b/flank-scripts/build.gradle.kts index 33c8250f7c..f198f3653b 100644 --- a/flank-scripts/build.gradle.kts +++ b/flank-scripts/build.gradle.kts @@ -28,7 +28,7 @@ shadowJar.apply { } } // .. -version = "1.5.0" +version = "1.4.0" group = "com.github.flank" application {