Update CI setup for windows to install yarn in global path (#24558)

* Update windows ci setup to install yarn global

* Keep formatting consistent

* Update yarn installation for linux

* Updating paths and removing cache folder
This commit is contained in:
liza-mae 2018-10-31 12:16:58 -06:00 committed by GitHub
parent 191335cf91
commit 2ce57a5e6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -31,20 +31,21 @@ fi
### download node
###
UNAME=$(uname)
OS='linux'
OS="linux"
if [[ "$UNAME" = *"MINGW64_NT"* ]]; then
OS='win'
OS="win"
fi
echo " -- Running on OS: $OS"
nodeVersion="$(cat $dir/.node-version)"
nodeDir="$cacheDir/node/$nodeVersion"
if [[ $OS == 'win' ]]; then
nodeBin="$nodeDir"
nodeUrl="https://nodejs.org/download/release/v$nodeVersion/node-v$nodeVersion-win-x64.zip"
else
if [[ "$OS" == "win" ]]; then
nodeBin="$HOME/node"
nodeUrl="https://nodejs.org/dist/v$nodeVersion/node-v$nodeVersion-win-x64.zip"
else
nodeBin="$nodeDir/bin"
nodeUrl="https://nodejs.org/download/release/v$nodeVersion/node-v$nodeVersion-linux-x64.tar.gz"
nodeUrl="https://nodejs.org/dist/v$nodeVersion/node-v$nodeVersion-linux-x64.tar.gz"
fi
echo " -- node: version=v${nodeVersion} dir=$nodeDir"
@ -60,69 +61,45 @@ else
echo " -- downloading node.js from $nodeUrl"
mkdir -p "$nodeDir"
if [[ $OS == 'win' ]]; then
if [[ "$OS" == "win" ]]; then
nodePkg="$nodeDir/${nodeUrl##*/}"
curl --silent -o $nodePkg $nodeUrl
unzip -jqo $nodePkg -d $nodeDir
unzip -qo $nodePkg -d $nodeDir
mv "${nodePkg%.*}" "$nodeBin"
else
curl --silent "$nodeUrl" | tar -xz -C "$nodeDir" --strip-components=1
fi
fi
###
### "install" node into this shell
###
export PATH="$nodeBin:$PATH"
hash -r
###
### downloading yarn
###
yarnVersion="$(node -e "console.log(String(require('./package.json').engines.yarn || '').replace(/^[^\d]+/,''))")"
yarnUrl="https://github.com/yarnpkg/yarn/releases/download/v$yarnVersion/yarn-$yarnVersion.js"
yarnDir="$cacheDir/yarn/$yarnVersion"
if [ -z "$yarnVersion" ]; then
echo " ${RED}!! missing engines.yarn in package.json${RESET_C}";
exit 1
elif [ -x "$yarnDir/bin/yarn" ] && [ "$($yarnDir/bin/yarn --version)" == "$yarnVersion" ]; then
echo " -- reusing yarn install"
else
if [ -d "$yarnDir" ]; then
echo " -- clearing previous yarn install"
rm -rf "$yarnDir"
fi
echo " -- downloading yarn from $yarnUrl"
mkdir -p "$yarnDir/bin"
curl -L --silent "$yarnUrl" > "$yarnDir/bin/yarn"
chmod +x "$yarnDir/bin/yarn"
fi
npm install -g yarn@^${yarnVersion}
###
### "install" yarn into this shell
###
export PATH="$yarnDir/bin:$PATH"
yarnGlobalDir="$(yarn global bin)"
export PATH="$PATH:$yarnGlobalDir"
hash -r
###
### install dependencies
###
echo " -- installing node.js dependencies"
yarn config set cache-folder "$cacheDir/yarn"
yarn kbn bootstrap
###
### verify no git modifications
###
GIT_CHANGES="$(git ls-files --modified)"
if [ "$GIT_CHANGES" ]; then
echo -e "\n${RED}ERROR: 'yarn kbn bootstrap' caused changes to the following files:${C_RESET}\n"