travis_reprise 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +3 -0
- data/Gemfile.lock +38 -0
- data/README.md +16 -0
- data/bin/travis_reprise +90 -0
- data/travis_reprise.gemspec +19 -0
- metadata +82 -0
    
        data/Gemfile
    ADDED
    
    
    
        data/Gemfile.lock
    ADDED
    
    | @@ -0,0 +1,38 @@ | |
| 1 | 
            +
            PATH
         | 
| 2 | 
            +
              remote: .
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                travis-reprise (0.1.0)
         | 
| 5 | 
            +
                  faraday (~> 0.8.4)
         | 
| 6 | 
            +
                  github_api (~> 0.7.0)
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            GEM
         | 
| 9 | 
            +
              remote: http://rubygems.org/
         | 
| 10 | 
            +
              specs:
         | 
| 11 | 
            +
                faraday (0.8.4)
         | 
| 12 | 
            +
                  multipart-post (~> 1.1)
         | 
| 13 | 
            +
                github_api (0.7.0)
         | 
| 14 | 
            +
                  faraday (~> 0.8.1)
         | 
| 15 | 
            +
                  hashie (~> 1.2.0)
         | 
| 16 | 
            +
                  multi_json (~> 1.3)
         | 
| 17 | 
            +
                  nokogiri (~> 1.5.2)
         | 
| 18 | 
            +
                  oauth2
         | 
| 19 | 
            +
                hashie (1.2.0)
         | 
| 20 | 
            +
                httpauth (0.2.0)
         | 
| 21 | 
            +
                jwt (0.1.5)
         | 
| 22 | 
            +
                  multi_json (>= 1.0)
         | 
| 23 | 
            +
                multi_json (1.3.6)
         | 
| 24 | 
            +
                multipart-post (1.1.5)
         | 
| 25 | 
            +
                nokogiri (1.5.5)
         | 
| 26 | 
            +
                oauth2 (0.8.0)
         | 
| 27 | 
            +
                  faraday (~> 0.8)
         | 
| 28 | 
            +
                  httpauth (~> 0.1)
         | 
| 29 | 
            +
                  jwt (~> 0.1.4)
         | 
| 30 | 
            +
                  multi_json (~> 1.0)
         | 
| 31 | 
            +
                  rack (~> 1.2)
         | 
| 32 | 
            +
                rack (1.4.1)
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            PLATFORMS
         | 
| 35 | 
            +
              ruby
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            DEPENDENCIES
         | 
| 38 | 
            +
              travis-reprise!
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            This is a stupid simple gem which you can use to trigger a rebuild on
         | 
| 2 | 
            +
            Travis Pro. It could likely be enhanced without much effort to work on
         | 
| 3 | 
            +
            the public system as well but I have no use for that at this time.
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            # Responsibility
         | 
| 6 | 
            +
            *DO NOT* use this tool to compensate for a piece of crap test suite that
         | 
| 7 | 
            +
            fails depending on the cycle of the moon. Fix your tests instead. Valid
         | 
| 8 | 
            +
            use cases are when a test suite fails because a worker died, code
         | 
| 9 | 
            +
            couldn't be checked out because GitHub had a temporary issue, etc.
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            # Using
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            ```bash
         | 
| 14 | 
            +
            gem install travis_reprise
         | 
| 15 | 
            +
            travis_reprise USER REPO BRANCH
         | 
| 16 | 
            +
            ```
         | 
    
        data/bin/travis_reprise
    ADDED
    
    | @@ -0,0 +1,90 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            # Pardon code fugliness that follows, got it working, don't care to
         | 
| 4 | 
            +
            # clean it up at this point...
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            require 'github_api'
         | 
| 7 | 
            +
            require 'net/https'
         | 
| 8 | 
            +
            require 'json'
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            user, repo, branch = ARGV[0], ARGV[1], ARGV[2]
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            unless user && repo && branch
         | 
| 13 | 
            +
              puts "USAGE: #{$0} GITHUB_USER REPO BRANCH_TO_BUILD"
         | 
| 14 | 
            +
              puts "If not specified github user defaults to bigcartel"
         | 
| 15 | 
            +
              exit 1
         | 
| 16 | 
            +
            end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            begin
         | 
| 19 | 
            +
              config = JSON.parse(File.read(File.expand_path('~/.travis-reprise.json')))
         | 
| 20 | 
            +
            rescue Errno::ENOENT
         | 
| 21 | 
            +
              $stdout.sync = true
         | 
