Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kazuhiko Shiozaki
gitlab-ce
Commits
600d6eef
Commit
600d6eef
authored
Sep 18, 2015
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix CI status in the MR page
parent
1eb3dde4
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
75 deletions
+13
-75
app/models/project_services/buildkite_service.rb
app/models/project_services/buildkite_service.rb
+0
-8
app/models/project_services/drone_ci_service.rb
app/models/project_services/drone_ci_service.rb
+0
-14
app/models/project_services/gitlab_ci_service.rb
app/models/project_services/gitlab_ci_service.rb
+8
-31
spec/models/project_services/buildkite_service_spec.rb
spec/models/project_services/buildkite_service_spec.rb
+0
-14
spec/models/project_services/gitlab_ci_service_spec.rb
spec/models/project_services/gitlab_ci_service_spec.rb
+5
-8
No files found.
app/models/project_services/buildkite_service.rb
View file @
600d6eef
...
@@ -69,14 +69,6 @@ class BuildkiteService < CiService
...
@@ -69,14 +69,6 @@ class BuildkiteService < CiService
"
#{
project_url
}
/builds?commit=
#{
sha
}
"
"
#{
project_url
}
/builds?commit=
#{
sha
}
"
end
end
def
builds_path
"
#{
project_url
}
/builds?branch=
#{
project
.
default_branch
}
"
end
def
status_img_path
"
#{
buildkite_endpoint
(
'badge'
)
}
/
#{
status_token
}
.svg"
end
def
title
def
title
'Buildkite'
'Buildkite'
end
end
...
...
app/models/project_services/drone_ci_service.rb
View file @
600d6eef
...
@@ -135,20 +135,6 @@ class DroneCiService < CiService
...
@@ -135,20 +135,6 @@ class DroneCiService < CiService
commit_page
(
sha
,
ref
)
commit_page
(
sha
,
ref
)
end
end
def
builds_path
url
=
[
drone_url
,
"
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
"
]
URI
.
join
(
*
url
).
to_s
end
def
status_img_path
url
=
[
drone_url
,
"api/badges/
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
/status.svg"
,
"?branch=
#{
URI
::
encode
(
project
.
default_branch
)
}
"
]
URI
.
join
(
*
url
).
to_s
end
def
title
def
title
'Drone CI'
'Drone CI'
end
end
...
...
app/models/project_services/gitlab_ci_service.rb
View file @
600d6eef
...
@@ -58,24 +58,13 @@ class GitlabCiService < CiService
...
@@ -58,24 +58,13 @@ class GitlabCiService < CiService
service_hook
.
execute
(
data
)
service_hook
.
execute
(
data
)
end
end
def
commit_status_path
(
sha
,
ref
)
def
get_ci_commit
(
sha
,
ref
)
URI
::
encode
(
project_url
+
"/refs/
#{
ref
}
/commits/
#{
sha
}
/status.json?token=
#{
token
}
"
)
Ci
::
Project
.
find
(
project
.
gitlab_ci_project
).
commits
.
find_by_sha_and_ref!
(
sha
,
ref
)
end
def
get_ci_build
(
sha
,
ref
)
@ci_builds
||=
{}
@ci_builds
[
sha
]
||=
HTTParty
.
get
(
commit_status_path
(
sha
,
ref
),
verify:
false
)
end
end
def
commit_status
(
sha
,
ref
)
def
commit_status
(
sha
,
ref
)
response
=
get_ci_build
(
sha
,
ref
)
get_ci_commit
(
sha
,
ref
).
status
rescue
ActiveRecord
::
RecordNotFound
if
response
.
code
==
200
and
response
[
"status"
]
response
[
"status"
]
else
:error
end
rescue
Errno
::
ECONNREFUSED
:error
:error
end
end
...
@@ -101,25 +90,13 @@ class GitlabCiService < CiService
...
@@ -101,25 +90,13 @@ class GitlabCiService < CiService
end
end
def
commit_coverage
(
sha
,
ref
)
def
commit_coverage
(
sha
,
ref
)
response
=
get_ci_build
(
sha
,
ref
)
get_ci_commit
(
sha
,
ref
).
coverage
rescue
ActiveRecord
::
RecordNotFound
if
response
.
code
==
200
and
response
[
"coverage"
]
:error
response
[
"coverage"
]
end
rescue
Errno
::
ECONNREFUSED
nil
end
end
def
build_page
(
sha
,
ref
)
def
build_page
(
sha
,
ref
)
URI
::
encode
(
project_url
+
"/refs/
#{
ref
}
/commits/
#{
sha
}
"
)
Ci
::
RoutesHelper
.
ci_project_ref_commits_path
(
project
.
gitlab_ci_project
,
ref
,
sha
)
end
def
builds_path
project_url
+
"?ref="
+
project
.
default_branch
end
def
status_img_path
project_url
+
"/status.png?ref="
+
project
.
default_branch
end
end
def
title
def
title
...
...
spec/models/project_services/buildkite_service_spec.rb
View file @
600d6eef
...
@@ -63,19 +63,5 @@ describe BuildkiteService do
...
@@ -63,19 +63,5 @@ describe BuildkiteService do
)
)
end
end
end
end
describe
:builds_page
do
it
'returns the correct path to the builds page'
do
expect
(
@service
.
builds_path
).
to
eq
(
'https://buildkite.com/account-name/example-project/builds?branch=default-brancho'
)
end
end
describe
:status_img_path
do
it
'returns the correct path to the status image'
do
expect
(
@service
.
status_img_path
).
to
eq
(
'https://badge.buildkite.com/secret-sauce-status-token.svg'
)
end
end
end
end
end
end
spec/models/project_services/gitlab_ci_service_spec.rb
View file @
600d6eef
...
@@ -55,22 +55,19 @@ describe GitlabCiService do
...
@@ -55,22 +55,19 @@ describe GitlabCiService do
describe
'commits methods'
do
describe
'commits methods'
do
before
do
before
do
@ci_project
=
create
(
:ci_project
)
@service
=
GitlabCiService
.
new
@service
=
GitlabCiService
.
new
allow
(
@service
).
to
receive_messages
(
allow
(
@service
).
to
receive_messages
(
service_hook:
true
,
service_hook:
true
,
project_url:
'http://ci.gitlab.org/projects/2'
,
project_url:
'http://ci.gitlab.org/projects/2'
,
token:
'verySecret'
token:
'verySecret'
,
project:
@ci_project
.
gl_project
)
)
end
end
describe
:commit_status_path
do
it
{
expect
(
@service
.
commit_status_path
(
"2ab7834c"
,
'master'
)).
to
eq
(
"http://ci.gitlab.org/projects/2/refs/master/commits/2ab7834c/status.json?token=verySecret"
)}
it
{
expect
(
@service
.
commit_status_path
(
"issue#2"
,
'master'
)).
to
eq
(
"http://ci.gitlab.org/projects/2/refs/master/commits/issue%232/status.json?token=verySecret"
)}
end
describe
:build_page
do
describe
:build_page
do
it
{
expect
(
@service
.
build_page
(
"2ab7834c"
,
'master'
)).
to
eq
(
"
http://ci.gitlab.org/projects/2
/refs/master/commits/2ab7834c"
)}
it
{
expect
(
@service
.
build_page
(
"2ab7834c"
,
'master'
)).
to
eq
(
"
/ci/projects/
#{
@ci_project
.
id
}
/refs/master/commits/2ab7834c"
)}
it
{
expect
(
@service
.
build_page
(
"issue#2"
,
'master'
)).
to
eq
(
"
http://ci.gitlab.org/projects/2
/refs/master/commits/issue%232"
)}
it
{
expect
(
@service
.
build_page
(
"issue#2"
,
'master'
)).
to
eq
(
"
/ci/projects/
#{
@ci_project
.
id
}
/refs/master/commits/issue%232"
)}
end
end
describe
"execute"
do
describe
"execute"
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment