hockey-gerrit 0.0.4 → 1.0.0
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.
- checksums.yaml +4 -4
- data/.gitignore +6 -1
- data/.rubocop.yml +9 -1
- data/.travis.yml +5 -5
- data/Rakefile +5 -1
- data/bin/hockey-gerrit +1 -1
- data/hockey-gerrit.gemspec +12 -4
- data/lib/hockey_gerrit.rb +88 -25
- data/lib/hockey_gerrit/shenzhen.rb +71 -0
- data/lib/hockey_gerrit/version.rb +1 -1
- data/notes.md +6 -0
- metadata +105 -6
- data/.rspec +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33dabbc32ca92ae60bf2d88ac65491c1037e7dea
|
4
|
+
data.tar.gz: e544b00de71d7e68cf298e1950328f0a6450608e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7495c4cf19234679f045e68ab217d39b969a742e8ddc7bc9bd2ecd0b33f7d44e68da53a57d5100cfde669d3997b8962eadd4508c7edb64ab89d64b142c51f07
|
7
|
+
data.tar.gz: 2ac67394f78af6ac01b0de5c4049df6d19a790cf7e66e7a4cba7d0d6883cd9c10cd90443794c004c80ee9dd95fd990f7c51f8c8374bc376e0396d09846ae176d
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -27,5 +27,13 @@ Metrics/ClassLength:
|
|
27
27
|
Max: 150
|
28
28
|
Metrics/CyclomaticComplexity:
|
29
29
|
Max: 10
|
30
|
+
Metrics/PerceivedComplexity:
|
31
|
+
Max: 10
|
30
32
|
Metrics/AbcSize:
|
31
|
-
Max: 40
|
33
|
+
Max: 40
|
34
|
+
AllCops:
|
35
|
+
Exclude:
|
36
|
+
- 'lib/hockey_gerrit/shenzhen.rb'
|
37
|
+
# RubyMine default formatting breaks this rule
|
38
|
+
Style/SpaceInsideHashLiteralBraces:
|
39
|
+
Enabled: false
|
data/.travis.yml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
sudo: false
|
2
|
-
cache: bundler
|
3
2
|
language: ruby
|
3
|
+
cache:
|
4
|
+
bundler: true
|
4
5
|
rvm:
|
5
|
-
- 2.3.
|
6
|
+
- 2.3.1
|
6
7
|
before_install: gem update --remote bundler
|
7
8
|
install:
|
8
9
|
- bundle install --retry=3
|
9
10
|
script:
|
10
|
-
- bundle exec
|
11
|
-
- bundle exec rspec
|
11
|
+
- bundle exec rake
|
12
12
|
notifications:
|
13
13
|
email:
|
14
14
|
on_success: never
|
15
|
-
on_failure: never
|
15
|
+
on_failure: never
|
data/Rakefile
CHANGED
data/bin/hockey-gerrit
CHANGED
data/hockey-gerrit.gemspec
CHANGED
@@ -3,11 +3,12 @@ require_relative 'lib/hockey_gerrit/version'
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'hockey-gerrit'
|
5
5
|
spec.version = HockeyGerrit::VERSION
|
6
|
-
spec.authors = ['Trevor Renshaw']
|
7
|
-
spec.email = [
|
8
|
-
spec.summary = '
|
9
|
-
spec.description = '
|
6
|
+
spec.authors = ['Trevor Renshaw', 'bootstraponline']
|
7
|
+
spec.email = %w[trenshaw@instructure.com code@bootstraponline.com]
|
8
|
+
spec.summary = 'Uploads a build from gerrit/Jenkins to hockeyapp'
|
9
|
+
spec.description = 'Uploads a build from gerrit/Jenkins to hockeyapp.'
|
10
10
|
spec.license = 'Apache-2.0'
|
11
|
+
spec.homepage = 'https://github.com/instructure/hockey-gerrit'
|
11
12
|
|
12
13
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
13
14
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
@@ -17,6 +18,13 @@ Gem::Specification.new do |spec|
|
|
17
18
|
|
18
19
|
spec.required_ruby_version = '>= 2.0.0'
|
19
20
|
|
21
|
+
spec.add_runtime_dependency 'faraday', '~> 0.9.2'
|
22
|
+
spec.add_runtime_dependency 'faraday_middleware', '~> 0.10.0'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'safe_yaml', '~> 1.0', '>= 1.0.4'
|
25
|
+
spec.add_development_dependency 'pry', '~> 0.10.3'
|
26
|
+
spec.add_development_dependency 'trace_files', '~> 1.0'
|
27
|
+
spec.add_development_dependency 'webmock', '~> 2.0', '>= 2.0.3'
|
20
28
|
spec.add_development_dependency 'bundler', '~> 1.11', '>= 1.11.0'
|
21
29
|
spec.add_development_dependency 'byebug', '~> 8.2.2', '>= 8.2.2'
|
22
30
|
spec.add_development_dependency 'rake', '~> 11.1.1', '>= 11.1.1'
|
data/lib/hockey_gerrit.rb
CHANGED
@@ -1,41 +1,104 @@
|
|
1
1
|
require_relative 'hockey_gerrit/version'
|
2
2
|
require 'English'
|
3
3
|
|
4
|
+
require 'rubygems'
|
5
|
+
require_relative 'hockey_gerrit/shenzhen'
|
6
|
+
|
4
7
|
class HockeyGerrit
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
attr_reader :token, :ipa, :build_url, :gerrit_env, :tries, :upload_url
|
9
|
+
|
10
|
+
def gerrit_refspec
|
11
|
+
raise 'Must set GERRIT_REFSPEC' unless gerrit_env && !gerrit_env.empty?
|
12
|
+
gerrit_split = gerrit_env.split('/')
|
13
|
+
raise 'GERRIT_REFSPEC is invalid' unless gerrit_split.size >= 2
|
14
|
+
change, patch = gerrit_split[-2..-1]
|
15
|
+
"g#{change},#{patch}"
|
11
16
|
end
|
12
17
|
|
13
|
-
def
|
14
|
-
|
15
|
-
raise '
|
18
|
+
def git_log
|
19
|
+
git_log = `git log --reverse -1 --format="%an: %s"`
|
20
|
+
raise 'command failed' unless $CHILD_STATUS.success?
|
21
|
+
git_log
|
16
22
|
end
|
17
23
|
|
18
|
-
def
|
19
|
-
|
24
|
+
def git_commit_sha
|
25
|
+
sha = `git rev-parse --verify HEAD`
|
26
|
+
raise 'command failed' unless $CHILD_STATUS.success?
|
27
|
+
sha
|
20
28
|
end
|
21
29
|
|
22
|
-
def
|
23
|
-
|
30
|
+
def configure_options
|
31
|
+
gerrit = gerrit_refspec
|
32
|
+
log = git_log
|
33
|
+
release_notes = "#{gerrit}\n\n#{log}"
|
34
|
+
|
35
|
+
markdown = 1
|
36
|
+
available_for_download = 2
|
37
|
+
dont_notify = 0
|
38
|
+
options = {
|
39
|
+
notes_type: markdown,
|
40
|
+
notes: release_notes,
|
41
|
+
notify: dont_notify,
|
42
|
+
ipa: ipa,
|
43
|
+
status: available_for_download,
|
44
|
+
build_server_url: build_url,
|
45
|
+
commit_sha: git_commit_sha
|
46
|
+
}
|
47
|
+
|
48
|
+
dsym_ext = 'app.dSYM.zip'
|
49
|
+
dsym = ipa.to_s.gsub('ipa', dsym_ext)
|
50
|
+
|
51
|
+
if File.exist?(dsym) && dsym.end_with?(dsym_ext)
|
52
|
+
options[:dsym_filename] = dsym
|
53
|
+
else
|
54
|
+
is_android = File.extname(ipa) == '.apk'
|
55
|
+
puts 'dSYM not found! Unable to symbolicate crashes' unless is_android
|
56
|
+
end
|
57
|
+
options
|
24
58
|
end
|
25
59
|
|
26
|
-
def
|
27
|
-
|
28
|
-
raise '
|
29
|
-
|
30
|
-
@
|
60
|
+
def hockey_url(response)
|
61
|
+
config_url = response.body ? response.body['config_url'] : ''
|
62
|
+
raise 'Missing config_url' unless config_url
|
63
|
+
config_url.gsub!('https://upload.hockeyapp.net/', 'https://rink.hockeyapp.net/')
|
64
|
+
@upload_url = config_url
|
65
|
+
config_url
|
31
66
|
end
|
32
67
|
|
33
|
-
def
|
34
|
-
@
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
68
|
+
def validate_args(opts)
|
69
|
+
@token = opts.fetch :token, ENV['token']
|
70
|
+
@ipa = opts.fetch :ipa, ARGV.first
|
71
|
+
@build_url = opts.fetch :build_url, ENV['build_url']
|
72
|
+
@gerrit_env = opts.fetch :gerrit, ENV['GERRIT_REFSPEC']
|
73
|
+
@tries = opts.fetch :retry, 5
|
74
|
+
|
75
|
+
raise 'Must set token' unless token && token.is_a?(String) && !token.empty?
|
76
|
+
raise 'Must provide path to ipa' unless ipa
|
77
|
+
raise 'ipa doesn\'t exist' unless File.exist?(ipa)
|
78
|
+
raise 'Must provide build_url' unless build_url
|
79
|
+
raise 'Retry must be an int >= 1' unless tries && tries.is_a?(Integer) && tries >= 1
|
80
|
+
end
|
81
|
+
|
82
|
+
def run(opts = {})
|
83
|
+
validate_args opts
|
84
|
+
|
85
|
+
tries = @tries # required for tries to be in scope for 'retry'
|
86
|
+
|
87
|
+
puts "Uploading #{File.basename(ipa)}"
|
88
|
+
|
89
|
+
# http://support.hockeyapp.net/kb/api/api-versions#upload-version
|
90
|
+
begin
|
91
|
+
client = Shenzhen::Plugins::HockeyApp::Client.new(token)
|
92
|
+
|
93
|
+
options = configure_options
|
94
|
+
response = client.upload_build(ipa, options)
|
95
|
+
|
96
|
+
raise "Invalid response: #{response.body}" unless response.status == 201
|
97
|
+
puts "Build uploaded to: #{hockey_url(response)}"
|
98
|
+
rescue
|
99
|
+
puts "Retrying upload. #{tries} attempts remaining..." if tries > 1
|
100
|
+
retry unless (tries -= 1).zero?
|
101
|
+
raise
|
102
|
+
end
|
40
103
|
end
|
41
104
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# we only need the Hockey part of shenzhen
|
2
|
+
# https://github.com/nomad/shenzhen/blob/master/lib/shenzhen/plugins/hockeyapp.rb
|
3
|
+
|
4
|
+
=begin
|
5
|
+
Copyright (c) 2012–2015 Mattt Thompson (http://mattt.me/)
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
9
|
+
in the Software without restriction, including without limitation the rights
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
12
|
+
furnished to do so, subject to the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be included in
|
15
|
+
all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
THE SOFTWARE.
|
24
|
+
=end
|
25
|
+
|
26
|
+
module Shenzhen
|
27
|
+
end
|
28
|
+
|
29
|
+
require 'json'
|
30
|
+
require 'openssl'
|
31
|
+
require 'faraday'
|
32
|
+
require 'faraday_middleware'
|
33
|
+
|
34
|
+
module Shenzhen::Plugins
|
35
|
+
module HockeyApp
|
36
|
+
class Client
|
37
|
+
HOSTNAME = 'upload.hockeyapp.net'
|
38
|
+
|
39
|
+
def initialize(api_token)
|
40
|
+
@api_token = api_token
|
41
|
+
@connection = Faraday.new(:url => "https://#{HOSTNAME}") do |builder|
|
42
|
+
builder.request :multipart
|
43
|
+
builder.request :url_encoded
|
44
|
+
builder.response :json, :content_type => /\bjson$/
|
45
|
+
builder.use FaradayMiddleware::FollowRedirects
|
46
|
+
builder.adapter :net_http
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def upload_build(ipa, options)
|
51
|
+
options[:ipa] = Faraday::UploadIO.new(ipa, 'application/octet-stream') if ipa and File.exist?(ipa)
|
52
|
+
|
53
|
+
if dsym_filename = options.delete(:dsym_filename)
|
54
|
+
options[:dsym] = Faraday::UploadIO.new(dsym_filename, 'application/octet-stream')
|
55
|
+
end
|
56
|
+
|
57
|
+
@connection.post do |req|
|
58
|
+
if options[:public_identifier].nil?
|
59
|
+
req.url("/api/2/apps/upload")
|
60
|
+
else
|
61
|
+
req.url("/api/2/apps/#{options.delete(:public_identifier)}/app_versions/upload")
|
62
|
+
end
|
63
|
+
req.headers['X-HockeyAppToken'] = @api_token
|
64
|
+
req.body = options
|
65
|
+
end.on_complete do |env|
|
66
|
+
yield env[:status], env[:body] if block_given?
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/notes.md
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
```ruby
|
2
|
+
# ArgumentError: WebMock does not support matching body for multipart/form-data requests yet :(
|
3
|
+
# https://github.com/bblimke/webmock/issues/623
|
4
|
+
# expect(WebMock).to have_requested(http_method, http_uri).
|
5
|
+
# with(body: http_body, headers: http_headers)
|
6
|
+
````
|
metadata
CHANGED
@@ -1,15 +1,112 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hockey-gerrit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trevor Renshaw
|
8
|
+
- bootstraponline
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
12
|
+
date: 2016-05-28 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: faraday
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.9.2
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.9.2
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: faraday_middleware
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.10.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.10.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: safe_yaml
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.0'
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: 1.0.4
|
52
|
+
type: :development
|
53
|
+
prerelease: false
|
54
|
+
version_requirements: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - "~>"
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '1.0'
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.4
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: pry
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.10.3
|
69
|
+
type: :development
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.10.3
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: trace_files
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.0'
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.0'
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
name: webmock
|
92
|
+
requirement: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.0'
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 2.0.3
|
100
|
+
type: :development
|
101
|
+
prerelease: false
|
102
|
+
version_requirements: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - "~>"
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '2.0'
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 2.0.3
|
13
110
|
- !ruby/object:Gem::Dependency
|
14
111
|
name: bundler
|
15
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,9 +247,10 @@ dependencies:
|
|
150
247
|
- - ">="
|
151
248
|
- !ruby/object:Gem::Version
|
152
249
|
version: 0.8.3
|
153
|
-
description:
|
250
|
+
description: Uploads a build from gerrit/Jenkins to hockeyapp.
|
154
251
|
email:
|
155
252
|
- trenshaw@instructure.com
|
253
|
+
- code@bootstraponline.com
|
156
254
|
executables:
|
157
255
|
- hockey-gerrit
|
158
256
|
extensions: []
|
@@ -161,7 +259,6 @@ files:
|
|
161
259
|
- ".codeclimate.yml"
|
162
260
|
- ".coveralls.yml"
|
163
261
|
- ".gitignore"
|
164
|
-
- ".rspec"
|
165
262
|
- ".rubocop.yml"
|
166
263
|
- ".travis.yml"
|
167
264
|
- Gemfile
|
@@ -171,8 +268,10 @@ files:
|
|
171
268
|
- bin/hockey-gerrit
|
172
269
|
- hockey-gerrit.gemspec
|
173
270
|
- lib/hockey_gerrit.rb
|
271
|
+
- lib/hockey_gerrit/shenzhen.rb
|
174
272
|
- lib/hockey_gerrit/version.rb
|
175
|
-
|
273
|
+
- notes.md
|
274
|
+
homepage: https://github.com/instructure/hockey-gerrit
|
176
275
|
licenses:
|
177
276
|
- Apache-2.0
|
178
277
|
metadata: {}
|
@@ -195,5 +294,5 @@ rubyforge_project:
|
|
195
294
|
rubygems_version: 2.6.4
|
196
295
|
signing_key:
|
197
296
|
specification_version: 4
|
198
|
-
summary:
|
297
|
+
summary: Uploads a build from gerrit/Jenkins to hockeyapp
|
199
298
|
test_files: []
|
data/.rspec
DELETED