| 22 | 
            +
              print "Github Username: "
         | 
| 23 | 
            +
              u = $stdin.gets.chomp
         | 
| 24 | 
            +
              print "Github Password: "
         | 
| 25 | 
            +
              `stty -echo`
         | 
| 26 | 
            +
              p = $stdin.gets.chomp
         | 
| 27 | 
            +
              `stty echo`
         | 
| 28 | 
            +
              puts
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              json = `curl -u '#{u}:#{p}' -d '{"scopes":["repo"],"note":"Travis Reprise"}' https://api.github.com/authorizations 2>/dev/null`
         | 
| 31 | 
            +
              data = JSON.parse(json)
         | 
| 32 | 
            +
              if data['token']
         | 
| 33 | 
            +
                File.open(File.expand_path('~/.travis-reprise.json'), 'w') do |f|
         | 
| 34 | 
            +
                  f << json
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
              else
         | 
| 37 | 
            +
                puts "#{data['message']}: try again"
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
              retry
         | 
| 40 | 
            +
            end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            gh = Github.new oauth_token: config['token']
         | 
| 43 | 
            +
             | 
| 44 | 
            +
            branch_data = gh.repos.branch(user, repo, branch)
         | 
| 45 | 
            +
            head = gh.repos.commits.get(user, repo, branch_data.commit.sha)
         | 
| 46 | 
            +
            hook = gh.repos.hooks.all(user, repo).find { |h| h.name == 'travis' }
         | 
| 47 | 
            +
             | 
| 48 | 
            +
            payload = {
         | 
| 49 | 
            +
              :after => head.sha,
         | 
| 50 | 
            +
              :before => head.parents.first.sha,
         | 
| 51 | 
            +
              :ref => "refs/heads/#{branch}",
         | 
| 52 | 
            +
              :commits => [{
         | 
| 53 | 
            +
                :id => head.sha,
         | 
| 54 | 
            +
                :message => head.commit.message,
         | 
| 55 | 
            +
                :timestamp => head.commit.author['date'],
         | 
| 56 | 
            +
                :url => "https://github.com/#{user}/#{repo}/commit/#{head.sha}",
         | 
| 57 | 
            +
                :author => author = {
         | 
| 58 | 
            +
                  :name => head.commit.author.name,
         | 
| 59 | 
            +
                  :email => head.commit.author.email
         | 
| 60 | 
            +
                },
         | 
| 61 | 
            +
                :committer => author
         | 
| 62 | 
            +
              }],
         | 
| 63 | 
            +
              :compare => "http://dummy",
         | 
| 64 | 
            +
              :repository => {
         | 
| 65 | 
            +
                :name => repo,
         | 
| 66 | 
            +
                :owner => { :name => user },
         | 
| 67 | 
            +
                :private => true,
         | 
| 68 | 
            +
                :url => "https://github.com/#{user}/#{repo}"
         | 
| 69 | 
            +
              }
         | 
| 70 | 
            +
            }
         | 
| 71 | 
            +
             | 
| 72 | 
            +
            #pull_payload = gh.events.repository(user, repo).select { |e| e.type == 'PullRequestEvent' }.first.payload
         | 
| 73 | 
            +
             | 
| 74 | 
            +
            payload = JSON.pretty_generate(payload)
         | 
| 75 | 
            +
             | 
| 76 | 
            +
            http = Net::HTTP.new('notify.travis-ci.com', 443)
         | 
| 77 | 
            +
            http.use_ssl = true
         | 
| 78 | 
            +
            http.verify_mode = OpenSSL::SSL::VERIFY_NONE
         | 
| 79 | 
            +
            post = Net::HTTP::Post.new('/')
         | 
| 80 | 
            +
            post.basic_auth hook.config.user, hook.config.token
         | 
| 81 | 
            +
            post['X-GitHub-Event'] = 'push'
         | 
| 82 | 
            +
            post.set_form_data({ :payload => payload })
         | 
| 83 | 
            +
             | 
| 84 | 
            +
            result = http.request(post)
         | 
| 85 | 
            +
             | 
| 86 | 
            +
            if result.code == '204'
         | 
| 87 | 
            +
              puts "It may have worked, go check travis"
         | 
| 88 | 
            +
            else
         | 
| 89 | 
            +
              puts "OOPS: Travis responded #{result.inspect}"
         | 
| 90 | 
            +
            end
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Gem::Specification.new do |s|
         | 
| 4 | 
            +
              s.name        = "travis_reprise"
         | 
