inch_ci-worker 0.2.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 +7 -0
- data/.gitignore +22 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +8 -0
- data/bin/inch_ci-worker +47 -0
- data/inch_ci-worker.gemspec +27 -0
- data/lib/inch_ci/worker/build/report.rb +78 -0
- data/lib/inch_ci/worker/build/result.rb +81 -0
- data/lib/inch_ci/worker/build/task.rb +69 -0
- data/lib/inch_ci/worker/build.rb +8 -0
- data/lib/inch_ci/worker/list_tags/report.rb +19 -0
- data/lib/inch_ci/worker/list_tags/task.rb +53 -0
- data/lib/inch_ci/worker/list_tags.rb +10 -0
- data/lib/inch_ci/worker/version.rb +5 -0
- data/lib/inch_ci/worker.rb +15 -0
- data/test/integration/build_test.rb +109 -0
- data/test/test_helper.rb +7 -0
- metadata +138 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2d8e5c139f7993f520ee717f19c37eca754583f3
|
4
|
+
data.tar.gz: 5eba432e0dfda541f9cc59ff3a87ac8b812aa257
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d1979a0695fa591d823e934a4d8fdff77b7b9c5c469740898bd4bb5b7be45e8deb857f4ed02ccc44ed77abf797f90e487889e7b1cdb64891f7201a19d8d9cfef
|
7
|
+
data.tar.gz: 57ed86823276f198cff450d2d43fc38556fd06fb3ce0a6016114b996ee8ede438127a8a0d58eb26b5a752e7c97013a6587736301409cedd50061deab5c0a3791
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inch_ci
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.0
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 René Föhring
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# InchCi::Worker
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'inch_ci-worker'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install inch_ci-worker
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/inch_ci-worker/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/inch_ci-worker
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# @return [String] the path to the 'lib' directory of Inch
|
4
|
+
def find_lib_path
|
5
|
+
path = __FILE__
|
6
|
+
while File.symlink?(path)
|
7
|
+
path = File.expand_path(File.readlink(path), File.dirname(path))
|
8
|
+
end
|
9
|
+
File.join(File.dirname(File.expand_path(path)), '..', 'lib')
|
10
|
+
end
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(find_lib_path)
|
13
|
+
|
14
|
+
require 'bundler/setup'
|
15
|
+
require 'inch_ci/worker'
|
16
|
+
|
17
|
+
class Command
|
18
|
+
class Build
|
19
|
+
def initialize(url, branch_name = nil, revision = nil)
|
20
|
+
InchCI::Worker::Build::Task.new(url, branch_name, revision)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class ListTags
|
25
|
+
def initialize(url, branch_name)
|
26
|
+
InchCI::Worker::ListTags::Task.new(url, branch_name)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
MAP = {
|
31
|
+
'build' => Build,
|
32
|
+
'list-tags' => ListTags
|
33
|
+
}
|
34
|
+
|
35
|
+
def self.run(command_name, args)
|
36
|
+
if command_class = MAP[command_name]
|
37
|
+
command_class.new(*args)
|
38
|
+
else
|
39
|
+
puts "Unrecognized command: #{command_name}".color(:red)
|
40
|
+
puts "Valid commands: #{MAP.keys.sort.join(', ')}"
|
41
|
+
exit 1
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
command_name = ARGV.shift
|
47
|
+
Command.run(command_name, ARGV)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'inch_ci/worker/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "inch_ci-worker"
|
8
|
+
spec.version = InchCI::Worker::VERSION
|
9
|
+
spec.authors = ["René Föhring"]
|
10
|
+
spec.email = ["rf@bamaru.de"]
|
11
|
+
spec.summary = %q{Worker for the Inch CI project}
|
12
|
+
spec.description = %q{}
|
13
|
+
spec.homepage = "https://github.com/inch-ci/inch_ci-worker"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "simplecov"
|
24
|
+
spec.add_development_dependency "pry"
|
25
|
+
|
26
|
+
spec.add_dependency "inch", "~> 0.4"
|
27
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module InchCI
|
4
|
+
module Worker
|
5
|
+
module Build
|
6
|
+
class Report < Struct.new(:build)
|
7
|
+
def to_yaml
|
8
|
+
to_hash.to_yaml
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def to_hash
|
14
|
+
data = {
|
15
|
+
'status' => build.status,
|
16
|
+
'repo_url' => build.url,
|
17
|
+
'branch_name' => build.branch_name,
|
18
|
+
'started_at' => build.started_at,
|
19
|
+
'finished_at' => build.started_at,
|
20
|
+
'latest_revision' => build.latest_revision,
|
21
|
+
}
|
22
|
+
data['service_name'] = build.service_name.to_s if build.service_name
|
23
|
+
data['user_name'] = build.user_name if build.user_name
|
24
|
+
data['repo_name'] = build.repo_name if build.repo_name
|
25
|
+
if build.revision_uid
|
26
|
+
data['revision_uid'] = build.revision_uid
|
27
|
+
data['revision_message'] = build.revision_message
|
28
|
+
data['revision_author_name'] = build.revision_author_name
|
29
|
+
data['revision_author_email'] = build.revision_author_email
|
30
|
+
data['revision_authored_at'] = build.revision_authored_at
|
31
|
+
end
|
32
|
+
data['tag'] = build.tag_uid if build.tag_uid
|
33
|
+
data['objects'] = objects_hash if build.objects
|
34
|
+
{'build' => data}
|
35
|
+
end
|
36
|
+
|
37
|
+
def objects_hash
|
38
|
+
build.objects.map do |o|
|
39
|
+
code_object_to_hash(o)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def code_object_to_hash(o)
|
44
|
+
{
|
45
|
+
'type' => o.type.gsub('Inch::CodeObject::Proxy::', ''),
|
46
|
+
'fullname' => o.fullname,
|
47
|
+
'docstring' => o.original_docstring.to_s,
|
48
|
+
'score' => o.score.to_i,
|
49
|
+
'grade' => o.grade.to_s,
|
50
|
+
'priority' => o.priority.to_i,
|
51
|
+
'location' => location(o.files.first),
|
52
|
+
'roles' => o.roles.map { |r| role_to_hash(o, r) },
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def location(file)
|
57
|
+
return unless file
|
58
|
+
"#{file.relative_path}:#{file.line_no}"
|
59
|
+
end
|
60
|
+
|
61
|
+
def role_to_hash(object, role)
|
62
|
+
ref_name = role.object.fullname
|
63
|
+
name = role.class.to_s.gsub('Inch::Evaluation::Role::', '')
|
64
|
+
hash = {
|
65
|
+
'name' => name,
|
66
|
+
'priority' => role.priority,
|
67
|
+
}
|
68
|
+
hash['potential_score'] = role.potential_score if role.potential_score
|
69
|
+
hash['score'] = role.score if role.score
|
70
|
+
hash['min_score'] = role.min_score if role.min_score
|
71
|
+
hash['max_score'] = role.max_score if role.max_score
|
72
|
+
hash['ref_name'] = ref_name if object.fullname != ref_name
|
73
|
+
hash
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module InchCI
|
2
|
+
module Worker
|
3
|
+
module Build
|
4
|
+
class Result < Struct.new(:repo, :branch_name, :latest_revision, :objects)
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
def_delegators :repo, :url
|
8
|
+
def_delegators :repo, :service_name, :user_name, :repo_name
|
9
|
+
def_delegators :repo, :revision_message
|
10
|
+
def_delegators :repo, :revision_author_name
|
11
|
+
def_delegators :repo, :revision_author_email
|
12
|
+
def_delegators :repo, :revision_authored_at
|
13
|
+
|
14
|
+
attr_accessor :started_at
|
15
|
+
attr_accessor :finished_at
|
16
|
+
attr_writer :status
|
17
|
+
|
18
|
+
def duration
|
19
|
+
finished_at - started_at
|
20
|
+
end
|
21
|
+
|
22
|
+
def revision_uid
|
23
|
+
repo.revision
|
24
|
+
end
|
25
|
+
|
26
|
+
def status
|
27
|
+
@status || 'error'
|
28
|
+
end
|
29
|
+
|
30
|
+
def tag_uid
|
31
|
+
repo.tag.empty? ? nil : repo.tag
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class ResultSuccess < Result
|
36
|
+
def status
|
37
|
+
'success'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class ResultFail < Result
|
42
|
+
def revision_uid; nil; end
|
43
|
+
def revision_message; nil; end
|
44
|
+
def revision_author_name; nil; end
|
45
|
+
def revision_author_email; nil; end
|
46
|
+
def revision_authored_at; nil; end
|
47
|
+
def tag_uid; nil; end
|
48
|
+
def service_name; nil; end
|
49
|
+
def user_name; nil; end
|
50
|
+
def repo_name; nil; end
|
51
|
+
def status
|
52
|
+
'failed'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class ResultRetrieverFailed < ResultFail
|
57
|
+
def status
|
58
|
+
'failed:retriever'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class ResultChangeBranchFailed < ResultFail
|
63
|
+
def status
|
64
|
+
'failed:change_branch'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class ResultCheckoutRevisionFailed < ResultFail
|
69
|
+
def status
|
70
|
+
'failed:checkout_revision'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class ResultParserFailed < ResultFail
|
75
|
+
def status
|
76
|
+
'failed:parser'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'inch'
|
2
|
+
require 'repomen'
|
3
|
+
|
4
|
+
require_relative 'result'
|
5
|
+
require_relative 'report'
|
6
|
+
|
7
|
+
module InchCI
|
8
|
+
module Worker
|
9
|
+
module Build
|
10
|
+
class Task
|
11
|
+
def initialize(url, branch_name = 'master', revision = nil)
|
12
|
+
@work_dir = Dir.mktmpdir
|
13
|
+
if revision.nil?
|
14
|
+
revision = 'HEAD'
|
15
|
+
@latest_revision = true
|
16
|
+
end
|
17
|
+
started_at = Time.now
|
18
|
+
@result = build(url, branch_name, revision, !!@latest_revision)
|
19
|
+
@result.finished_at = Time.now
|
20
|
+
@result.started_at = started_at
|
21
|
+
puts Report.new(@result).to_yaml
|
22
|
+
ensure
|
23
|
+
FileUtils.remove_entry @work_dir
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def build(url, branch_name, revision, latest_revision)
|
29
|
+
@url = url
|
30
|
+
if retrieve_repo
|
31
|
+
if repo.change_branch(branch_name, true)
|
32
|
+
if repo.checkout_revision(revision)
|
33
|
+
if @codebase = parse_codebase(repo.path)
|
34
|
+
ResultSuccess.new(repo, branch_name, latest_revision, @codebase.objects)
|
35
|
+
else
|
36
|
+
ResultParserFailed.new(repo, branch_name, latest_revision, nil)
|
37
|
+
end
|
38
|
+
else
|
39
|
+
ResultCheckoutRevisionFailed.new(repo, branch_name, latest_revision, nil)
|
40
|
+
end
|
41
|
+
else
|
42
|
+
ResultChangeBranchFailed.new(repo, branch_name, latest_revision, nil)
|
43
|
+
end
|
44
|
+
else
|
45
|
+
ResultRetrieverFailed.new(repo, branch_name, latest_revision, nil)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def parse_codebase(path)
|
50
|
+
YARD::Config.options[:safe_mode] = true
|
51
|
+
begin
|
52
|
+
::Inch::Codebase.parse(path)
|
53
|
+
rescue
|
54
|
+
nil
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def repo
|
59
|
+
@repo ||= Repomen::Retriever.new(@url, :work_dir => @work_dir)
|
60
|
+
end
|
61
|
+
|
62
|
+
# @return [Repomen::Retriever,nil] either the retrieved repo or +nil+
|
63
|
+
def retrieve_repo
|
64
|
+
repo.retrieved? ? repo : nil
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'inch'
|
2
|
+
require 'repomen'
|
3
|
+
|
4
|
+
require_relative 'report'
|
5
|
+
|
6
|
+
module InchCI
|
7
|
+
module Worker
|
8
|
+
module ListTags
|
9
|
+
class Task
|
10
|
+
def initialize(url, branch_name = 'master')
|
11
|
+
@work_dir = Dir.mktmpdir
|
12
|
+
@url = url
|
13
|
+
@branch_name = branch_name
|
14
|
+
puts Report.new(build_tag_list).to_yaml
|
15
|
+
ensure
|
16
|
+
FileUtils.remove_entry @work_dir
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def build_tag_list
|
22
|
+
if retrieve_repo
|
23
|
+
if repo.change_branch(@branch_name, true)
|
24
|
+
tag_list
|
25
|
+
else
|
26
|
+
# ChangeBranchFailed
|
27
|
+
end
|
28
|
+
else
|
29
|
+
# RetrieverFailed
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def repo
|
34
|
+
@repo ||= Repomen::Retriever.new(@url, :work_dir => @work_dir)
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [Repomen::Retriever,nil] either the retrieved repo or +nil+
|
38
|
+
def retrieve_repo
|
39
|
+
repo.retrieved? ? repo : nil
|
40
|
+
end
|
41
|
+
|
42
|
+
def tag_list
|
43
|
+
Dir.chdir(repo.path) do
|
44
|
+
output = `git for-each-ref --sort='taggerdate' refs/tags`
|
45
|
+
output.lines.map do |line|
|
46
|
+
line.split("\t").last.gsub('refs/tags/', '').chomp
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'repomen'
|
2
|
+
|
3
|
+
# Set the directory where checked out repos are kept
|
4
|
+
Repomen.config.work_dir = ENV['REPOMEN_WORK_DIR'] || File.join(__dir__, '..', '..', 'tmp')
|
5
|
+
|
6
|
+
# Check out the whole history
|
7
|
+
Repomen.config.only_last_revision = false
|
8
|
+
|
9
|
+
module InchCI
|
10
|
+
module Worker
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'inch_ci/worker/build'
|
15
|
+
require 'inch_ci/worker/list_tags'
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
|
3
|
+
describe ::InchCI::Worker::Build do
|
4
|
+
let(:described_class) { ::InchCI::Worker::Build::Task }
|
5
|
+
let(:branch_name) { 'master' }
|
6
|
+
let(:url) { 'git@bitbucket.org:atlassian_tutorial/helloworld.git' }
|
7
|
+
let(:incorrect_url) { 'git@bitbucket.org:atlassian_tutorial/helloworld123.git' }
|
8
|
+
|
9
|
+
#
|
10
|
+
# Good scenarios
|
11
|
+
#
|
12
|
+
|
13
|
+
it 'should retrieve the repo' do
|
14
|
+
out, err = capture_io do
|
15
|
+
@task = described_class.new(url, branch_name)
|
16
|
+
end
|
17
|
+
refute out.empty?
|
18
|
+
assert_match /status: success/, out
|
19
|
+
assert err.empty?
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should retrieve the repo and checkout revision' do
|
23
|
+
skip # helloworld doesnot have tags
|
24
|
+
# TODO: make own helloworld repo
|
25
|
+
out, err = capture_io do
|
26
|
+
@task = described_class.new(url, branch_name, 'v0.1.0')
|
27
|
+
end
|
28
|
+
refute out.empty?
|
29
|
+
assert_match /status: success/, out
|
30
|
+
assert err.empty?
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# Deal with invalid parameters
|
35
|
+
#
|
36
|
+
|
37
|
+
it "should not retrieve non-existing branch in repo" do
|
38
|
+
out, err = capture_io do
|
39
|
+
@task = described_class.new(url, 'somebranch')
|
40
|
+
end
|
41
|
+
refute out.empty?
|
42
|
+
assert_match /status: failed:change_branch/, out
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should not retrieve non-existing revision in repo" do
|
46
|
+
out, err = capture_io do
|
47
|
+
@task = described_class.new(url, branch_name, 'vX.X.X')
|
48
|
+
end
|
49
|
+
refute out.empty?
|
50
|
+
assert_match /status: failed:checkout_revision/, out
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
# Deal with not existing repos, whatever the parameters are
|
55
|
+
#
|
56
|
+
|
57
|
+
it "should not retrieve non-existing repo" do
|
58
|
+
out, err = capture_io do
|
59
|
+
@task = described_class.new(incorrect_url, branch_name)
|
60
|
+
end
|
61
|
+
refute out.empty?
|
62
|
+
assert_match /status: failed:retriever/, out
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should not retrieve non-existing branch in non-existing repo" do
|
66
|
+
out, err = capture_io do
|
67
|
+
@task = described_class.new(incorrect_url, 'somebranch')
|
68
|
+
end
|
69
|
+
refute out.empty?
|
70
|
+
assert_match /status: failed:retriever/, out
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should not retrieve non-existing revision in non-existing repo" do
|
74
|
+
out, err = capture_io do
|
75
|
+
@task = described_class.new(incorrect_url, branch_name, 'vX.X.X')
|
76
|
+
end
|
77
|
+
refute out.empty?
|
78
|
+
assert_match /status: failed:retriever/, out
|
79
|
+
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# Deal with errors thrown by Inch itself
|
83
|
+
#
|
84
|
+
|
85
|
+
module ::Inch::Codebase
|
86
|
+
class << self
|
87
|
+
alias :parse_original :parse
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should not retrieve error throwing repo" do
|
92
|
+
# Patch the Parser to fail
|
93
|
+
codebase = ::Inch::Codebase
|
94
|
+
def codebase.parse(*args)
|
95
|
+
raise "Vending machine is broken!"
|
96
|
+
end
|
97
|
+
|
98
|
+
out, err = capture_io do
|
99
|
+
@task = described_class.new(url, branch_name)
|
100
|
+
end
|
101
|
+
refute out.empty?
|
102
|
+
assert_match /status: failed:parser/, out
|
103
|
+
|
104
|
+
# Let's repair the Parser
|
105
|
+
def codebase.parse(*args)
|
106
|
+
parse_original(*args)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: inch_ci-worker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- René Föhring
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: simplecov
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: inch
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.4'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.4'
|
83
|
+
description: ''
|
84
|
+
email:
|
85
|
+
- rf@bamaru.de
|
86
|
+
executables:
|
87
|
+
- inch_ci-worker
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".ruby-gemset"
|
93
|
+
- ".ruby-version"
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/inch_ci-worker
|
99
|
+
- inch_ci-worker.gemspec
|
100
|
+
- lib/inch_ci/worker.rb
|
101
|
+
- lib/inch_ci/worker/build.rb
|
102
|
+
- lib/inch_ci/worker/build/report.rb
|
103
|
+
- lib/inch_ci/worker/build/result.rb
|
104
|
+
- lib/inch_ci/worker/build/task.rb
|
105
|
+
- lib/inch_ci/worker/list_tags.rb
|
106
|
+
- lib/inch_ci/worker/list_tags/report.rb
|
107
|
+
- lib/inch_ci/worker/list_tags/task.rb
|
108
|
+
- lib/inch_ci/worker/version.rb
|
109
|
+
- test/integration/build_test.rb
|
110
|
+
- test/test_helper.rb
|
111
|
+
homepage: https://github.com/inch-ci/inch_ci-worker
|
112
|
+
licenses:
|
113
|
+
- MIT
|
114
|
+
metadata: {}
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
requirements: []
|
130
|
+
rubyforge_project:
|
131
|
+
rubygems_version: 2.2.0
|
132
|
+
signing_key:
|
133
|
+
specification_version: 4
|
134
|
+
summary: Worker for the Inch CI project
|
135
|
+
test_files:
|
136
|
+
- test/integration/build_test.rb
|
137
|
+
- test/test_helper.rb
|
138
|
+
has_rdoc:
|