From 4ab1b7d0d47ed46946533be20bc42d6a08e9adf8 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 9 May 2023 19:28:38 +0300 Subject: [PATCH] update space automation --- .gitignore | 1 + .space.kts | 49 ++++++++++++++++++++++++++++++++++++++++++-- test-utils/README.md | 4 ++++ 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 test-utils/README.md diff --git a/.gitignore b/.gitignore index 7713a9f96..96a556ae1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ out/ .idea/ .vscode/ +.fleet/ # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) diff --git a/.space.kts b/.space.kts index e4d7522e3..ce52a2f5c 100644 --- a/.space.kts +++ b/.space.kts @@ -1,3 +1,48 @@ -job("Build and run tests") { - gradlew("amazoncorretto:17-alpine", "build") +import kotlin.io.path.readText + +val projectName = "kmath" + +job("Build") { + //Perform only jvm tests + gradlew("spc.registry.jetbrains.space/p/sci/containers/kotlin-ci:1.0.3", "test", "jvmTest") +} + +job("Publish") { + startOn { + gitPush { enabled = false } + } + container("spc.registry.jetbrains.space/p/sci/containers/kotlin-ci:1.0.3") { + env["SPACE_USER"] = "{{ project:space_user }}" + env["SPACE_TOKEN"] = "{{ project:space_token }}" + kotlinScript { api -> + + val spaceUser = System.getenv("SPACE_USER") + val spaceToken = System.getenv("SPACE_TOKEN") + + // write the version to the build directory + api.gradlew("version") + + //read the version from build file + val version = java.nio.file.Path.of("build/project-version.txt").readText() + + val revisionSuffix = if (version.endsWith("SNAPSHOT")) { + "-" + api.gitRevision().take(7) + } else { + "" + } + + api.space().projects.automation.deployments.start( + project = api.projectIdentifier(), + targetIdentifier = TargetIdentifier.Key(projectName), + version = version+revisionSuffix, + // automatically update deployment status based on the status of a job + syncWithAutomationJob = true + ) + api.gradlew( + "publishAllPublicationsToSpaceRepository", + "-Ppublishing.space.user=\"$spaceUser\"", + "-Ppublishing.space.token=\"$spaceToken\"", + ) + } + } } \ No newline at end of file diff --git a/test-utils/README.md b/test-utils/README.md new file mode 100644 index 000000000..6ff8b98e8 --- /dev/null +++ b/test-utils/README.md @@ -0,0 +1,4 @@ +# Module test-utils + + +