From 22dc21db8880caada4befb4322add47015549cef Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Wed, 2 Apr 2025 19:51:42 +0100 Subject: [PATCH 1/3] Add ci parameter to install endpoints Co-Authored-By: Claude --- app/controllers/InstallController.scala | 8 +++++--- app/views/install_beta.scala.txt | 2 +- app/views/install_stable.scala.txt | 2 +- conf/routes | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controllers/InstallController.scala b/app/controllers/InstallController.scala index c47e635..5f18b2d 100644 --- a/app/controllers/InstallController.scala +++ b/app/controllers/InstallController.scala @@ -19,7 +19,7 @@ class InstallController @Inject() ( private val betaBaseUrlO = configUrl("service.betaBaseUrl") - def install(beta: Boolean, rcUpdate: Option[Boolean]) = Action.async { _ => + def install(beta: Boolean, rcUpdate: Option[Boolean], ci: Option[Boolean]) = Action.async { _ => appRepo.findApplication().map { maybeApp => val response = for { stableBaseUrl <- stableBaseUrlO @@ -37,7 +37,8 @@ class InstallController @Inject() ( cliNativeVersion = betaNativeVersion, baseUrl = betaBaseUrl, rcUpdate = rcUpdate.getOrElse(true), - beta = true + beta = true, + ci = ci.getOrElse(false) ) ) } else { @@ -47,7 +48,8 @@ class InstallController @Inject() ( cliNativeVersion = stableNativeVersion, baseUrl = stableBaseUrl, rcUpdate = rcUpdate.getOrElse(true), - beta = false + beta = false, + ci = ci.getOrElse(false) ) ) } diff --git a/app/views/install_beta.scala.txt b/app/views/install_beta.scala.txt index 118df71..b41975b 100644 --- a/app/views/install_beta.scala.txt +++ b/app/views/install_beta.scala.txt @@ -1,4 +1,4 @@ -@(cliVersion: String, cliNativeVersion: String, baseUrl: String, rcUpdate: Boolean, beta: Boolean)#!/bin/bash +@(cliVersion: String, cliNativeVersion: String, baseUrl: String, rcUpdate: Boolean, beta: Boolean, ci: Boolean)#!/bin/bash @includes.license() @includes.statusline("install", cliVersion, cliNativeVersion, baseUrl, beta) diff --git a/app/views/install_stable.scala.txt b/app/views/install_stable.scala.txt index 118df71..b41975b 100644 --- a/app/views/install_stable.scala.txt +++ b/app/views/install_stable.scala.txt @@ -1,4 +1,4 @@ -@(cliVersion: String, cliNativeVersion: String, baseUrl: String, rcUpdate: Boolean, beta: Boolean)#!/bin/bash +@(cliVersion: String, cliNativeVersion: String, baseUrl: String, rcUpdate: Boolean, beta: Boolean, ci: Boolean)#!/bin/bash @includes.license() @includes.statusline("install", cliVersion, cliNativeVersion, baseUrl, beta) diff --git a/conf/routes b/conf/routes index 83eecc7..1cb6a5f 100644 --- a/conf/routes +++ b/conf/routes @@ -3,8 +3,8 @@ # ~~~~ GET /alive controllers.HealthController.alive -GET /install/beta controllers.InstallController.install(beta: Boolean = true, rcupdate: Option[Boolean]) -GET /install/stable controllers.InstallController.install(beta: Boolean = false, rcupdate: Option[Boolean]) +GET /install/beta controllers.InstallController.install(beta: Boolean = true, rcupdate: Option[Boolean], ci: Option[Boolean]) +GET /install/stable controllers.InstallController.install(beta: Boolean = false, rcupdate: Option[Boolean], ci: Option[Boolean]) GET /selfupdate/beta/:platform controllers.SelfUpdateController.selfUpdate(beta: Boolean = true, platform) GET /selfupdate/beta controllers.SelfUpdateController.selfUpdate(beta: Boolean = true, platform = "unknown") GET /selfupdate/stable/:platform controllers.SelfUpdateController.selfUpdate(beta: Boolean ?= false, platform) From 9c532aaaeb568634529a7cc7b2139059def041c1 Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Wed, 2 Apr 2025 19:55:41 +0100 Subject: [PATCH 2/3] Run scalafmt --- test/steps/Steps.scala | 9 +++++++-- test/steps/support/Mongo.scala | 10 +++++++++- test/steps/support/World.scala | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/test/steps/Steps.scala b/test/steps/Steps.scala index 3cf4c3b..b6dfed4 100644 --- a/test/steps/Steps.scala +++ b/test/steps/Steps.scala @@ -26,11 +26,16 @@ class Steps extends ScalaDsl with EN with Matchers { And("""^the stable native CLI Version is "(.*)"""") { native: String => stableNativeCliVersion = native } - + And("""^the beta native CLI Version is "(.*)"""") { native: String => betaNativeCliVersion = native // Insert all CLI versions after both stable and beta native CLI versions are set - Mongo.insertCliVersions(stableCliVersion, betaCliVersion, stableNativeCliVersion, betaNativeCliVersion) + Mongo.insertCliVersions( + stableCliVersion, + betaCliVersion, + stableNativeCliVersion, + betaNativeCliVersion + ) } And("""^a request is made to the (.*) endpoint$""") { endpoint: String => diff --git a/test/steps/support/Mongo.scala b/test/steps/support/Mongo.scala index 4e5b5b5..7946e85 100644 --- a/test/steps/support/Mongo.scala +++ b/test/steps/support/Mongo.scala @@ -38,7 +38,15 @@ object Mongo { betaNativeCliVersion: String ): Seq[Completed] = appCollection - .insertOne(Application("OK", stableCliVersion, betaCliVersion, stableNativeCliVersion, betaNativeCliVersion)) + .insertOne( + Application( + "OK", + stableCliVersion, + betaCliVersion, + stableNativeCliVersion, + betaNativeCliVersion + ) + ) .results() def dropAppCollection(): Seq[Completed] = appCollection.drop().results() diff --git a/test/steps/support/World.scala b/test/steps/support/World.scala index 97ac33b..8355f25 100644 --- a/test/steps/support/World.scala +++ b/test/steps/support/World.scala @@ -15,6 +15,6 @@ object World { var betaCliVersion = "" var stableNativeCliVersion = "" - + var betaNativeCliVersion = "" } From 916ceda1072ddd02bcb2189147201fb4536961cb Mon Sep 17 00:00:00 2001 From: Marco Vermeulen Date: Wed, 2 Apr 2025 22:30:46 +0100 Subject: [PATCH 3/3] Add CI mode to beta installation template Co-Authored-By: Claude --- app/views/install_beta.scala.txt | 17 +++++++++++++++-- features/installation.feature | 14 +++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/views/install_beta.scala.txt b/app/views/install_beta.scala.txt index b41975b..e9c098a 100644 --- a/app/views/install_beta.scala.txt +++ b/app/views/install_beta.scala.txt @@ -68,22 +68,35 @@ echo "$SDKMAN_PLATFORM" > "$sdkman_platform_file" echo "Prime the config file..." touch "$sdkman_config_file" + +@if(ci) { +# CI mode - optimized for automated environments +echo "sdkman_auto_answer=true" >> "$sdkman_config_file" +echo "sdkman_colour_enable=false" >> "$sdkman_config_file" +echo "sdkman_selfupdate_feature=false" >> "$sdkman_config_file" +} else { +# Interactive mode - optimized for human use echo "sdkman_auto_answer=false" >> "$sdkman_config_file" +echo "sdkman_colour_enable=true" >> "$sdkman_config_file" +echo "sdkman_selfupdate_feature=true" >> "$sdkman_config_file" +} + +# Set shell-specific config if [ -z "$ZSH_VERSION" -a -z "$BASH_VERSION" ]; then echo "sdkman_auto_complete=false" >> "$sdkman_config_file" else echo "sdkman_auto_complete=true" >> "$sdkman_config_file" fi + +# Common settings that don't change based on CI mode echo "sdkman_auto_env=false" >> "$sdkman_config_file" echo "sdkman_beta_channel=@beta" >> "$sdkman_config_file" echo "sdkman_checksum_enable=true" >> "$sdkman_config_file" -echo "sdkman_colour_enable=true" >> "$sdkman_config_file" echo "sdkman_curl_connect_timeout=7" >> "$sdkman_config_file" echo "sdkman_curl_max_time=10" >> "$sdkman_config_file" echo "sdkman_debug_mode=false" >> "$sdkman_config_file" echo "sdkman_insecure_ssl=false" >> "$sdkman_config_file" echo "sdkman_native_enable=true" >> "$sdkman_config_file" -echo "sdkman_selfupdate_feature=true" >> "$sdkman_config_file" # script cli distribution echo "Installing script cli archive..." diff --git a/features/installation.feature b/features/installation.feature index f7eca00..36e73e6 100644 --- a/features/installation.feature +++ b/features/installation.feature @@ -55,4 +55,16 @@ Feature: Installation And a "text/plain; charset=UTF-8" content type is received And the response script contains "# install:- channel: beta" And the response script contains "Attempt update of interactive bash profile " - And the response script contains "Attempt update of zsh profile..."" + And the response script contains "Attempt update of zsh profile..." + + Scenario: Install SDKMAN beta in CI mode + When a request is made to the /install/beta?ci=true endpoint + Then a 200 status code is received + And a "text/plain; charset=UTF-8" content type is received + And the response script contains "# install:- channel: beta" + And the response script contains "sdkman_auto_answer=true" + And the response script contains "sdkman_colour_enable=false" + And the response script contains "sdkman_selfupdate_feature=false" + And the response script does not contain "sdkman_auto_answer=false" + And the response script does not contain "sdkman_colour_enable=true" + And the response script does not contain "sdkman_selfupdate_feature=true"