From 27530c403c2a1e1242e4dc59fca177e6abed9447 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 2 Sep 2016 16:32:06 -0700 Subject: [PATCH] Use direct download URLs instead of API GitHub's API is throttled to 60 requests per hour per IP address when for non-authenticated calls, which was causing severe CI flakiness. While this adds another set of URLs to update for each release, the alternative was adding an OAuth token and maintaining its ownership. Moreover, this code is simpler than the previous API parsing. --- .travis.yml | 4 +++- tools/download.sh | 25 ++++++++----------------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5635e6fd4f..d0ffc8f17c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,9 @@ addons: paths: $(ls powershell*{deb,pkg} | tr "\n" ":") install: - - (cd tools && ./download.sh) + - pushd tools + - ./download.sh + - popd - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then rvm use 2.2.1; fi # Default 2.0.0 Ruby is buggy script: ./tools/travis.sh diff --git a/tools/download.sh b/tools/download.sh index 90ba9b02d6..ec1733f66a 100755 --- a/tools/download.sh +++ b/tools/download.sh @@ -7,10 +7,9 @@ trap ' kill -s INT "$$" ' INT -# Retrieves asset ID and package name of asset ending in argument -# $info looks like: "id": 1698239, "name": "powershell_0.4.0-1_amd64.deb", -get_info() { - curl -s https://api.github.com/repos/PowerShell/PowerShell/releases/latest | grep -B 1 "name.*$1" +get_url() { + release=v6.0.0-alpha.9 + echo "https://github.com/PowerShell/PowerShell/releases/download/$release/$1" } # Get OS specific asset ID and package name @@ -25,7 +24,7 @@ case "$OSTYPE" in sudo yum install -y curl fi - version=rpm + package=powershell-6.0.0_alpha.9-1.el7.centos.x86_64.rpm ;; ubuntu) if ! hash curl 2>/dev/null; then @@ -35,10 +34,10 @@ case "$OSTYPE" in case "$VERSION_ID" in 14.04) - version=ubuntu1.14.04.1_amd64.deb + package=powershell_6.0.0-alpha.9-1ubuntu1.14.04.1_amd64.deb ;; 16.04) - version=ubuntu1.16.04.1_amd64.deb + package=powershell_6.0.0-alpha.9-1ubuntu1.16.04.1_amd64.deb ;; *) echo "Ubuntu $VERSION_ID is not supported!" >&2 @@ -52,7 +51,7 @@ case "$OSTYPE" in ;; darwin*) # We don't check for curl as macOS should have a system version - version=pkg + package=powershell-6.0.0-alpha.9.pkg ;; *) echo "$OSTYPE is not supported!" >&2 @@ -60,15 +59,7 @@ case "$OSTYPE" in ;; esac -info=$(get_info "$version") - -# Parses $info for asset ID and package name -read asset package <<< $(echo "$info" | sed 's/[,"]//g' | awk '{ print $2; print $4 }') - -# Downloads asset to file -packageuri=$(curl -s -i -H 'Accept: application/octet-stream' "https://api.github.com/repos/PowerShell/PowerShell/releases/assets/$asset" | - grep location | sed 's/location: //g') -curl -C - -o "$package" ${packageuri%$'\r'} +curl -L -o "$package" $(get_url "$package") if [[ ! -r "$package" ]]; then echo "ERROR: $package failed to download! Aborting..." >&2