[skip ci] Added GraalVM installation to DevOps section, Test DevOpsKtTest/installGraalVM integration prooven

This commit is contained in:
Mirco 2024-07-29 19:48:09 +02:00
parent 1b7e2824ce
commit 4bd18fcdf8
2 changed files with 43 additions and 4 deletions

View file

@ -15,8 +15,37 @@ fun Prov.installDevOps() = task {
installTerraform() installTerraform()
installKubectlAndTools() installKubectlAndTools()
installYq() installYq()
installGraalVM()
} }
fun Prov.installGraalVM():ProvResult = task{
val version = "21.0.2"
val tmpDir = "~/tmp"
val filename = "graalvm-community-jdk-"
val additionalPartFilename = "_linux-x64_bin"
val packedFilename = "$filename$version$additionalPartFilename.tar.gz"
val extractedFilenameHunch = "graalvm-community-openjdk-"
val installationPath = "/usr/lib/jvm/"
if ( !chk("/usr/local/bin/native-image --version") || version != cmd("/usr/local/bin/native-image --version").out?.trim() || !chk("ls -d $installationPath$extractedFilenameHunch$version*")) {
downloadFromURL(
"https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-$version/$packedFilename",
path = tmpDir,
sha256sum = "b048069aaa3a99b84f5b957b162cc181a32a4330cbc35402766363c5be76ae48"
)
if (!chk("ls -d $installationPath"))
cmd("sudo mkdir $installationPath")
else {
ProvResult(true, out = "$installationPath just exists, mkdir not necessary.")
}
cmd("sudo tar -C $installationPath -xzf $packedFilename", tmpDir)
val graalInstPath = installationPath + (cmd("ls /usr/lib/jvm/|grep -e graalvm-community-openjdk-$version").out?.replace("\n", ""))
cmd("sudo ln -s $graalInstPath/lib/svm/bin/native-image /usr/local/bin/native-image")
cmd("/usr/local/bin/native-image --version")
} else {
ProvResult(true, out = "GraalVM $version already installed")
}
}
fun Prov.installYq( fun Prov.installYq(
version: String = "4.13.2", version: String = "4.13.2",

View file

@ -1,10 +1,7 @@
package org.domaindrivenarchitecture.provs.desktop.infrastructure package org.domaindrivenarchitecture.provs.desktop.infrastructure
import org.domaindrivenarchitecture.provs.framework.core.getResourceAsText import org.domaindrivenarchitecture.provs.framework.core.getResourceAsText
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.checkFile import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.*
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.createDir
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.createDirs
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.fileContainsText
import org.domaindrivenarchitecture.provs.test.defaultTestContainer import org.domaindrivenarchitecture.provs.test.defaultTestContainer
import org.domaindrivenarchitecture.provs.test.tags.ContainerTest import org.domaindrivenarchitecture.provs.test.tags.ContainerTest
import org.domaindrivenarchitecture.provs.test.tags.ExtensiveContainerTest import org.domaindrivenarchitecture.provs.test.tags.ExtensiveContainerTest
@ -62,4 +59,17 @@ internal class DevOpsKtTest {
assertTrue(res.success) assertTrue(res.success)
assertTrue(prov.checkFile("/usr/local/bin/kubeconform")) assertTrue(prov.checkFile("/usr/local/bin/kubeconform"))
} }
@ContainerTest
fun installGraalVM() {
// given
val prov = defaultTestContainer()
// when
val res = prov.installGraalVM()
// then
assertTrue(res.success)
assertTrue(prov.checkFile("/usr/local/bin/native-image"))
}
} }