Skip to content

Commit 40d74a6

Browse files
authored
Decouple installation of IE and scenarios. (#189)
This PR decouples the installation script so that we can specify both the version of IE and the scenarios that are used via the portal independently of one another.
1 parent 2fe89a1 commit 40d74a6

File tree

3 files changed

+78
-60
lines changed

3 files changed

+78
-60
lines changed

.github/workflows/scenario-testing.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ jobs:
1919
- uses: actions/checkout@v2
2020
- name: Check ie installation
2121
run: |
22+
set -e
2223
cat scripts/install_from_release.sh | /bin/bash
2324
if ! command -v ie; then
2425
echo "ie not found"
2526
exit 1
2627
fi
28+
29+
bash scripts/install_docs_from_release.sh en-us v1.0.1
2730
if [ ! -d "${HOME}/scenarios" ]
2831
then
2932
echo "scenarios not found"

scripts/install_docs_from_release.sh

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Script to install documentation from our upstream repository.
2+
3+
set -e
4+
5+
# TODO: make parameters mandatory
6+
LANG="$1"
7+
RELEASE="$2"
8+
9+
# If no release is specified, download the latest release
10+
if [ "$RELEASE" == "" ]; then
11+
RELEASE="latest"
12+
fi
13+
14+
# Set a default scenarios file
15+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/$RELEASE/scenarios.zip"
16+
17+
# If the LANG parameter was set, download appropriate script
18+
if [ "$LANG" != "" ]; then
19+
# Map the language parameter to the corresponding scenarios file
20+
# If no parameter, download the scenarios from IE
21+
MAIN_LANG_PREFIX="$(echo "$LANG" | head -c2 | tr '[:upper:]' '[:lower:]')"
22+
LANG_ARRAY=("de" "es" "fr" "it" "nl" "pt" "zh" "cs" "hu" "id" "ja" "ko" "pl" "pt" "ru" "sv" "tr")
23+
24+
if [[ "${LANG_ARRAY[*]}" =~ "$MAIN_LANG_PREFIX" ]]; then
25+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-$MAIN_LANG_PREFIX-scenarios.zip"
26+
if [ "$MAIN_LANG_PREFIX" = "pt" ]; then
27+
if [ "$LANG" = "pt-pt" ]; then
28+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-pt-scenarios.zip"
29+
elif [ "$LANG" = "pt-br" ]; then
30+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-br-scenarios.zip"
31+
else
32+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-pt-scenarios.zip"
33+
fi
34+
fi
35+
if [ "$MAIN_LANG_PREFIX" = "zh" ]; then
36+
if [ "$LANG" = "zh-cn" ]; then
37+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-cn-scenarios.zip"
38+
elif [ "$LANG" = "zh-tw" ]; then
39+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-tw-scenarios.zip"
40+
else
41+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-cn-scenarios.zip"
42+
fi
43+
fi
44+
if [ "$MAIN_LANG_PREFIX" = "cs" ]; then
45+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-cz-scenarios.zip"
46+
fi
47+
if [ "$MAIN_LANG_PREFIX" = "ja" ]; then
48+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-jp-scenarios.zip"
49+
fi
50+
if [ "$MAIN_LANG_PREFIX" = "ko" ]; then
51+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-kr-scenarios.zip"
52+
fi
53+
if [ "$MAIN_LANG_PREFIX" = "sv" ]; then
54+
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-se-scenarios.zip"
55+
fi
56+
fi
57+
fi
58+
59+
# Download the scenarios.
60+
echo "Installing scenarios from the $RELEASE release..."
61+
wget -q -O scenarios.zip "$SCENARIOS" >/dev/null
62+
63+
# Unzip the scenarios, overwrite if they already exist.
64+
unzip -o scenarios.zip -d ~ >/dev/null
65+
rm scenarios.zip >/dev/null
66+
67+
echo "Done."

scripts/install_from_release.sh

+8-60
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,25 @@
11
# Script to install scenarios file. Pass in language code parameter for a particular language, such as it-it for Italian.
22
set -e
33

4-
# TODO: make parameters mandatory
5-
LANG="$1"
6-
RELEASE="$2"
4+
RELEASE="$1"
75

86
# If no release is specified, download the latest release
97
if [ "$RELEASE" == "" ]; then
10-
RELEASE="latest"
11-
fi
12-
13-
# Set a default scenarios file
14-
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/scenarios.zip"
15-
16-
# If the LANG parameter was set, download appropriate script
17-
if [ -n "$LANG" ]; then
18-
# Map the language parameter to the corresponding scenarios file
19-
# If no parameter, download the scenarios from IE
20-
MAIN_LANG_PREFIX="$(echo "$LANG" | head -c2 | tr '[:upper:]' '[:lower:]')"
21-
LANG_ARRAY=("de" "es" "fr" "it" "nl" "pt" "zh" "cs" "hu" "id" "ja" "ko" "pl" "pt" "ru" "sv" "tr")
22-
23-
if [[ "${LANG_ARRAY[*]}" =~ "$MAIN_LANG_PREFIX" ]]; then
24-
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-$MAIN_LANG_PREFIX-scenarios.zip"
25-
if [ "$MAIN_LANG_PREFIX" = "pt" ]; then
26-
if [ "$LANG" = "pt-pt" ]; then
27-
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-pt-scenarios.zip"
28-
elif [ "$LANG" = "pt-br" ]; then
29-
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-br-scenarios.zip"
30-
else
31-
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/pt-pt-scenarios.zip"
32-
fi
33-
fi
34-
if [ "$MAIN_LANG_PREFIX" = "zh" ]; then
35-
if [ "$LANG" = "zh-cn" ]; then
36-
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-cn-scenarios.zip"
37-
elif [ "$LANG" = "zh-tw" ]; then
38-
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-tw-scenarios.zip"
39-
else
40-
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/zh-cn-scenarios.zip"
41-
fi
42-
fi
43-
if [ "$MAIN_LANG_PREFIX" = "cs" ]; then
44-
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-cz-scenarios.zip"
45-
fi
46-
if [ "$MAIN_LANG_PREFIX" = "ja" ]; then
47-
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-jp-scenarios.zip"
48-
fi
49-
if [ "$MAIN_LANG_PREFIX" = "ko" ]; then
50-
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-kr-scenarios.zip"
51-
fi
52-
if [ "$MAIN_LANG_PREFIX" = "sv" ]; then
53-
SCENARIOS="https://github.com/MicrosoftDocs/executable-docs/releases/download/v1.0.1/$MAIN_LANG_PREFIX-se-scenarios.zip"
54-
fi
55-
fi
8+
RELEASE="latest"
569
fi
5710

5811
# Download the binary
59-
echo "Installing IE & scenarios from the $RELEASE release..."
60-
wget -q -O ie https://github.com/Azure/InnovationEngine/releases/download/$RELEASE/ie > /dev/null
61-
wget -q -O scenarios.zip "$SCENARIOS" > /dev/null
12+
echo "Installing IE from the $RELEASE release..."
13+
wget -q -O ie https://github.com/Azure/InnovationEngine/releases/download/"$RELEASE"/ie >/dev/null
6214

6315
# Setup permissions & move to the local bin
64-
chmod +x ie > /dev/null
65-
mkdir -p ~/.local/bin > /dev/null
66-
mv ie ~/.local/bin > /dev/null
67-
68-
# Unzip the scenarios, overwrite if they already exist.
69-
unzip -o scenarios.zip -d ~ > /dev/null
70-
rm scenarios.zip > /dev/null
16+
chmod +x ie >/dev/null
17+
mkdir -p ~/.local/bin >/dev/null
18+
mv ie ~/.local/bin >/dev/null
7119

7220
# Export the path to IE if it's not already available
7321
if [[ !"$PATH" =~ "~/.local/bin" || !"$PATH" =~ "$HOME/.local/bin" ]]; then
74-
export PATH="$PATH:~/.local/bin"
22+
export PATH="$PATH:~/.local/bin"
7523
fi
7624

7725
echo "Done."

0 commit comments

Comments
 (0)