Browse Source

Fix Carthage test to use current commit hash

kishikawa katsumi 9 years ago
parent
commit
07a2d0cb97
2 changed files with 14 additions and 2 deletions
  1. 2 0
      .travis.yml
  2. 12 2
      Lib/Rakefile

+ 2 - 0
.travis.yml

@@ -3,6 +3,8 @@ osx_image: xcode7.3
 cache:
   directories:
     - Lib/vendor/bundle
+before_install:
+  - brew install jq
 install:
   - "(cd Lib && bundle install --path=vendor/bundle --binstubs=vendor/bin)"
 before_script:

+ 12 - 2
Lib/Rakefile

@@ -93,9 +93,19 @@ namespace :test do
     end
   end
   
+  def branch_name
+    if ENV['CI']
+      pull_req = %[https://api.github.com/repos/#{ENV['TRAVIS_REPO_SLUG']}/pulls/#{ENV['TRAVIS_PULL_REQUEST']}]
+      auth_token = 'kishikawakatsumi:209558699492df7782fbe62dda1891d6a6ba010f'
+      (ENV['TRAVIS_PULL_REQUEST'] == 'false' ? ENV['TRAVIS_BRANCH'] : `curl -u #{auth_token} -s #{pull_req} | jq -r .head.ref`).strip
+    else
+      %x[git rev-parse --abbrev-ref HEAD]
+    end
+  end
+  
   task :carthage do
-    sh 'echo "github \"kishikawakatsumi/KeychainAccess\" \"${sha:-master}"\" > Cartfile'
-    sh 'carthage update --no-use-binaries'
+    sh %[echo 'github \"kishikawakatsumi/KeychainAccess\" \"#{branch_name}\"' > Cartfile]
+    sh %[carthage update --no-use-binaries]
   end
 end