From de7c1225b9a596246f42aa7a341616d527178c8e Mon Sep 17 00:00:00 2001 From: ansgarz Date: Fri, 16 Aug 2024 15:41:54 +0200 Subject: [PATCH] move VSCode installation from IDE desktop to office desktop --- .../provs/desktop/domain/DesktopService.kt | 6 +++-- .../provs/desktop/infrastructure/VSCode.kt | 24 +++++++++---------- .../desktop/infrastructure/VSCodeKtTest.kt | 18 +++++++++----- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopService.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopService.kt index b7b3327..948c8b2 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopService.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopService.kt @@ -137,7 +137,10 @@ fun Prov.provisionOfficeDesktop() { // installNextcloudClient() might not install - might need fix and working test aptInstall(COMPARE_TOOLS) - // optional, as installation of these tools often fail and as they are not considered mandatory + // VSCode is also required in office VM (not only in IDE desktop) e.g. as editor + installVSCode("python", "clojure") + + // optional, as installation of these tools often fail and as they are not mandatory optional { aptInstall(DRAWING_TOOLS) } @@ -159,7 +162,6 @@ fun Prov.provisionIdeDesktop() { installHugoByDeb() // IDEs - installVSC("python", "clojure") installIntelliJ() installKubeconform() diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/VSCode.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/VSCode.kt index 1b48fcc..7a3b22c 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/VSCode.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/VSCode.kt @@ -6,33 +6,33 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.aptInsta import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.isPackageInstalled -fun Prov.installVSC(vararg options: String) = task { +fun Prov.installVSCode(vararg options: String) = task { val clojureExtensions = setOf("betterthantomorrow.calva", "DavidAnson.vscode-markdownlint") val pythonExtensions = setOf("ms-python.python") - prerequisitesVSCinstall() + installVSCodePrerequisites() installVSCPackage() installVSCodiumPackage() if (options.contains("clojure")) { - installExtensionsCode(clojureExtensions) - installExtensionsCodium(clojureExtensions) + installVSCodeExtensions(clojureExtensions) + installVSCodiumExtensions(clojureExtensions) } if (options.contains("python")) { - installExtensionsCode(pythonExtensions) - installExtensionsCodium(pythonExtensions) + installVSCodeExtensions(pythonExtensions) + installVSCodiumExtensions(pythonExtensions) } } -private fun Prov.prerequisitesVSCinstall() = task { +private fun Prov.installVSCodePrerequisites() = task { aptInstall("curl gpg unzip apt-transport-https") } @Suppress("unused") // only required for installation of vscode via apt -private fun Prov.installVscWithApt() = task { +private fun Prov.installVSCodeWithApt() = task { val packageName = "code" if (!isPackageInstalled(packageName)) { // see https://code.visualstudio.com/docs/setup/linux @@ -62,7 +62,7 @@ private fun Prov.installVSCodiumPackage() = task { } -private fun Prov.installExtensionsCode(extensions: Set) = optional { +private fun Prov.installVSCodeExtensions(extensions: Set) = optional { var res = ProvResult(true) for (ext in extensions) { res = cmd("code --install-extension $ext") @@ -71,11 +71,11 @@ private fun Prov.installExtensionsCode(extensions: Set) = optional { // Settings can be found at $HOME/.config/Code/User/settings.json } -private fun Prov.installExtensionsCodium(extensions: Set) = optional { +private fun Prov.installVSCodiumExtensions(extensions: Set) = optional { var res = ProvResult(true) for (ext in extensions) { - res = cmd("codium --install-extension $ext") + res = ProvResult(res.success && cmd("codium --install-extension $ext").success) } res - // Settings can be found at $HOME/.config/Code/User/settings.json + // Settings can be found at $HOME/.config/VSCodium/User/settings.json } diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/VSCodeKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/VSCodeKtTest.kt index 1be0270..51747c3 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/VSCodeKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/VSCodeKtTest.kt @@ -1,7 +1,8 @@ package org.domaindrivenarchitecture.provs.desktop.infrastructure +import org.domaindrivenarchitecture.provs.framework.core.remote import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.aptInstall -import org.domaindrivenarchitecture.provs.test.defaultTestContainer +import org.domaindrivenarchitecture.provs.framework.ubuntu.secret.secretSources.PromptSecretSource import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -9,14 +10,19 @@ import org.junit.jupiter.api.Test internal class VSCodeKtTest { @Test - @Disabled("Test currently not working, needs fix. VSC is installed by snapd which is not currently supported to run inside docker") - fun installVSC() { + @Disabled("Remote testing by updating connection details below, then enable test and run it manually.") + // Remark: VSCode installs with snap, which does not run in container and cannot be tested by container test. + fun installVSCode() { // given - val a = defaultTestContainer() - a.aptInstall("xvfb libgbm-dev libasound2") + val prov = remote("192.168.56.153", "xx", PromptSecretSource("Remote password").secret()) // machine needs openssh-server installed and sudo possible without pw + prov.aptInstall("xvfb libgbm-dev libasound2") // when - val res = a.installVSC("python", "clojure") + val res = prov.task { + installVSCode("python", "clojure") + cmd("code -v") + cmd("codium -v") + } // then assertTrue(res.success)