build_eval 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/build_eval/server/travis.rb +3 -3
- data/lib/build_eval/server/travis_pro.rb +4 -3
- data/lib/build_eval/travis.rb +5 -7
- data/lib/build_eval/version.rb +1 -1
- data/lib/build_eval.rb +1 -2
- data/spec/lib/build_eval/server/travis_pro_spec.rb +3 -9
- data/spec/lib/build_eval/server/travis_spec.rb +1 -2
- data/spec/lib/build_eval/travis_spec.rb +29 -15
- metadata +1 -3
- data/spec/lib/build_eval/travis_shared_context.rb +0 -50
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDBkZjU0NzI5ODI4NDE2YTA5ZTJjZWZjNWMzZGRlMzM0MzM0YTYzYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MjMxMzI4MGVlMjVjYTQzZTIzN2YyNWY2MDI5Nzg4MDg5MDAzOTc4YQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODNmMjliMWM2YzMwZGY1OWIzZjRkNmYxMWI4MzJmMjM3N2UyYmVhMWZlZGFh
|
10
|
+
ODc4ZTdhOWQzMjhkZGYwMGViOWFlMzBiZDJiNjQ3MzdmZjEzYzhhZDJiY2Ji
|
11
|
+
YjM5NjAwYjYzOGQyMWRlZDliNjc5M2JlNmYwYzQ3YmEwODY5MzA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGJlYTg2ZjAxOTMxMjExM2I4OTRkM2UxMGZlYjI4YmQ4ODIwOThhZWE1MGVm
|
14
|
+
ZWZhZjI3MmUyNzc5M2JmNjk1MmEyZGU2YjQxZjBhODkwODE4ODQ4NTFlZWJk
|
15
|
+
ZTdiNmE5MGNmMTdjM2U4MzMzMjgzZWI2MTA0YTJlYjBkNjFiNmM=
|
@@ -8,10 +8,10 @@ module BuildEval
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def build_result(name)
|
11
|
-
|
11
|
+
repository_path = "#{@username}/#{name}"
|
12
12
|
BuildEval::Result::BuildResult.create(
|
13
|
-
build_name:
|
14
|
-
status_name: BuildEval::Travis.last_build_status(
|
13
|
+
build_name: repository_path,
|
14
|
+
status_name: BuildEval::Travis.last_build_status(repository_path: repository_path)
|
15
15
|
)
|
16
16
|
end
|
17
17
|
|
@@ -9,10 +9,11 @@ module BuildEval
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def build_result(name)
|
12
|
-
|
12
|
+
repository_path = "#{@username}/#{name}"
|
13
13
|
BuildEval::Result::BuildResult.create(
|
14
|
-
build_name:
|
15
|
-
status_name: BuildEval::Travis.last_build_status(github_token:
|
14
|
+
build_name: repository_path,
|
15
|
+
status_name: BuildEval::Travis.last_build_status(github_token: @github_token,
|
16
|
+
repository_path: repository_path)
|
16
17
|
)
|
17
18
|
end
|
18
19
|
|
data/lib/build_eval/travis.rb
CHANGED
@@ -5,7 +5,7 @@ module BuildEval
|
|
5
5
|
class << self
|
6
6
|
|
7
7
|
def last_build_status(args)
|
8
|
-
repository =
|
8
|
+
repository = create_session(args).repo(args[:repository_path])
|
9
9
|
repository.recent_builds.find(&:finished?).passed? ? "Success" : "Failure"
|
10
10
|
rescue ::Travis::Client::Error
|
11
11
|
"Unknown"
|
@@ -13,13 +13,11 @@ module BuildEval
|
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
travis_module.github_auth(args[:github_token])
|
16
|
+
def create_session(args)
|
17
|
+
travis_uri = args[:github_token] ? ::Travis::Client::PRO_URI : ::Travis::Client::ORG_URI
|
18
|
+
::Travis::Client::Session.new(uri: travis_uri, ssl: {}).tap do |session|
|
19
|
+
session.github_auth(args[:github_token]) if args[:github_token]
|
21
20
|
end
|
22
|
-
travis_module
|
23
21
|
end
|
24
22
|
|
25
23
|
end
|
data/lib/build_eval/version.rb
CHANGED
data/lib/build_eval.rb
CHANGED
@@ -1,16 +1,10 @@
|
|
1
1
|
describe BuildEval::Server::TravisPro do
|
2
|
-
include_context "stubbed Travis API interactions"
|
3
2
|
|
4
3
|
let(:username) { "some_username" }
|
5
4
|
let(:github_token) { "ABCD1234" }
|
6
|
-
let(:
|
7
|
-
{
|
8
|
-
username: username,
|
9
|
-
github_token: github_token
|
10
|
-
}
|
11
|
-
end
|
5
|
+
let(:args) { { username: username, github_token: github_token } }
|
12
6
|
|
13
|
-
let(:travis_pro_server) { described_class.new(
|
7
|
+
let(:travis_pro_server) { described_class.new(args) }
|
14
8
|
|
15
9
|
describe "#build_result" do
|
16
10
|
|
@@ -35,7 +29,7 @@ describe BuildEval::Server::TravisPro do
|
|
35
29
|
|
36
30
|
it "retrieves the last build status from Travis for the users build" do
|
37
31
|
expect(BuildEval::Travis).to(
|
38
|
-
receive(:last_build_status).with(hash_including(
|
32
|
+
receive(:last_build_status).with(hash_including(repository_path: "#{username}/#{build_name}"))
|
39
33
|
)
|
40
34
|
|
41
35
|
subject
|
@@ -1,5 +1,4 @@
|
|
1
1
|
describe BuildEval::Server::Travis do
|
2
|
-
include_context "stubbed Travis API interactions"
|
3
2
|
|
4
3
|
let(:username) { "some_username" }
|
5
4
|
let(:constructor_args) { { username: username } }
|
@@ -21,7 +20,7 @@ describe BuildEval::Server::Travis do
|
|
21
20
|
|
22
21
|
it "retrieves the last build status from Travis for the users build" do
|
23
22
|
expect(BuildEval::Travis).to(
|
24
|
-
receive(:last_build_status).with(hash_including(
|
23
|
+
receive(:last_build_status).with(hash_including(repository_path: "#{username}/#{build_name}"))
|
25
24
|
)
|
26
25
|
|
27
26
|
subject
|
@@ -1,10 +1,9 @@
|
|
1
1
|
describe BuildEval::Travis do
|
2
|
-
include_context "stubbed Travis API interactions"
|
3
2
|
|
4
3
|
describe "::last_build_status" do
|
5
4
|
|
6
|
-
let(:
|
7
|
-
let(:optional_args)
|
5
|
+
let(:repository_path) { "some/repository_path" }
|
6
|
+
let(:optional_args) { {} }
|
8
7
|
|
9
8
|
let(:recent_builds) do
|
10
9
|
(1..3).map { |i| instance_double(::Travis::Client::Build, finished?: i > 1) }
|
@@ -14,11 +13,12 @@ describe BuildEval::Travis do
|
|
14
13
|
let(:travis_repository) do
|
15
14
|
instance_double(::Travis::Client::Repository, recent_builds: recent_builds)
|
16
15
|
end
|
16
|
+
let(:travis_session) { instance_double(::Travis::Client::Session, repo: travis_repository) }
|
17
17
|
|
18
|
-
subject { described_class.last_build_status({
|
18
|
+
subject { described_class.last_build_status({ repository_path: repository_path }.merge(optional_args)) }
|
19
19
|
|
20
20
|
before(:example) do
|
21
|
-
allow(::Travis::
|
21
|
+
allow(::Travis::Client::Session).to receive(:new).and_return(travis_session)
|
22
22
|
allow(last_finished_build).to receive(:passed?).and_return(last_finished_build_passed_flag)
|
23
23
|
end
|
24
24
|
|
@@ -27,22 +27,24 @@ describe BuildEval::Travis do
|
|
27
27
|
let(:github_token) { "SOMEGITHUBAUTHTOKEN" }
|
28
28
|
let(:optional_args) { { github_token: github_token } }
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
before(:example) { allow(travis_session).to receive(:github_auth) }
|
31
|
+
|
32
|
+
it "creates a Travis session connecting to the Travis Pro site" do
|
33
|
+
expect(::Travis::Client::Session).to receive(:new).with(hash_including(uri: ::Travis::Client::PRO_URI))
|
32
34
|
|
33
35
|
subject
|
34
36
|
end
|
35
37
|
|
36
|
-
it "
|
37
|
-
expect(
|
38
|
+
it "logs-in using the provided GitHub token via the session" do
|
39
|
+
expect(travis_session).to receive(:github_auth).with(github_token)
|
38
40
|
|
39
41
|
subject
|
40
42
|
end
|
41
43
|
|
42
|
-
context "when
|
44
|
+
context "when an error occurs on log-in" do
|
43
45
|
|
44
46
|
before(:example) do
|
45
|
-
allow(
|
47
|
+
allow(travis_session).to receive(:github_auth).and_raise(::Travis::Client::Error.new("Forced error"))
|
46
48
|
end
|
47
49
|
|
48
50
|
it "returns 'Unknown'" do
|
@@ -57,16 +59,28 @@ describe BuildEval::Travis do
|
|
57
59
|
|
58
60
|
let(:optional_args) { {} }
|
59
61
|
|
60
|
-
it "
|
61
|
-
expect(::Travis::
|
62
|
+
it "creates a Travis session connecting to the Travis Org site" do
|
63
|
+
expect(::Travis::Client::Session).to receive(:new).with(hash_including(uri: ::Travis::Client::ORG_URI))
|
64
|
+
|
65
|
+
subject
|
66
|
+
end
|
67
|
+
|
68
|
+
it "does not log-in" do
|
69
|
+
expect(travis_session).to_not receive(:github_auth)
|
62
70
|
|
63
71
|
subject
|
64
72
|
end
|
65
73
|
|
66
74
|
end
|
67
75
|
|
68
|
-
it "
|
69
|
-
expect(::Travis::
|
76
|
+
it "creates a Travis session with empty SSL settings to avoid using local security certificates" do
|
77
|
+
expect(::Travis::Client::Session).to receive(:new).with(hash_including(ssl: {}))
|
78
|
+
|
79
|
+
subject
|
80
|
+
end
|
81
|
+
|
82
|
+
it "retrieves the Travis repository for the provided repository path" do
|
83
|
+
expect(travis_session).to receive(:repo).with(repository_path)
|
70
84
|
|
71
85
|
subject
|
72
86
|
end
|
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.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ueckerman
|
@@ -184,7 +184,6 @@ files:
|
|
184
184
|
- ./spec/lib/build_eval/server/team_city_spec.rb
|
185
185
|
- ./spec/lib/build_eval/server/travis_pro_spec.rb
|
186
186
|
- ./spec/lib/build_eval/server/travis_spec.rb
|
187
|
-
- ./spec/lib/build_eval/travis_shared_context.rb
|
188
187
|
- ./spec/lib/build_eval/travis_spec.rb
|
189
188
|
- ./spec/lib/build_eval_smoke_spec.rb
|
190
189
|
- ./spec/lib/build_eval_spec.rb
|
@@ -234,7 +233,6 @@ test_files:
|
|
234
233
|
- ./spec/lib/build_eval/server/team_city_spec.rb
|
235
234
|
- ./spec/lib/build_eval/server/travis_pro_spec.rb
|
236
235
|
- ./spec/lib/build_eval/server/travis_spec.rb
|
237
|
-
- ./spec/lib/build_eval/travis_shared_context.rb
|
238
236
|
- ./spec/lib/build_eval/travis_spec.rb
|
239
237
|
- ./spec/lib/build_eval_smoke_spec.rb
|
240
238
|
- ./spec/lib/build_eval_spec.rb
|
@@ -1,50 +0,0 @@
|
|
1
|
-
shared_context "stubbed Travis API interactions" do
|
2
|
-
|
3
|
-
module StubTravisBuild
|
4
|
-
|
5
|
-
def finished?
|
6
|
-
# Intentionally blank
|
7
|
-
end
|
8
|
-
|
9
|
-
def passed?
|
10
|
-
# Intentionally blank
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
module StubTravisRepository
|
16
|
-
|
17
|
-
def recent_builds
|
18
|
-
# Intentionally blank
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
module StubTravisPro
|
24
|
-
|
25
|
-
Repository = StubTravisRepository
|
26
|
-
|
27
|
-
def self.github_auth(auth_token)
|
28
|
-
# Intentionally blank
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
module StubTravis
|
34
|
-
|
35
|
-
Repository = StubTravisRepository
|
36
|
-
Pro = StubTravisPro
|
37
|
-
|
38
|
-
module Client
|
39
|
-
Repository = StubTravisRepository
|
40
|
-
Build = StubTravisBuild
|
41
|
-
Error = ::StandardError
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
before(:context) do
|
47
|
-
::Travis = StubTravis
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|