From 5b11be618a6f94cc95e9397afcd1134162bb4552 Mon Sep 17 00:00:00 2001 From: Akash Yadav Date: Thu, 13 Apr 2023 00:28:53 +0530 Subject: [PATCH] chore(workflow): fix: provide dummy version name for test jobs --- .github/workflows/build.yml | 4 +++- build-logic/ide/src/main/java/CI.kt | 5 ++++- build.gradle.kts | 14 ++++++++++---- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1a7a87163..0cf0d0123 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -110,6 +110,7 @@ jobs: - name: Run debug tests run: ./gradlew testDebug --continue env: + ANDROIDIDE_TEST: true IDE_SIGNING_ALIAS: ${{ secrets.IDE_SIGNING_ALIAS }} IDE_SIGNING_AUTH_PASS: ${{ secrets.IDE_SIGNING_AUTH_PASS }} IDE_SIGNING_AUTH_USER: ${{ secrets.IDE_SIGNING_AUTH_USER }} @@ -148,6 +149,7 @@ jobs: - name: Run Tooling API tests run: ./gradlew clean :subprojects:tooling-api-impl:build env: + ANDROIDIDE_TEST: true TEST_TOOLING_API_IMPL: "true" IDE_SIGNING_ALIAS: ${{ secrets.IDE_SIGNING_ALIAS }} IDE_SIGNING_AUTH_PASS: ${{ secrets.IDE_SIGNING_AUTH_PASS }} @@ -231,4 +233,4 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - name: Publish release - run: ./gradlew publishAllPublicationsToMavenCentralRepository --stacktrace \ No newline at end of file + run: ./gradlew publishAllPublicationsToMavenCentralRepository --stacktrace diff --git a/build-logic/ide/src/main/java/CI.kt b/build-logic/ide/src/main/java/CI.kt index ba9054bcc..2080766b0 100644 --- a/build-logic/ide/src/main/java/CI.kt +++ b/build-logic/ide/src/main/java/CI.kt @@ -15,8 +15,8 @@ * along with AndroidIDE. If not, see . */ -import org.gradle.kotlin.dsl.provideDelegate import java.io.File +import org.gradle.kotlin.dsl.provideDelegate /** * Information about the CI build. @@ -39,6 +39,9 @@ object CI { /** Whether the current build is a CI build. */ val isCiBuild by lazy { "true" == System.getenv("CI") } + /** Whether the current build is for tests. This is set ONLY in CI builds. */ + val isTestEnv by lazy { "true" == System.getenv("ANDROIDIDE_TEST") } + private fun shortSha(sha: String): String { return ProcessBuilder("git", "rev-parse", "--short", sha) .directory(File(".")) diff --git a/build.gradle.kts b/build.gradle.kts index bf76dafd1..3e2b0f881 100755 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -51,9 +51,15 @@ val Project.simpleVersionName: String by lazy { return@lazy regex.find(version)?.value?.substring(1)?.also { logger.warn("Simple version name is '$it' (from version $version)") } - ?: throw IllegalStateException( - "Invalid version string '$version'. Version names must be SEMVER with 'v' prefix" - ) + ?: run { + if (CI.isTestEnv) { + return@run "1.0.0-beta" + } + + throw IllegalStateException( + "Cannot extract simple version name. Invalid version string '$version'. Version names must be SEMVER with 'v' prefix" + ) + } } val Project.projectVersionCode: Int by lazy { @@ -64,7 +70,7 @@ val Project.projectVersionCode: Int by lazy { logger.warn("Version code is '$it' (from version ${version}).") } ?: throw IllegalStateException( - "Invalid version string '$version'. Version names must be SEMVER with 'v' prefix" + "Cannot extract version code. Invalid version string '$version'. Version names must be SEMVER with 'v' prefix" ) }