diff --git a/cloudformation-template/unity-mc.main.template.yaml b/cloudformation-template/unity-mc.main.template.yaml index a45bb5f3..00df32ae 100644 --- a/cloudformation-template/unity-mc.main.template.yaml +++ b/cloudformation-template/unity-mc.main.template.yaml @@ -15,6 +15,7 @@ Metadata: - Venue - GithubToken - MCVersion + - MCSha - Label: default: Network configuration Parameters: @@ -52,6 +53,8 @@ Metadata: default: Github token with repo:read access. MCVersion: default: latest + MCSha: + default: "" Venue: default: Name of the venue being setup Project: @@ -113,6 +116,12 @@ Parameters: Default: latest ConstraintDescription: The version of unity-sds/unity-management-console to install. + MCSha: + Description: Management Console Sha + Type: String + Default: "" + ConstraintDescription: A commit sha to build the Management Console from. + Venue: Description: e.g. Dev, Test, Ops. See https://unity-sds.gitbook.io/docs/architecture/deployments-projects-and-venues Type: String @@ -464,10 +473,36 @@ Resources: commands: 01_install_management_console: command: !Sub | - set -ex \ - && echo "running 01_install_management_console" \ - && { if [ "${MCVersion}" = "latest" ]; then sudo -i -u ubuntu wget -q -O managementconsole.zip "https://github.com/unity-sds/unity-management-console/releases/latest/download/managementconsole.zip"; else sudo -i -u ubuntu wget -q -O managementconsole.zip "https://github.com/unity-sds/unity-management-console/releases/download/${MCVersion}/managementconsole.zip" ; fi } \ - && sudo -i -u ubuntu unzip managementconsole.zip + #!/bin/bash + sudo -u ubuntu bash << 'EOFMC' + set -ex + echo "running 01_install_management_console" + echo "requested sha: ${MCSha}" + if [ "${MCSha}" != "" ]; then + git clone https://github.com/unity-sds/unity-management-console.git + cd unity-management-console + git checkout ${MCSha} + cd /home/ubuntu/ + wget https://go.dev/dl/go1.20.14.linux-amd64.tar.gz + tar xfvz go1.20.14.linux-amd64.tar.gz + export GOROOT=$(pwd)/go + export GOPATH=$(pwd)/go/bin + export PATH=$(pwd)/go/bin:$PATH + cd /home/ubuntu/unity-management-console + npm ci + git clone https://github.com/unity-sds/unity-cs-infra.git workflowresources + sudo apt-get install -y zip + npm run package && npm run build-integration + cd /home/ubuntu + unzip unity-management-console/managementconsole.zip + elif [ "${MCVersion}" = "latest" ]; then + wget -q -O managementconsole.zip "https://github.com/unity-sds/unity-management-console/releases/latest/download/managementconsole.zip" + unzip managementconsole.zip + else + wget -q -O managementconsole.zip "https://github.com/unity-sds/unity-management-console/releases/download/${MCVersion}/managementconsole.zip" + unzip managementconsole.zip + fi + EOFMC cwd: /home/ubuntu 02_install_service: command: !Sub | diff --git a/nightly_tests/deploy.sh b/nightly_tests/deploy.sh index ddfc28ff..a53d775c 100644 --- a/nightly_tests/deploy.sh +++ b/nightly_tests/deploy.sh @@ -4,11 +4,12 @@ STACK_NAME="" PROJECT_NAME="" VENUE_NAME="" MC_VERSION="latest" +MC_SHA="" CONFIG_FILE="" # Function to display usage instructions usage() { - echo "Usage: $0 --stack-name --project-name --venue-name [--mc-version ] [--config-file ]" + echo "Usage: $0 --stack-name --project-name --venue-name [--mc-version ] [--mc-sha ] [--config-file ]" exit 1 } @@ -38,6 +39,10 @@ while [[ $# -gt 0 ]]; do MC_VERSION="$2" shift 2 ;; + --mc-sha) + MC_SHA="$2" + shift 2 + ;; --config-file) CONFIG_FILE="$2" shift 2 @@ -62,6 +67,7 @@ fi echo "deploy.sh :: STACK_NAME: ${STACK_NAME}" echo "deploy.sh :: PROJECT_NAME: ${PROJECT_NAME}" echo "deploy.sh :: VENUE_NAME: ${VENUE_NAME}" +echo "deploy.sh :: MC_SHA: ${MC_SHA}" # # Create the SSM parameters required by this deployment @@ -122,6 +128,7 @@ aws cloudformation create-stack \ ParameterKey=Project,ParameterValue=${PROJECT_NAME} \ ParameterKey=Venue,ParameterValue=${VENUE_NAME} \ ParameterKey=MCVersion,ParameterValue=${MC_VERSION} \ + ParameterKey=MCSha,ParameterValue=${MC_SHA} \ ParameterKey=MarketplaceItems,ParameterValue="${escaped_config_content}" \ --tags Key=ServiceArea,Value=U-CS diff --git a/nightly_tests/run.sh b/nightly_tests/run.sh index 982aed9f..83ffdd63 100755 --- a/nightly_tests/run.sh +++ b/nightly_tests/run.sh @@ -6,10 +6,11 @@ PROJECT_NAME="" VENUE_NAME="" MC_VERSION="latest" DEPLOYMENT_START_TIME=$(date +%s) +MC_SHA="" CONFIG_FILE="marketplace_config.yaml" # Set default config file # Function to display usage instructions usage() { - echo "Usage: $0 --destroy --run-tests --project-name --venue-name [--mc-version ] [--config-file ]" + echo "Usage: $0 --destroy --run-tests --project-name --venue-name [--mc-version ] [--mc-sha ] [--config-file ]" exit 1 } @@ -62,6 +63,10 @@ while [[ $# -gt 0 ]]; do CONFIG_FILE="$2" shift 2 ;; + --mc-sha) + MC_SHA="$2" + shift 2 + ;; *) echo "Invalid option: $1" >&2 exit 1 @@ -135,10 +140,12 @@ echo " - Run tests? $RUN_TESTS" echo " - Project Name: $PROJECT_NAME" echo " - Venue Name: $VENUE_NAME" echo " - MC Version: $MC_VERSION" +echo " - MC SHA: $MC_SHA" echo " - Config File: $CONFIG_FILE" echo "---------------------------------------------------------" +export MC_SHA="${MC_SHA}" export STACK_NAME="unity-management-console-${PROJECT_NAME}-${VENUE_NAME}" export GH_BRANCH=main TODAYS_DATE=$(date '+%F_%H-%M') @@ -198,6 +205,7 @@ mkdir -p ${LOG_DIR} NIGHTLY_HASH=$(git rev-parse --short HEAD) echo "Repo Hash (Nightly Test): [$NIGHTLY_HASH]" >> nightly_output.txt echo "Repo Hash (Nightly Test): [$NIGHTLY_HASH]" +echo "Management Console SHA: [$MC_SHA]" ## update self (unity-cs-infra repository) git pull origin ${GH_BRANCH} @@ -206,7 +214,7 @@ git checkout ${GH_BRANCH} # # Deploy the Management Console using CloudFormation # -bash deploy.sh --stack-name "${STACK_NAME}" --project-name "${PROJECT_NAME}" --venue-name "${VENUE_NAME}" --mc-version "${MC_VERSION}" --config-file "$CONFIG_FILE" +bash deploy.sh --stack-name "${STACK_NAME}" --project-name "${PROJECT_NAME}" --venue-name "${VENUE_NAME}" --mc-version "${MC_VERSION}" --config-file "$CONFIG_FILE" --mc-sha "$MC_SHA" echo "Deploying Management Console..." >> nightly_output.txt echo "Deploying Management Console..."