From 2fbb5a2122499a2539ba379f63256ed78abb6059 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Thu, 4 Dec 2025 19:41:40 +0000 Subject: [PATCH 1/2] Bump local dependencies --- .../kotlin/io/spine/dependency/local/Compiler.kt | 14 +++++++------- .../io/spine/dependency/local/CoreJvmCompiler.kt | 4 ++-- .../kotlin/io/spine/dependency/local/Validation.kt | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt index 433e5c95..f0ad0be5 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/Compiler.kt @@ -29,7 +29,7 @@ package io.spine.dependency.local /** * Dependencies on the Spine Compiler modules. * - * To use a locally published ProtoData version instead of the version from a public plugin + * To use a locally published Compiler version instead of the version from a public plugin * registry, set the `COMPILER_VERSION` and/or the `COMPILER_DF_VERSION` environment variables * and stop the Gradle daemons so that Gradle observes the env change: * ``` @@ -67,22 +67,22 @@ object Compiler { const val module = "io.spine.tools:compiler" /** - * The version of ProtoData dependencies. + * The version of the Compiler dependencies. */ val version: String - private const val fallbackVersion = "2.0.0-SNAPSHOT.030" + private const val fallbackVersion = "2.0.0-SNAPSHOT.034" /** - * The distinct version of ProtoData used by other build tools. + * The distinct version of the Compiler used by other build tools. * - * When ProtoData is used both for building the project and as a part of the Project's - * transitional dependencies, this is the version used to build the project itself. + * When the Compiler is used both for building the project and as a part of the Project's + * transitive dependencies, this is the version used to build the project itself. */ val dogfoodingVersion: String private const val fallbackDfVersion = "2.0.0-SNAPSHOT.030" /** - * The artifact for the ProtoData Gradle plugin. + * The artifact for the Compiler Gradle plugin. */ val pluginLib: String diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt index a003f7c2..c96d774b 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/CoreJvmCompiler.kt @@ -46,12 +46,12 @@ object CoreJvmCompiler { /** * The version used to in the build classpath. */ - const val dogfoodingVersion = "2.0.0-SNAPSHOT.034" + const val dogfoodingVersion = "2.0.0-SNAPSHOT.035" /** * The version to be used for integration tests. */ - const val version = "2.0.0-SNAPSHOT.034" + const val version = "2.0.0-SNAPSHOT.035" /** * The ID of the Gradle plugin. diff --git a/buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt b/buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt index ff8aee46..7314d125 100644 --- a/buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt +++ b/buildSrc/src/main/kotlin/io/spine/dependency/local/Validation.kt @@ -36,7 +36,7 @@ object Validation { /** * The version of the Validation library artifacts. */ - const val version = "2.0.0-SNAPSHOT.354" + const val version = "2.0.0-SNAPSHOT.360" /** * The last version of Validation compatible with ProtoData. From 038f27abb420a380b4fbb78d0c95a4156b657132 Mon Sep 17 00:00:00 2001 From: alexander-yevsyukov Date: Thu, 4 Dec 2025 19:42:50 +0000 Subject: [PATCH 2/2] Push to `gh-pages` using retries --- .../kotlin/io/spine/gradle/git/Repository.kt | 48 ++++++++++++++++++- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/io/spine/gradle/git/Repository.kt b/buildSrc/src/main/kotlin/io/spine/gradle/git/Repository.kt index de41ee8b..dcf7b565 100644 --- a/buildSrc/src/main/kotlin/io/spine/gradle/git/Repository.kt +++ b/buildSrc/src/main/kotlin/io/spine/gradle/git/Repository.kt @@ -26,8 +26,10 @@ package io.spine.gradle.git +import com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly import io.spine.gradle.Cli import io.spine.gradle.fs.LazyTempPath +import java.util.concurrent.TimeUnit.MILLISECONDS import org.gradle.api.logging.Logger /** @@ -133,8 +135,10 @@ class Repository private constructor( * Performs a pull with rebase before pushing to ensure the local branch is up-to-date. */ fun push() { - repoExecute("git", "pull", "--rebase") - repoExecute("git", "push") + withRetries(description = "Pushing to $sshUrl, branch = '$currentBranch'") { + repoExecute("git", "pull", "--rebase") + repoExecute("git", "push") + } } override fun close() { @@ -174,3 +178,43 @@ class Repository private constructor( } } } + +/** + * Executes a given operation with retries using exponential backoff strategy. + * + * If the operation fails, it will be retried up to the specified number of times + * with increasing delays between attempts. + * The delay increases exponentially but is capped at the specified maximum value. + * + * If all retries fail, the exception from the final attempt will be thrown to the caller. + * + * @param T the type of value returned by the operation + * @param times the maximum number of attempts to execute the operation (default: 3) + * @param initialDelay the delay before the first retry in milliseconds (default: 100ms) + * @param maxDelay the maximum delay between retries in milliseconds (default: 2000ms) + * @param factor the multiplier used to increase delay after each failure (default: 2.0) + * @param description a description of the operation for error reporting (default: empty string) + * @param block the operation to execute + * @return the result of the successful operation execution + */ +private fun withRetries( + times: Int = 3, + initialDelay: Long = 100, // ms + maxDelay: Long = 2000, // ms + factor: Double = 2.0, + description: String = "", + block: () -> T +): T { + var currentDelay = initialDelay + repeat(times - 1) { + try { + return block() + } catch (e: Exception) { + System.err.println("'$description' failed. " + + "Message: '${e.message}'. Retrying in $currentDelay ms.") + } + sleepUninterruptibly(currentDelay, MILLISECONDS) + currentDelay = (currentDelay * factor).toLong().coerceAtMost(maxDelay) + } + return block() +}