From 0199a8cb59fdc13a5fe0dfd89b690ea3fb7965ab Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 21 Jun 2018 14:53:42 -0400 Subject: [PATCH] Fetch the pull request number using @sassbot's credentials This avoids running into GitHub's low rate limits for unauthenticated requests. --- .travis.yml | 14 ++++++++++++-- extra/sass-spec-ref.sh | 7 ++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 96e9b78d2..f5b4e5b55 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,25 @@ sudo: false language: ruby cache: bundler + +env: + global: + # GITHUB_AUTH="..." + # + # Used to fetch the corresponding sass-spec ref without running into GitHub's + # API rate limit. + - secure: "DSINT3LH/FaoSfYEo7kyRBilEWtAoGjZ6TJgwawmkeV8uhiOo/PbrulHMlQJszH0zOk5h8d8CD9fwtOTlItSzbLJaGyF7MQN3SwqJ5+UIzZio3znGA+TR0jEKY2 + uaF06qa42f9szyd40aszYeYQDA6jTkS3reM0LL0oOwA6GY7Q=" + install: # If we're running for a pull request, check out the revision of sass-spec # referenced by that pull request. - | if [ ! -z "$TRAVIS_PULL_REQUEST" -a "$TRAVIS_PULL_REQUEST" != false ]; then + ref=$(extra/sass-spec-ref.sh) mkdir sass-spec git -C sass-spec init - git -C sass-spec pull --depth=1 git://github.com/sass/sass-spec \ - $(extra/sass-spec-ref.sh) + git -C sass-spec pull --depth=1 git://github.com/sass/sass-spec "$ref" bundle config local.sass-spec "$(pwd)/sass-spec" fi diff --git a/extra/sass-spec-ref.sh b/extra/sass-spec-ref.sh index d487f7aef..5d0d1c4b3 100755 --- a/extra/sass-spec-ref.sh +++ b/extra/sass-spec-ref.sh @@ -18,7 +18,12 @@ fi >&2 echo "Fetching pull request $TRAVIS_PULL_REQUEST..." -JSON=$(curl -L -sS https://api.github.com/repos/sass/sass/pulls/$TRAVIS_PULL_REQUEST) +url=https://api.github.com/repos/sass/sass/pulls/$TRAVIS_PULL_REQUEST +if [ -z "$GITHUB_AUTH" ]; then + JSON=$(curl -L -sS $url) +else + JSON=$(curl -u "sassbot:$GITHUB_AUTH" -L -sS $url) +fi RE_SPEC_PR="sass\/sass-spec(#|\/pull\/)([0-9]+)"