build_eval 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTJiNTE3NDJkMjUxNWRkN2FmZTMwNjViY2MxNWJjOWEzZmM4YWRjNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTBiZjJmOWJiMDBiYjFhZjViMmEyOGIyZWRlMDY5NWIyNjc0NTFhMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmY2Y2Q3ZmMxYzUzNTkwNGEwNzc2NGYxZGNjODkyNDlhZDIwMzg0YzczODBh
|
10
|
+
ZDc0YWMyMjEzNzE2YWM3N2JmYmI1ZDhhNjIyMDYwM2NkODdiY2E1MzA5Nzk0
|
11
|
+
Y2JiZTZhMWQzNDE4NDljMWE3ZGFhZGIwYTM2ZTA3MWNmMjcxMDA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDM5MmUwN2Q3NGQ5YWJlZDA5ZGYwY2E5NDVkMjc2YmU0NGQzNTQwZDY3N2Ri
|
14
|
+
MzliZGM3NjRlOWFhM2ZjMTM0ZmFjZTVhNDJkN2NiNWM3OTU3Njk5NmUwMmZm
|
15
|
+
OWQ0MTg3MmE2ODU3MGQ2Y2Y5MzAwN2RiNWQzMDRhYjc2YzFhNDU=
|
@@ -4,16 +4,15 @@ module BuildEval
|
|
4
4
|
class TravisPro
|
5
5
|
|
6
6
|
def initialize(args)
|
7
|
-
@username
|
8
|
-
|
7
|
+
@username = args[:username]
|
8
|
+
@github_token = args[:github_token]
|
9
9
|
end
|
10
10
|
|
11
11
|
def build_result(name)
|
12
|
-
|
13
|
-
has_failed = ::Travis::Pro::Repository.find(repo_string).recent_builds.first.failed?
|
12
|
+
repository_path = "#{@username}/#{name}"
|
14
13
|
BuildEval::Result::BuildResult.create(
|
15
|
-
build_name:
|
16
|
-
status_name:
|
14
|
+
build_name: repository_path,
|
15
|
+
status_name: last_build_failed?(repository_path) ? "Failure" : "Success"
|
17
16
|
)
|
18
17
|
end
|
19
18
|
|
@@ -21,7 +20,14 @@ module BuildEval
|
|
21
20
|
"Travis CI Pro #{@username}"
|
22
21
|
end
|
23
22
|
|
23
|
+
private
|
24
|
+
|
25
|
+
def last_build_failed?(repository_path)
|
26
|
+
::Travis::Pro.github_auth(@github_token)
|
27
|
+
::Travis::Pro::Repository.find(repository_path).recent_builds.first.failed?
|
28
|
+
end
|
29
|
+
|
24
30
|
end
|
25
|
-
end
|
26
31
|
|
32
|
+
end
|
27
33
|
end
|
data/lib/build_eval/version.rb
CHANGED
@@ -12,20 +12,6 @@ describe BuildEval::Server::TravisPro do
|
|
12
12
|
|
13
13
|
let(:travis_pro_server) { described_class.new(constructor_args) }
|
14
14
|
|
15
|
-
before(:example) { allow(::Travis::Pro).to receive(:github_auth) }
|
16
|
-
|
17
|
-
describe "#initialize" do
|
18
|
-
|
19
|
-
subject { described_class.new(constructor_args) }
|
20
|
-
|
21
|
-
it "establishes the GitHub auth token" do
|
22
|
-
expect(::Travis::Pro).to receive(:github_auth).with(github_token)
|
23
|
-
|
24
|
-
subject
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
15
|
describe "#build_result" do
|
30
16
|
|
31
17
|
let(:build_name) { "some_build_name" }
|
@@ -38,31 +24,38 @@ describe BuildEval::Server::TravisPro do
|
|
38
24
|
subject { travis_pro_server.build_result(build_name) }
|
39
25
|
|
40
26
|
before(:example) do
|
27
|
+
allow(::Travis::Pro).to receive(:github_auth)
|
41
28
|
allow(::Travis::Pro::Repository).to receive(:find).and_return(travis_repository)
|
42
29
|
allow(travis_repository).to receive(:recent_builds).and_return(recent_builds)
|
43
30
|
allow(last_build).to receive(:failed?).and_return(last_build_failed_flag)
|
44
31
|
allow(BuildEval::Result::BuildResult).to receive(:create).and_return(build_result)
|
45
32
|
end
|
46
33
|
|
47
|
-
it "
|
34
|
+
it "logs-in to Travis Pro using the provided GitHub token" do
|
35
|
+
expect(::Travis::Pro).to receive(:github_auth).with(github_token)
|
36
|
+
|
37
|
+
subject
|
38
|
+
end
|
39
|
+
|
40
|
+
it "retrieves the relevant Travis Pro Repository" do
|
48
41
|
expect(::Travis::Pro::Repository).to receive(:find).with("#{username}/#{build_name}")
|
49
42
|
|
50
43
|
subject
|
51
44
|
end
|
52
45
|
|
53
|
-
it "retrieves the recent builds from Travis" do
|
46
|
+
it "retrieves the recent builds from the Travis Repository" do
|
54
47
|
expect(travis_repository).to receive(:recent_builds)
|
55
48
|
|
56
49
|
subject
|
57
50
|
end
|
58
51
|
|
59
|
-
it "
|
52
|
+
it "determines if the last build has failed" do
|
60
53
|
expect(last_build).to receive(:failed?)
|
61
54
|
|
62
55
|
subject
|
63
56
|
end
|
64
57
|
|
65
|
-
it "creates a build result whose build name is the path to the repository" do
|
58
|
+
it "creates a build result whose build name is the path to the GitHub repository" do
|
66
59
|
expect(BuildEval::Result::BuildResult).to(
|
67
60
|
receive(:create).with(hash_including(build_name: "#{username}/#{build_name}"))
|
68
61
|
)
|
@@ -70,7 +63,7 @@ describe BuildEval::Server::TravisPro do
|
|
70
63
|
subject
|
71
64
|
end
|
72
65
|
|
73
|
-
context "when the last build
|
66
|
+
context "when the last build had passed" do
|
74
67
|
|
75
68
|
let(:last_build_failed_flag) { false }
|
76
69
|
|
@@ -82,7 +75,7 @@ describe BuildEval::Server::TravisPro do
|
|
82
75
|
|
83
76
|
end
|
84
77
|
|
85
|
-
context "when the last build
|
78
|
+
context "when the last build had failed" do
|
86
79
|
|
87
80
|
let(:last_build_failed_flag) { true }
|
88
81
|
|
@@ -94,7 +87,7 @@ describe BuildEval::Server::TravisPro do
|
|
94
87
|
|
95
88
|
end
|
96
89
|
|
97
|
-
it "returns the
|
90
|
+
it "returns the build result" do
|
98
91
|
expect(subject).to eql(build_result)
|
99
92
|
end
|
100
93
|
|
@@ -30,13 +30,13 @@ describe BuildEval::Server::Travis do
|
|
30
30
|
subject
|
31
31
|
end
|
32
32
|
|
33
|
-
it "retrieves the recent builds from Travis" do
|
33
|
+
it "retrieves the recent builds from the Travis repository" do
|
34
34
|
expect(travis_repository).to receive(:recent_builds)
|
35
35
|
|
36
36
|
subject
|
37
37
|
end
|
38
38
|
|
39
|
-
it "
|
39
|
+
it "determines if the last build has failed" do
|
40
40
|
expect(last_build).to receive(:failed?)
|
41
41
|
|
42
42
|
subject
|
@@ -74,7 +74,7 @@ describe BuildEval::Server::Travis do
|
|
74
74
|
|
75
75
|
end
|
76
76
|
|
77
|
-
it "returns the
|
77
|
+
it "returns the build result" do
|
78
78
|
expect(subject).to eql(build_result)
|
79
79
|
end
|
80
80
|
|