diff --git a/.github/workflows/reusable_e2e.yaml b/.github/workflows/reusable_e2e.yaml index 8b3c22e0..c92bfe1b 100644 --- a/.github/workflows/reusable_e2e.yaml +++ b/.github/workflows/reusable_e2e.yaml @@ -74,7 +74,7 @@ jobs: if: ${{ inputs.mirrord_release_branch }} run: | chmod u+x mirrord - echo "${GITHUB_WORKSPACE}" >> "$GITHUB_PATH" + echo "${GITHUB_WORKSPACE}" >> $GITHUB_PATH - name: get the latest mirrord binary if: ${{ !inputs.mirrord_release_branch }} @@ -112,7 +112,8 @@ jobs: ./gradlew test - name: Save the failure video - if: ${{ failure() }} + continue-on-error: true + if: ${{ always() }} run: | mv video build/reports - name: Save fails report diff --git a/changelog.d/+auto-update-and-ci.internal.md b/changelog.d/+auto-update-and-ci.internal.md new file mode 100644 index 00000000..ba09f1a8 --- /dev/null +++ b/changelog.d/+auto-update-and-ci.internal.md @@ -0,0 +1 @@ +Remove quotes around GITHUB_PATH in e2e and add "CI_BUILD_PLUGIN" check to e2e for releases diff --git a/changelog.d/+provide-video.internal.md b/changelog.d/+provide-video.internal.md new file mode 100644 index 00000000..c9035aab --- /dev/null +++ b/changelog.d/+provide-video.internal.md @@ -0,0 +1 @@ +Always provide video for CI run diff --git a/modules/core/src/main/kotlin/com/metalbear/mirrord/MirrordBinaryManager.kt b/modules/core/src/main/kotlin/com/metalbear/mirrord/MirrordBinaryManager.kt index 4515b7dc..e5e95ad7 100644 --- a/modules/core/src/main/kotlin/com/metalbear/mirrord/MirrordBinaryManager.kt +++ b/modules/core/src/main/kotlin/com/metalbear/mirrord/MirrordBinaryManager.kt @@ -1,5 +1,6 @@ package com.metalbear.mirrord +import com.github.zafarkhaja.semver.Version import com.intellij.execution.wsl.WSLDistribution import com.intellij.notification.NotificationType import com.intellij.openapi.components.Service @@ -35,6 +36,7 @@ private const val DOWNLOAD_ENDPOINT = "https://github.com/metalbear-co/mirrord/r class MirrordBinaryManager { @Volatile private var latestSupportedVersion: String? = null + private var downloadVersion: String? = null /** * Schedules the update task at project startup. @@ -78,13 +80,14 @@ class MirrordBinaryManager { val autoUpdate = MirrordSettingsState.instance.mirrordState.autoUpdate val userSelectedMirrordVersion = MirrordSettingsState.instance.mirrordState.mirrordVersion + manager.latestSupportedVersion = manager.fetchLatestSupportedVersion(product, indicator) val version = when { // auto update -> false -> use mirrordVersion if it's not empty - !autoUpdate && userSelectedMirrordVersion.isNotEmpty() -> { - if (checkVersionFormat(userSelectedMirrordVersion)) { - userSelectedMirrordVersion - } else { + !autoUpdate && (userSelectedMirrordVersion.isNotEmpty()) -> { + try { + Version.valueOf(userSelectedMirrordVersion) + } catch (e: Exception) { project .service() .notifier @@ -92,13 +95,14 @@ class MirrordBinaryManager { .fire() return } + userSelectedMirrordVersion } // auto update -> false -> mirrordVersion is empty -> needs check in the path // if not in path -> fetch latest version !autoUpdate && userSelectedMirrordVersion.isEmpty() -> null // auto update -> true -> fetch latest version - else -> manager.fetchLatestSupportedVersion(product, indicator) + else -> manager.latestSupportedVersion } val local = if (checkInPath) { @@ -111,9 +115,9 @@ class MirrordBinaryManager { return } - manager.latestSupportedVersion = version - // auto update -> false -> mirrordVersion is empty -> no cli found locally -> fetch latest version - ?: manager.fetchLatestSupportedVersion(product, indicator) + manager.downloadVersion = version + // auto update -> false -> mirrordVersion is empty -> no cli found locally -> latest version + ?: manager.latestSupportedVersion if (downloadInProgress.compareAndExchange(false, true)) { return @@ -148,14 +152,6 @@ class MirrordBinaryManager { ) } } - - /** - * checks if the passed version string matches *.*.* format (numbers only) - * @param version version string to check - * */ - fun checkVersionFormat(version: String): Boolean { - return version.matches(Regex("^[0-9]+\\.[0-9]+\\.[0-9]+$")) - } } private fun fetchLatestSupportedVersion(product: String?, indicator: ProgressIndicator): String { @@ -192,7 +188,7 @@ class MirrordBinaryManager { } private fun updateBinary(indicator: ProgressIndicator) { - val version = latestSupportedVersion ?: return + val version = downloadVersion ?: return val url = if (SystemInfo.isMac) { "$DOWNLOAD_ENDPOINT/$version/mirrord_mac_universal" @@ -283,7 +279,19 @@ class MirrordBinaryManager { } val binary = MirrordBinary(output, wslDistribution) - if (requiredVersion == null || requiredVersion == binary.version) { + + val isRequiredVersion = try { + // for release CI, the tag can be greater than the latest release + if (System.getenv("CI_BUILD_PLUGIN") == "true") { + Version.valueOf(binary.version).greaterThanOrEqualTo(Version.valueOf(requiredVersion)) + } else { + Version.valueOf(binary.version).equals(Version.valueOf(requiredVersion)) + } + } catch (e: Exception) { + MirrordLogger.logger.debug("failed to parse version", e) + false + } + if (requiredVersion == null || isRequiredVersion) { return binary } } catch (e: Exception) { @@ -300,14 +308,19 @@ class MirrordBinaryManager { try { MirrordPathManager.getBinary(CLI_BINARY, true)?.let { val binary = MirrordBinary(it, wslDistribution) - if (requiredVersion == null || requiredVersion == binary.version) { + val isRequiredVersion = try { + Version.valueOf(binary.version).equals(Version.valueOf(requiredVersion)) + } catch (e: Exception) { + MirrordLogger.logger.debug("failed to parse version", e) + false + } + if (requiredVersion == null || isRequiredVersion) { return binary } } } catch (e: Exception) { MirrordLogger.logger.debug("failed to find mirrord in plugin storage", e) } - return null }