build_eval 0.0.9 → 0.0.10
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 +8 -8
- data/lib/build_eval/server/travis.rb +5 -7
- data/lib/build_eval/server/travis_pro.rb +3 -2
- data/lib/build_eval/travis.rb +21 -0
- data/lib/build_eval/version.rb +1 -1
- data/lib/build_eval.rb +1 -0
- data/spec/lib/build_eval/server/travis_pro_spec.rb +17 -46
- data/spec/lib/build_eval/server/travis_spec.rb +16 -44
- data/spec/lib/build_eval/travis_shared_context.rb +7 -0
- data/spec/lib/build_eval/travis_spec.rb +94 -0
- data/spec/lib/build_eval_smoke_spec.rb +8 -5
- data/spec/spec_helper.rb +2 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Y2RmM2FlM2IyNDIwNGI2YmRmZjM0ODkyOTU1Y2MxNzBiZmEyNjY4MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTRkNzVhNjY0Njg5Y2NhZWMwN2Q2Y2NjMzYxYmEyZDZlODQxNTNiNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2FiMDJhZjdlYTA0Yzg0NGU2NDMyMTJhMjk4MTYzYzBhNTY5ZDA2OTAyODlm
|
10
|
+
YmFlMWRmOWJiZDE2Y2VkOWEyODA4MWFkOTM4NmI0ZjcwZDNhMzE5MzhmNmI2
|
11
|
+
ZTFlNjYwMzlhOWE1ODBjMGM4ZTJiMGIwNTk2YWQ2Y2U1NjU4NDY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDZiYjI2Yzg4OWRhNWE2YmM0OGMzMjE3YmE2NDQ1MTZhYzQwNDY0ZjQwZGNi
|
14
|
+
ODBmNmFiOGI3YTc2NjY5ZDg3NzY0YTM0ZjRmZmI2ZGU2Y2Q0MWY4NDlhOWIw
|
15
|
+
NzI1MWQ3ZjhiMzg3YzQ5OWYwMDc5NWI4NTkxODg3ODYxMWEzMWM=
|
@@ -5,23 +5,21 @@ module BuildEval
|
|
5
5
|
|
6
6
|
def initialize(args)
|
7
7
|
@username = args[:username]
|
8
|
+
@travis = BuildEval::Travis.new(::Travis)
|
8
9
|
end
|
9
10
|
|
10
11
|
def build_result(name)
|
11
12
|
build_path = "#{@username}/#{name}"
|
12
|
-
BuildEval::Result::BuildResult.create(
|
13
|
+
BuildEval::Result::BuildResult.create(
|
14
|
+
build_name: build_path,
|
15
|
+
status_name: @travis.last_build_status_for(build_path)
|
16
|
+
)
|
13
17
|
end
|
14
18
|
|
15
19
|
def to_s
|
16
20
|
"Travis CI #{@username}"
|
17
21
|
end
|
18
22
|
|
19
|
-
private
|
20
|
-
|
21
|
-
def last_status_name(build_path)
|
22
|
-
::Travis::Repository.find(build_path).recent_builds.find(&:finished?).passed? ? "Success" : "Failure"
|
23
|
-
end
|
24
|
-
|
25
23
|
end
|
26
24
|
|
27
25
|
end
|
@@ -6,6 +6,7 @@ module BuildEval
|
|
6
6
|
def initialize(args)
|
7
7
|
@username = args[:username]
|
8
8
|
@github_token = args[:github_token]
|
9
|
+
@travis = BuildEval::Travis.new(::Travis::Pro)
|
9
10
|
end
|
10
11
|
|
11
12
|
def build_result(name)
|
@@ -20,8 +21,8 @@ module BuildEval
|
|
20
21
|
private
|
21
22
|
|
22
23
|
def last_status_name(build_path)
|
23
|
-
|
24
|
-
|
24
|
+
@travis.login(@github_token)
|
25
|
+
@travis.last_build_status_for(build_path)
|
25
26
|
end
|
26
27
|
|
27
28
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module BuildEval
|
2
|
+
|
3
|
+
class Travis
|
4
|
+
|
5
|
+
def initialize(travis_module)
|
6
|
+
@travis_module = travis_module
|
7
|
+
end
|
8
|
+
|
9
|
+
def login(auth_token)
|
10
|
+
@travis_module.github_auth(auth_token)
|
11
|
+
end
|
12
|
+
|
13
|
+
def last_build_status_for(build_path)
|
14
|
+
@travis_module::Repository.find(build_path).recent_builds.find(&:finished?).passed? ? "Success" : "Failure"
|
15
|
+
rescue ::Travis::Client::Error
|
16
|
+
"Unknown"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/lib/build_eval/version.rb
CHANGED
data/lib/build_eval.rb
CHANGED
@@ -7,6 +7,7 @@ require 'travis/tools/github'
|
|
7
7
|
|
8
8
|
require_relative 'build_eval/error'
|
9
9
|
require_relative 'build_eval/http'
|
10
|
+
require_relative 'build_eval/travis'
|
10
11
|
require_relative 'build_eval/result/status'
|
11
12
|
require_relative 'build_eval/result/build_result'
|
12
13
|
require_relative 'build_eval/result/server_result'
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe BuildEval::Server::TravisPro do
|
2
|
-
include_context "stubbed
|
2
|
+
include_context "stubbed Travis API interactions"
|
3
3
|
|
4
4
|
let(:username) { "some_username" }
|
5
5
|
let(:github_token) { "ABCD1234" }
|
@@ -14,45 +14,32 @@ describe BuildEval::Server::TravisPro do
|
|
14
14
|
|
15
15
|
describe "#build_result" do
|
16
16
|
|
17
|
-
let(:build_name)
|
18
|
-
let(:
|
19
|
-
let(:
|
20
|
-
|
21
|
-
end
|
22
|
-
let(:last_finished_build) { recent_builds[1] }
|
23
|
-
let(:last_finished_build_passed_flag) { true }
|
24
|
-
let(:build_result) { instance_double(BuildEval::Result::BuildResult) }
|
17
|
+
let(:build_name) { "some_build_name" }
|
18
|
+
let(:last_build_status) { "Unknown" }
|
19
|
+
let(:travis) { instance_double(BuildEval::Travis, login: nil, last_build_status_for: last_build_status) }
|
20
|
+
let(:build_result) { instance_double(BuildEval::Result::BuildResult) }
|
25
21
|
|
26
22
|
subject { travis_pro_server.build_result(build_name) }
|
27
23
|
|
28
24
|
before(:example) do
|
29
|
-
allow(::Travis
|
30
|
-
allow(::Travis::Pro::Repository).to receive(:find).and_return(travis_repository)
|
31
|
-
allow(travis_repository).to receive(:recent_builds).and_return(recent_builds)
|
32
|
-
allow(last_finished_build).to receive(:passed?).and_return(last_finished_build_passed_flag)
|
25
|
+
allow(BuildEval::Travis).to receive(:new).and_return(travis)
|
33
26
|
allow(BuildEval::Result::BuildResult).to receive(:create).and_return(build_result)
|
34
27
|
end
|
35
28
|
|
36
|
-
it "
|
37
|
-
expect(::Travis
|
38
|
-
|
39
|
-
subject
|
40
|
-
end
|
41
|
-
|
42
|
-
it "retrieves the relevant Travis Pro Repository" do
|
43
|
-
expect(::Travis::Pro::Repository).to receive(:find).with("#{username}/#{build_name}")
|
29
|
+
it "creates a Travis API wrapping the Pro module" do
|
30
|
+
expect(BuildEval::Travis).to receive(:new).with(::Travis::Pro)
|
44
31
|
|
45
32
|
subject
|
46
33
|
end
|
47
34
|
|
48
|
-
it "
|
49
|
-
expect(
|
35
|
+
it "logs-in to the Travis API using the provided GitHub token" do
|
36
|
+
expect(travis).to receive(:login).with(github_token)
|
50
37
|
|
51
38
|
subject
|
52
39
|
end
|
53
40
|
|
54
|
-
it "
|
55
|
-
expect(
|
41
|
+
it "retrieves the last build status for the GitHub repository" do
|
42
|
+
expect(travis).to receive(:last_build_status_for).with("#{username}/#{build_name}")
|
56
43
|
|
57
44
|
subject
|
58
45
|
end
|
@@ -65,28 +52,12 @@ describe BuildEval::Server::TravisPro do
|
|
65
52
|
subject
|
66
53
|
end
|
67
54
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
it "creates a successful build result" do
|
73
|
-
expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(status_name: "Success"))
|
74
|
-
|
75
|
-
subject
|
76
|
-
end
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
context "when the last finished build failed" do
|
81
|
-
|
82
|
-
let(:last_finished_build_passed_flag) { false }
|
83
|
-
|
84
|
-
it "creates a failed build result" do
|
85
|
-
expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(status_name: "Failure"))
|
86
|
-
|
87
|
-
subject
|
88
|
-
end
|
55
|
+
it "creates a build result whose status is the status the last build status" do
|
56
|
+
expect(BuildEval::Result::BuildResult).to(
|
57
|
+
receive(:create).with(hash_including(status_name: last_build_status))
|
58
|
+
)
|
89
59
|
|
60
|
+
subject
|
90
61
|
end
|
91
62
|
|
92
63
|
it "returns the build result" do
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe BuildEval::Server::Travis do
|
2
|
-
include_context "stubbed
|
2
|
+
include_context "stubbed Travis API interactions"
|
3
3
|
|
4
4
|
let(:username) { "some_username" }
|
5
5
|
let(:constructor_args) { { username: username } }
|
@@ -8,43 +8,31 @@ describe BuildEval::Server::Travis do
|
|
8
8
|
|
9
9
|
describe "#build_result" do
|
10
10
|
|
11
|
-
let(:build_name)
|
12
|
-
let(:
|
13
|
-
let(:
|
14
|
-
|
15
|
-
end
|
16
|
-
let(:last_finished_build) { recent_builds[1] }
|
17
|
-
let(:last_finished_build_passed_flag) { true }
|
18
|
-
let(:build_result) { instance_double(BuildEval::Result::BuildResult) }
|
11
|
+
let(:build_name) { "some_build_name" }
|
12
|
+
let(:last_build_status) { "Failure" }
|
13
|
+
let(:travis) { instance_double(BuildEval::Travis, last_build_status_for: last_build_status) }
|
14
|
+
let(:build_result) { instance_double(BuildEval::Result::BuildResult) }
|
19
15
|
|
20
16
|
subject { travis_server.build_result(build_name) }
|
21
17
|
|
22
18
|
before(:example) do
|
23
|
-
allow(::Travis
|
24
|
-
allow(travis_repository).to receive(:recent_builds).and_return(recent_builds)
|
25
|
-
allow(last_finished_build).to receive(:passed?).and_return(last_finished_build_passed_flag)
|
19
|
+
allow(BuildEval::Travis).to receive(:new).and_return(travis)
|
26
20
|
allow(BuildEval::Result::BuildResult).to receive(:create).and_return(build_result)
|
27
21
|
end
|
28
22
|
|
29
|
-
it "
|
30
|
-
expect(::Travis
|
31
|
-
|
32
|
-
subject
|
33
|
-
end
|
34
|
-
|
35
|
-
it "retrieves the recent builds from the Travis repository" do
|
36
|
-
expect(travis_repository).to receive(:recent_builds)
|
23
|
+
it "creates a Travis API wrapping the Standard module" do
|
24
|
+
expect(BuildEval::Travis).to receive(:new).with(::Travis)
|
37
25
|
|
38
26
|
subject
|
39
27
|
end
|
40
28
|
|
41
|
-
it "
|
42
|
-
expect(
|
29
|
+
it "retrieves the last build status for the GitHub repository" do
|
30
|
+
expect(travis).to receive(:last_build_status_for).with("#{username}/#{build_name}")
|
43
31
|
|
44
32
|
subject
|
45
33
|
end
|
46
34
|
|
47
|
-
it "creates a build result whose build name is the path to the repository" do
|
35
|
+
it "creates a build result whose build name is the path to the GitHub repository" do
|
48
36
|
expect(BuildEval::Result::BuildResult).to(
|
49
37
|
receive(:create).with(hash_including(build_name: "#{username}/#{build_name}"))
|
50
38
|
)
|
@@ -52,28 +40,12 @@ describe BuildEval::Server::Travis do
|
|
52
40
|
subject
|
53
41
|
end
|
54
42
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
it "creates a successful build result" do
|
60
|
-
expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(status_name: "Success"))
|
61
|
-
|
62
|
-
subject
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
context "when the last finished build failed" do
|
68
|
-
|
69
|
-
let(:last_finished_build_passed_flag) { false }
|
70
|
-
|
71
|
-
it "creates a failed build result" do
|
72
|
-
expect(BuildEval::Result::BuildResult).to receive(:create).with(hash_including(status_name: "Failure"))
|
73
|
-
|
74
|
-
subject
|
75
|
-
end
|
43
|
+
it "creates a build result whose status is the status the last build status" do
|
44
|
+
expect(BuildEval::Result::BuildResult).to(
|
45
|
+
receive(:create).with(hash_including(status_name: last_build_status))
|
46
|
+
)
|
76
47
|
|
48
|
+
subject
|
77
49
|
end
|
78
50
|
|
79
51
|
it "returns the build result" do
|
@@ -0,0 +1,94 @@
|
|
1
|
+
describe BuildEval::Travis do
|
2
|
+
include_context "stubbed Travis API interactions"
|
3
|
+
|
4
|
+
let(:travis_module) { ::Travis }
|
5
|
+
|
6
|
+
let(:travis) { described_class.new(travis_module) }
|
7
|
+
|
8
|
+
describe "#login" do
|
9
|
+
|
10
|
+
let(:github_token) { "SOMEGITHUBTOKEN" }
|
11
|
+
|
12
|
+
subject { travis.login(github_token) }
|
13
|
+
|
14
|
+
it "logs-in to Travis using the GitHub Auth token provided" do
|
15
|
+
expect(travis_module).to receive(:github_auth).with(github_token)
|
16
|
+
|
17
|
+
subject
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#last_build_status_for" do
|
23
|
+
|
24
|
+
let(:build_path) { "some/build_path" }
|
25
|
+
|
26
|
+
let(:recent_builds) do
|
27
|
+
(1..3).map { |i| instance_double(::Travis::Client::Build, finished?: i > 1) }
|
28
|
+
end
|
29
|
+
let(:last_finished_build) { recent_builds[1] }
|
30
|
+
let(:last_finished_build_passed_flag) { true }
|
31
|
+
let(:travis_repository) do
|
32
|
+
instance_double(::Travis::Client::Repository, recent_builds: recent_builds)
|
33
|
+
end
|
34
|
+
|
35
|
+
subject { travis.last_build_status_for(build_path) }
|
36
|
+
|
37
|
+
before(:example) do
|
38
|
+
allow(travis_module::Repository).to receive(:find).and_return(travis_repository)
|
39
|
+
allow(last_finished_build).to receive(:passed?).and_return(last_finished_build_passed_flag)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "retrieves the Travis Repository for the provided build path" do
|
43
|
+
expect(travis_module::Repository).to receive(:find).with(build_path)
|
44
|
+
|
45
|
+
subject
|
46
|
+
end
|
47
|
+
|
48
|
+
it "retrieves the recent builds from the Travis Repository" do
|
49
|
+
expect(travis_repository).to receive(:recent_builds)
|
50
|
+
|
51
|
+
subject
|
52
|
+
end
|
53
|
+
|
54
|
+
it "determines if the last finished build has passed" do
|
55
|
+
expect(last_finished_build).to receive(:passed?)
|
56
|
+
|
57
|
+
subject
|
58
|
+
end
|
59
|
+
|
60
|
+
context "when the last finished build passed" do
|
61
|
+
|
62
|
+
let(:last_finished_build_passed_flag) { true }
|
63
|
+
|
64
|
+
it "returns 'Success'" do
|
65
|
+
expect(subject).to eql("Success")
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
context "when the last finished build failed" do
|
71
|
+
|
72
|
+
let(:last_finished_build_passed_flag) { false }
|
73
|
+
|
74
|
+
it "returns 'Failure'" do
|
75
|
+
expect(subject).to eql("Failure")
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
context "when an Travis Client error occurs" do
|
81
|
+
|
82
|
+
before(:example) do
|
83
|
+
allow(travis_repository).to receive(:recent_builds).and_raise(::Travis::Client::Error.new("Forced error"))
|
84
|
+
end
|
85
|
+
|
86
|
+
it "returns 'Unknown'" do
|
87
|
+
expect(subject).to eql("Unknown")
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
describe BuildEval, "integrating with a real CI server", smoke: true do
|
2
|
-
let(:server) { BuildEval.server(type: :Travis, username: "MYOB-Technology") }
|
3
2
|
|
4
|
-
let(:
|
3
|
+
let(:builds) { BuildEval::Examples::Travis.builds }
|
4
|
+
|
5
|
+
let(:monitor) { BuildEval::Examples::Travis.monitor }
|
5
6
|
|
6
7
|
describe "the evaluated results from a build monitor for the server" do
|
7
8
|
|
@@ -16,12 +17,14 @@ describe BuildEval, "integrating with a real CI server", smoke: true do
|
|
16
17
|
|
17
18
|
subject { monitor.evaluate }
|
18
19
|
|
19
|
-
it "
|
20
|
+
it "indicates the combined status of all builds" do
|
20
21
|
expect(tolerated_statuses).to include(subject.status)
|
21
22
|
end
|
22
23
|
|
23
|
-
it "
|
24
|
-
|
24
|
+
it "describes the builds and their individual status" do
|
25
|
+
builds.each do |build|
|
26
|
+
expect(subject.to_s).to match(/#{build}: (#{tolerated_statuses.map(&:to_s).join("|")})/)
|
27
|
+
end
|
25
28
|
end
|
26
29
|
|
27
30
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -7,6 +7,7 @@ if ENV['coverage']
|
|
7
7
|
SimpleCov.start do
|
8
8
|
coverage_dir 'tmp/coverage'
|
9
9
|
|
10
|
+
add_filter '/examples/'
|
10
11
|
add_filter '/spec/'
|
11
12
|
|
12
13
|
minimum_coverage 100
|
@@ -15,6 +16,7 @@ if ENV['coverage']
|
|
15
16
|
end
|
16
17
|
|
17
18
|
require_relative '../lib/build_eval'
|
19
|
+
require_relative '../examples/travis'
|
18
20
|
|
19
21
|
%w( shared_examples shared_context ).each do |file_type|
|
20
22
|
Dir[::File.expand_path("../**/*_#{file_type}.rb", __FILE__)].each { |file| require file }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: build_eval
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ueckerman
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-06-
|
13
|
+
date: 2016-06-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- ./lib/build_eval/server/team_city.rb
|
163
163
|
- ./lib/build_eval/server/travis.rb
|
164
164
|
- ./lib/build_eval/server/travis_pro.rb
|
165
|
+
- ./lib/build_eval/travis.rb
|
165
166
|
- ./lib/build_eval/version.rb
|
166
167
|
- ./spec/lib/build_eval/error_spec.rb
|
167
168
|
- ./spec/lib/build_eval/http_shared_context.rb
|
@@ -183,6 +184,8 @@ files:
|
|
183
184
|
- ./spec/lib/build_eval/server/team_city_spec.rb
|
184
185
|
- ./spec/lib/build_eval/server/travis_pro_spec.rb
|
185
186
|
- ./spec/lib/build_eval/server/travis_spec.rb
|
187
|
+
- ./spec/lib/build_eval/travis_shared_context.rb
|
188
|
+
- ./spec/lib/build_eval/travis_spec.rb
|
186
189
|
- ./spec/lib/build_eval_smoke_spec.rb
|
187
190
|
- ./spec/lib/build_eval_spec.rb
|
188
191
|
- ./spec/spec_helper.rb
|
@@ -231,6 +234,8 @@ test_files:
|
|
231
234
|
- ./spec/lib/build_eval/server/team_city_spec.rb
|
232
235
|
- ./spec/lib/build_eval/server/travis_pro_spec.rb
|
233
236
|
- ./spec/lib/build_eval/server/travis_spec.rb
|
237
|
+
- ./spec/lib/build_eval/travis_shared_context.rb
|
238
|
+
- ./spec/lib/build_eval/travis_spec.rb
|
234
239
|
- ./spec/lib/build_eval_smoke_spec.rb
|
235
240
|
- ./spec/lib/build_eval_spec.rb
|
236
241
|
- ./spec/spec_helper.rb
|