| 5 | 
            +
              s.version     = '0.1.1'
         | 
| 6 | 
            +
              s.platform    = Gem::Platform::RUBY
         | 
| 7 | 
            +
              s.summary     = %q{Trigger travis rebuilds easily}
         | 
| 8 | 
            +
              s.author      = 'dev@bigcartel.com'
         | 
| 9 | 
            +
              s.email       = 'dev@bigcartel.com'
         | 
| 10 | 
            +
              s.homepage     = 'https://github.com/bigcartel/travis_reprise'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              s.files         = `git ls-files`.split("\n")
         | 
| 13 | 
            +
              s.test_files    = `git ls-files -- {spec}/*`.split("\n")
         | 
| 14 | 
            +
              s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         | 
| 15 | 
            +
              s.require_paths = ["lib"]
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              s.add_dependency 'github_api', '~>0.7.0'
         | 
| 18 | 
            +
              s.add_dependency 'faraday', '~>0.8.4'
         | 
| 19 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,82 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: travis_reprise
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.1
         | 
| 5 | 
            +
              prerelease: 
         | 
| 6 | 
            +
            platform: ruby
         | 
| 7 | 
            +
            authors:
         | 
| 8 | 
            +
            - dev@bigcartel.com
         | 
| 9 | 
            +
            autorequire: 
         | 
| 10 | 
            +
            bindir: bin
         | 
| 11 | 
            +
            cert_chain: []
         | 
| 12 | 
            +
            date: 2012-10-15 00:00:00.000000000 Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 15 | 
            +
              name: github_api
         | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            +
                none: false
         | 
| 18 | 
            +
                requirements:
         | 
| 19 | 
            +
                - - ~>
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            +
                    version: 0.7.0
         | 
| 22 | 
            +
              type: :runtime
         | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                none: false
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - ~>
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: 0.7.0
         | 
| 30 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 31 | 
            +
              name: faraday
         | 
| 32 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 33 | 
            +
                none: false
         | 
| 34 | 
            +
                requirements:
         | 
| 35 | 
            +
                - - ~>
         | 
| 36 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 37 | 
            +
                    version: 0.8.4
         | 
| 38 | 
            +
              type: :runtime
         | 
| 39 | 
            +
              prerelease: false
         | 
| 40 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            +
                none: false
         | 
| 42 | 
            +
                requirements:
         | 
| 43 | 
            +
                - - ~>
         | 
| 44 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            +
                    version: 0.8.4
         | 
| 46 | 
            +
            description: 
         | 
| 47 | 
            +
            email: dev@bigcartel.com
         | 
| 48 | 
            +
            executables:
         | 
| 49 | 
            +
            - travis_reprise
         | 
| 50 | 
            +
            extensions: []
         | 
| 51 | 
            +
            extra_rdoc_files: []
         | 
| 52 | 
            +
            files:
         | 
| 53 | 
            +
            - Gemfile
         | 
| 54 | 
            +
            - Gemfile.lock
         | 
| 55 | 
            +
            - README.md
         | 
| 56 | 
            +
            - bin/travis_reprise
         | 
| 57 | 
            +
            - travis_reprise.gemspec
         | 
| 58 | 
            +
            homepage: https://github.com/bigcartel/travis_reprise
         | 
| 59 | 
            +
            licenses: []
         | 
| 60 | 
            +
            post_install_message: 
         | 
| 61 | 
            +
            rdoc_options: []
         | 
| 62 | 
            +
            require_paths:
         | 
| 63 | 
            +
            - lib
         | 
| 64 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
              none: false
         | 
| 66 | 
            +
              requirements:
         | 
| 67 | 
            +
              - - ! '>='
         | 
| 68 | 
            +
                - !ruby/object:Gem::Version
         | 
| 69 | 
            +
                  version: '0'
         | 
| 70 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 71 | 
            +
              none: false
         | 
| 72 | 
            +
              requirements:
         | 
| 73 | 
            +
              - - ! '>='
         | 
| 74 | 
            +
                - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                  version: '0'
         | 
| 76 | 
            +
            requirements: []
         | 
| 77 | 
            +
            rubyforge_project: 
         | 
| 78 | 
            +
            rubygems_version: 1.8.23
         | 
| 79 | 
            +
            signing_key: 
         | 
| 80 | 
            +
            specification_version: 3
         | 
| 81 | 
            +
            summary: Trigger travis rebuilds easily
         | 
| 82 | 
            +
            test_files: []
         |