From 59bd768e0a27d12fceaa86b4bd2d688b00fcf24f Mon Sep 17 00:00:00 2001 From: vmarcella Date: Thu, 28 Mar 2024 11:20:53 -0700 Subject: [PATCH 1/4] [add] script for installing docs separately from the innovation engine binary. --- scripts/install_docs_from_release.sh | 67 +++++++++++++++++++++++++++ scripts/install_from_release.sh | 68 ++++------------------------ 2 files changed, 75 insertions(+), 60 deletions(-) create mode 100644 scripts/install_docs_from_release.sh diff --git a/scripts/install_docs_from_release.sh b/scripts/install_docs_from_release.sh new file mode 100644 index 00000000..1c5fc575 --- /dev/null +++ b/scripts/install_docs_from_release.sh @@ -0,0 +1,67 @@ +# Script to install documentation from our upstream repository. + +set -e + +# TODO: make parameters mandatory +LANG="$1" +RELEASE="$2" + +# If no release is specified, download the latest release +if [ "$RELEASE" == "" ]; then + RELEASE="latest" +fi + +# Set a default scenarios file +SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/$RELEASE/scenarios.zip" + +# If the LANG parameter was set, download appropriate script +if [ "$LANG" != "" ]; then + # Map the language parameter to the corresponding scenarios file + # If no parameter, download the scenarios from IE + MAIN_LANG_PREFIX="$(echo "$LANG" | head -c2 | tr '[:upper:]' '[:lower:]')" + LANG_ARRAY=("de" "es" "fr" "it" "nl" "pt" "zh" "cs" "hu" "id" "ja" "ko" "pl" "pt" "ru" "sv" "tr") + + if [[ "${LANG_ARRAY[*]}" =~ "$MAIN_LANG_PREFIX" ]]; then + SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-$MAIN_LANG_PREFIX-scenarios.zip" + if [ "$MAIN_LANG_PREFIX" = "pt" ]; then + if [ "$LANG" = "pt-pt" ]; then + SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-pt-scenarios.zip" + elif [ "$LANG" = "pt-br" ]; then + SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-br-scenarios.zip" + else + SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-pt-scenarios.zip" + fi + fi + if [ "$MAIN_LANG_PREFIX" = "zh" ]; then + if [ "$LANG" = "zh-cn" ]; then + SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-cn-scenarios.zip" + elif [ "$LANG" = "zh-tw" ]; then + SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-tw-scenarios.zip" + else + SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-cn-scenarios.zip" + fi + fi + if [ "$MAIN_LANG_PREFIX" = "cs" ]; then + SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-cz-scenarios.zip" + fi + if [ "$MAIN_LANG_PREFIX" = "ja" ]; then + SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-jp-scenarios.zip" + fi + if [ "$MAIN_LANG_PREFIX" = "ko" ]; then + SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-kr-scenarios.zip" + fi + if [ "$MAIN_LANG_PREFIX" = "sv" ]; then + SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-se-scenarios.zip" + fi + fi +fi + +# Download the scenarios. +echo "Installing scenarios from the $RELEASE release..." +wget -q -O scenarios.zip "$SCENARIOS" >/dev/null + +# Unzip the scenarios, overwrite if they already exist. +unzip -o scenarios.zip -d ~ >/dev/null +rm scenarios.zip >/dev/null + +echo "Done." diff --git a/scripts/install_from_release.sh b/scripts/install_from_release.sh index a01bd495..234a5e72 100644 --- a/scripts/install_from_release.sh +++ b/scripts/install_from_release.sh @@ -1,77 +1,25 @@ # Script to install scenarios file. Pass in language code parameter for a particular language, such as it-it for Italian. set -e -# TODO: make parameters mandatory -LANG="$1" -RELEASE="$2" +RELEASE="$1" # If no release is specified, download the latest release if [ "$RELEASE" == "" ]; then - RELEASE="latest" -fi - -# Set a default scenarios file -SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/scenarios.zip" - -# If the LANG parameter was set, download appropriate script -if [ -n "$LANG" ]; then - # Map the language parameter to the corresponding scenarios file - # If no parameter, download the scenarios from IE - MAIN_LANG_PREFIX="$(echo "$LANG" | head -c2 | tr '[:upper:]' '[:lower:]')" - LANG_ARRAY=("de" "es" "fr" "it" "nl" "pt" "zh" "cs" "hu" "id" "ja" "ko" "pl" "pt" "ru" "sv" "tr") - - if [[ "${LANG_ARRAY[*]}" =~ "$MAIN_LANG_PREFIX" ]]; then - SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-$MAIN_LANG_PREFIX-scenarios.zip" - if [ "$MAIN_LANG_PREFIX" = "pt" ]; then - if [ "$LANG" = "pt-pt" ]; then - SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-pt-scenarios.zip" - elif [ "$LANG" = "pt-br" ]; then - SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-br-scenarios.zip" - else - SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-pt-scenarios.zip" - fi - fi - if [ "$MAIN_LANG_PREFIX" = "zh" ]; then - if [ "$LANG" = "zh-cn" ]; then - SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-cn-scenarios.zip" - elif [ "$LANG" = "zh-tw" ]; then - SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-tw-scenarios.zip" - else - SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-cn-scenarios.zip" - fi - fi - if [ "$MAIN_LANG_PREFIX" = "cs" ]; then - SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-cz-scenarios.zip" - fi - if [ "$MAIN_LANG_PREFIX" = "ja" ]; then - SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-jp-scenarios.zip" - fi - if [ "$MAIN_LANG_PREFIX" = "ko" ]; then - SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-kr-scenarios.zip" - fi - if [ "$MAIN_LANG_PREFIX" = "sv" ]; then - SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-se-scenarios.zip" - fi - fi + RELEASE="latest" fi # Download the binary -echo "Installing IE & scenarios from the $RELEASE release..." -wget -q -O ie https://github.com/Azure/InnovationEngine/releases/download/$RELEASE/ie > /dev/null -wget -q -O scenarios.zip "$SCENARIOS" > /dev/null +echo "Installing IE from the $RELEASE release..." +wget -q -O ie https://github.com/Azure/InnovationEngine/releases/download/"$RELEASE"/ie >/dev/null # Setup permissions & move to the local bin -chmod +x ie > /dev/null -mkdir -p ~/.local/bin > /dev/null -mv ie ~/.local/bin > /dev/null - -# Unzip the scenarios, overwrite if they already exist. -unzip -o scenarios.zip -d ~ > /dev/null -rm scenarios.zip > /dev/null +chmod +x ie >/dev/null +mkdir -p ~/.local/bin >/dev/null +mv ie ~/.local/bin >/dev/null # Export the path to IE if it's not already available if [[ !"$PATH" =~ "~/.local/bin" || !"$PATH" =~ "$HOME/.local/bin" ]]; then - export PATH="$PATH:~/.local/bin" + export PATH="$PATH:~/.local/bin" fi echo "Done." From 127f789622961ab83363f0cf26d0eba494302c67 Mon Sep 17 00:00:00 2001 From: vmarcella Date: Thu, 28 Mar 2024 12:16:48 -0700 Subject: [PATCH 2/4] [update] installation test to use new docs script. --- .github/workflows/scenario-testing.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/scenario-testing.yaml b/.github/workflows/scenario-testing.yaml index 023608ea..7b085ca0 100644 --- a/.github/workflows/scenario-testing.yaml +++ b/.github/workflows/scenario-testing.yaml @@ -24,6 +24,8 @@ jobs: echo "ie not found" exit 1 fi + + cat scripts/install_docs_from_release.sh en-us v1.0.1 | /bin/bash if [ ! -d "${HOME}/scenarios" ] then echo "scenarios not found" From 6bdad277409a1fd8f9cbe355354632d8bdae0b02 Mon Sep 17 00:00:00 2001 From: vmarcella Date: Thu, 28 Mar 2024 12:18:23 -0700 Subject: [PATCH 3/4] [fix] command usage. --- .github/workflows/scenario-testing.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/scenario-testing.yaml b/.github/workflows/scenario-testing.yaml index 7b085ca0..d1dc9394 100644 --- a/.github/workflows/scenario-testing.yaml +++ b/.github/workflows/scenario-testing.yaml @@ -19,13 +19,14 @@ jobs: - uses: actions/checkout@v2 - name: Check ie installation run: | + set -e cat scripts/install_from_release.sh | /bin/bash if ! command -v ie; then echo "ie not found" exit 1 fi - cat scripts/install_docs_from_release.sh en-us v1.0.1 | /bin/bash + cat scripts/install_docs_from_release.sh | /bin/bash -- en-us v1.0.1 if [ ! -d "${HOME}/scenarios" ] then echo "scenarios not found" From 84e0bf4d807e17a643e0b2184d7867e213fd966f Mon Sep 17 00:00:00 2001 From: vmarcella Date: Thu, 28 Mar 2024 12:19:51 -0700 Subject: [PATCH 4/4] [fix] command usage. --- .github/workflows/scenario-testing.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scenario-testing.yaml b/.github/workflows/scenario-testing.yaml index d1dc9394..5e1eaec4 100644 --- a/.github/workflows/scenario-testing.yaml +++ b/.github/workflows/scenario-testing.yaml @@ -26,7 +26,7 @@ jobs: exit 1 fi - cat scripts/install_docs_from_release.sh | /bin/bash -- en-us v1.0.1 + bash scripts/install_docs_from_release.sh en-us v1.0.1 if [ ! -d "${HOME}/scenarios" ] then echo "scenarios not found"