inch_ci-worker 0.2.12 → 0.2.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/inch_ci-worker +8 -1
- data/inch_ci-worker.gemspec +2 -2
- data/lib/inch_ci/worker/build/badge_detector.rb +32 -0
- data/lib/inch_ci/worker/build/report.rb +2 -0
- data/lib/inch_ci/worker/build/result.rb +1 -0
- data/lib/inch_ci/worker/build/task.rb +15 -6
- data/lib/inch_ci/worker/version.rb +1 -1
- data/test/integration/badge_detector_test.rb +36 -0
- data/test/integration/inch_version_test.rb +21 -0
- data/test/unit/worker/build/badge_detector_test.rb +20 -0
- metadata +16 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a72eee7a66a5707cec965706ff712db4c709968
|
4
|
+
data.tar.gz: 09a6d9d47206de9a98b1cb82670d1c854331fbe8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff13541b4254abc0add380c990859a09df1e42c5d6ad1360aa95fc15b091dd506bde34de73fe4ae13dad12ac559be02bba44a6fb548ee85c93423557d2d9e03d
|
7
|
+
data.tar.gz: 41160a5f21f5b2ef19f7cb8e677f77f76994215a44f800d9a65731f30a836a3266a4e3c7ed3d41dd6e3261658dea07c6070df22d1a8f97e546a5c284fbf0a56a
|
data/bin/inch_ci-worker
CHANGED
@@ -27,9 +27,16 @@ class Command
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
class Version
|
31
|
+
def initialize(*args)
|
32
|
+
puts InchCI::Worker::VERSION
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
30
36
|
MAP = {
|
31
37
|
'build' => Build,
|
32
|
-
'list-tags' => ListTags
|
38
|
+
'list-tags' => ListTags,
|
39
|
+
'-v' => Version,
|
33
40
|
}
|
34
41
|
|
35
42
|
def self.run(command_name, args)
|
data/inch_ci-worker.gemspec
CHANGED
@@ -23,6 +23,6 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "simplecov"
|
24
24
|
spec.add_development_dependency "pry"
|
25
25
|
|
26
|
-
spec.add_dependency
|
27
|
-
spec.add_dependency "
|
26
|
+
spec.add_dependency "inch", ">= 0.5.0.rc3"
|
27
|
+
spec.add_dependency "repomen", ">= 0.2.0.rc1"
|
28
28
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module InchCI
|
2
|
+
module Worker
|
3
|
+
module Build
|
4
|
+
class BadgeDetector
|
5
|
+
def self.in_readme?(repo, info)
|
6
|
+
if filename = find_readme(repo)
|
7
|
+
contents = File.read(filename, :encoding => 'utf-8')
|
8
|
+
new(contents, info).detected?
|
9
|
+
else
|
10
|
+
false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [String] filename
|
15
|
+
def self.find_readme(repo)
|
16
|
+
Dir[File.join(repo.path, '*.*')].detect do |f|
|
17
|
+
File.basename(f) =~ /\Areadme\./i
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(contents, info)
|
22
|
+
@contents = contents
|
23
|
+
@pattern = Regexp.escape("inch-ci.org/#{info.service_name}/#{info.user_name}/#{info.repo_name}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def detected?
|
27
|
+
!!( @contents =~ /#{@pattern}/mi )
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -22,6 +22,8 @@ module InchCI
|
|
22
22
|
data['service_name'] = build.service_name.to_s if build.service_name
|
23
23
|
data['user_name'] = build.user_name if build.user_name
|
24
24
|
data['repo_name'] = build.repo_name if build.repo_name
|
25
|
+
data['badge_in_readme'] = build.badge_in_readme
|
26
|
+
data['inch_version'] = ::Inch::VERSION
|
25
27
|
if build.revision_uid
|
26
28
|
data['revision_uid'] = build.revision_uid
|
27
29
|
data['revision_message'] = build.revision_message
|
@@ -1,9 +1,10 @@
|
|
1
|
+
require 'tmpdir'
|
1
2
|
require 'inch'
|
2
3
|
require 'repomen'
|
3
|
-
require 'tmpdir'
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
require 'inch_ci/worker/build/result'
|
6
|
+
require 'inch_ci/worker/build/report'
|
7
|
+
require 'inch_ci/worker/build/badge_detector'
|
7
8
|
|
8
9
|
module InchCI
|
9
10
|
module Worker
|
@@ -21,18 +22,25 @@ module InchCI
|
|
21
22
|
@result.started_at = started_at
|
22
23
|
puts Report.new(@result).to_yaml
|
23
24
|
ensure
|
24
|
-
FileUtils.remove_entry @work_dir
|
25
|
+
FileUtils.remove_entry(@work_dir) unless @work_dir.nil?
|
25
26
|
end
|
26
27
|
|
27
28
|
private
|
28
29
|
|
30
|
+
# @param info [#service_name,#user_name,#repo_name]
|
31
|
+
def badge_in_readme?(info)
|
32
|
+
BadgeDetector.in_readme?(repo, info)
|
33
|
+
end
|
34
|
+
|
29
35
|
def build(url, branch_name, revision, latest_revision)
|
30
36
|
@url = url
|
31
37
|
if retrieve_repo
|
32
38
|
if repo.change_branch(branch_name, true)
|
33
39
|
if repo.checkout_revision(revision)
|
34
40
|
if @codebase = parse_codebase(repo.path)
|
35
|
-
ResultSuccess.new(repo, branch_name, latest_revision, @codebase.objects)
|
41
|
+
result = ResultSuccess.new(repo, branch_name, latest_revision, @codebase.objects)
|
42
|
+
result.badge_in_readme = badge_in_readme?(result)
|
43
|
+
result
|
36
44
|
else
|
37
45
|
ResultParserFailed.new(repo, branch_name, latest_revision, nil)
|
38
46
|
end
|
@@ -51,7 +59,8 @@ module InchCI
|
|
51
59
|
YARD::Config.options[:safe_mode] = true
|
52
60
|
begin
|
53
61
|
::Inch::Codebase.parse(path)
|
54
|
-
rescue
|
62
|
+
rescue Exception => e
|
63
|
+
warn e
|
55
64
|
nil
|
56
65
|
end
|
57
66
|
end
|
@@ -0,0 +1,36 @@
|
|
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) { 'https://github.com/rrrene/inch.git' }
|
7
|
+
let(:incorrect_url) { 'https://github.com/rrrene/tipsy.hovercard.git' }
|
8
|
+
|
9
|
+
#
|
10
|
+
# Good scenario
|
11
|
+
#
|
12
|
+
|
13
|
+
it 'should show badge in readme' 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_match /badge_in_readme: true/, out
|
20
|
+
assert err.empty?
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# Bad scenario
|
25
|
+
#
|
26
|
+
|
27
|
+
it 'should show no badge in readme' do
|
28
|
+
out, err = capture_io do
|
29
|
+
@task = described_class.new(incorrect_url, branch_name)
|
30
|
+
end
|
31
|
+
refute out.empty?
|
32
|
+
assert_match /status: success/, out
|
33
|
+
assert_match /badge_in_readme: false/, out
|
34
|
+
assert err.empty?
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,21 @@
|
|
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) { 'https://github.com/rrrene/sparkr.git' }
|
7
|
+
|
8
|
+
#
|
9
|
+
# Good scenario
|
10
|
+
#
|
11
|
+
|
12
|
+
it 'should retrieve the repo' do
|
13
|
+
out, err = capture_io do
|
14
|
+
@task = described_class.new(url, branch_name)
|
15
|
+
end
|
16
|
+
refute out.empty?
|
17
|
+
assert_match /status: success/, out
|
18
|
+
assert_match /inch_version: \d+\.\d+\.\d+/, out
|
19
|
+
assert err.empty?
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../test_helper')
|
2
|
+
|
3
|
+
describe ::InchCI::Worker::Build::BadgeDetector do
|
4
|
+
let(:described_class) { ::InchCI::Worker::Build::BadgeDetector }
|
5
|
+
let(:info_mock) {
|
6
|
+
OpenStruct.new(:service_name => 'github', :user_name => 'user_name', :repo_name => 'repo_name')
|
7
|
+
}
|
8
|
+
let(:with_badge) {
|
9
|
+
"RepoName\n======\n\n[![Code Climate](https://codeclimate.com/github/user_name/repo_name.png)](https://codeclimate.com/github/user_name/repo_name)\n[![Inline docs](http://inch-ci.org/github/user_name/repo_name.svg?branch=master)](http://inch-ci.org/github/user_name/repo_name)\n\nThink of it like Homebrew for Minecraft.\n\nOf course where every individual projects gets it's own Formula,\n this allowing for mods to declare their runtime dependencies\n and making installing mods more or less painless.\n \n### Requirments\n\nTo run repo_name on your system you a few pieces of software installed. If you use your computer for any sort of development, or your computer runs Mac OS X or any of the main Linux distros, it is likely you already have this software installed. To make sure that your computer is ready to brew Minecraft be sure to check the [wiki page](https://github.com/user_name/repo_name/wiki/Requirements) on requirements for each platform.\n\n### Install\n\nMuch like the inspiring project of this project, installation is simple.\n\nRun this line of code in your system's command prompt and let it walk you through what it is doing.\n\n> On Mac OS X or any other system that uses curl:\n```\nruby -e \"$(curl -fsSL https://raw.github.com/user_name/repo_name/go/install)\"\n```\n\n> On most Linux distros:\n```\nruby -e \"$(wget -O- https://raw.github.com/user_name/repo_name/go/install)\"\n```\n\n> Using Windows PowerShell\n```\n$storageDir = #env.TEMP\n$webclient = New-Object System.Net.WebClient\n$url = \"https://raw.github.com/user_name/repo_name/go/install\"\n$file = \"$storageDir\\repo_name-install\"\n$webclient.DownloadFile($url,$file)\nStart-Process \"$storageDir\\repo_name-install\"\n```\n"
|
10
|
+
}
|
11
|
+
let(:with_badge_single_line) {
|
12
|
+
"[![Code Climate](https://codeclimate.com/github/user_name/repo_name.png)](https://codeclimate.com/github/user_name/repo_name)\n\n\n[![Inline docs](http://inch-ci.org/github/user_name/repo_name.png?branch=master)](http://inch-ci.org/github/user_name/repo_name)"
|
13
|
+
}
|
14
|
+
|
15
|
+
it "should detect badge" do
|
16
|
+
[with_badge, with_badge_single_line].each do |str|
|
17
|
+
assert described_class.new(str, info_mock).detected?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inch_ci-worker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- René Föhring
|
@@ -67,33 +67,33 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: inch
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 0.5.0.rc3
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 0.5.0.rc3
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: repomen
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.2.0.rc1
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.2.0.rc1
|
97
97
|
description: ''
|
98
98
|
email:
|
99
99
|
- rf@bamaru.de
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- inch_ci-worker.gemspec
|
114
114
|
- lib/inch_ci/worker.rb
|
115
115
|
- lib/inch_ci/worker/build.rb
|
116
|
+
- lib/inch_ci/worker/build/badge_detector.rb
|
116
117
|
- lib/inch_ci/worker/build/report.rb
|
117
118
|
- lib/inch_ci/worker/build/result.rb
|
118
119
|
- lib/inch_ci/worker/build/task.rb
|
@@ -120,8 +121,11 @@ files:
|
|
120
121
|
- lib/inch_ci/worker/list_tags/report.rb
|
121
122
|
- lib/inch_ci/worker/list_tags/task.rb
|
122
123
|
- lib/inch_ci/worker/version.rb
|
124
|
+
- test/integration/badge_detector_test.rb
|
123
125
|
- test/integration/build_test.rb
|
126
|
+
- test/integration/inch_version_test.rb
|
124
127
|
- test/test_helper.rb
|
128
|
+
- test/unit/worker/build/badge_detector_test.rb
|
125
129
|
homepage: https://github.com/inch-ci/inch_ci-worker
|
126
130
|
licenses:
|
127
131
|
- MIT
|
@@ -147,6 +151,9 @@ signing_key:
|
|
147
151
|
specification_version: 4
|
148
152
|
summary: Worker for the Inch CI project
|
149
153
|
test_files:
|
154
|
+
- test/integration/badge_detector_test.rb
|
150
155
|
- test/integration/build_test.rb
|
156
|
+
- test/integration/inch_version_test.rb
|
151
157
|
- test/test_helper.rb
|
158
|
+
- test/unit/worker/build/badge_detector_test.rb
|
152
159
|
has_rdoc:
|