BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
ac2bd99c
Commit
ac2bd99c
authored
Apr 12, 2017
by
Kamil Trzciński
Committed by
Lin Jen-Shin
Apr 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge branch 'zj-fix-coverage-bug' into 'master'
Return nil as coverage instead of a File object See merge request !10633
parent
58e53a01
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
7 deletions
+21
-7
build_coverage_worker.rb
app/workers/build_coverage_worker.rb
+1
-2
stream.rb
lib/gitlab/ci/trace/stream.rb
+4
-1
stream_spec.rb
spec/lib/gitlab/ci/trace/stream_spec.rb
+3
-3
trace_spec.rb
spec/lib/gitlab/ci/trace_spec.rb
+13
-1
No files found.
app/workers/build_coverage_worker.rb
View file @
ac2bd99c
...
...
@@ -3,7 +3,6 @@ class BuildCoverageWorker
include
BuildQueue
def
perform
(
build_id
)
Ci
::
Build
.
find_by
(
id:
build_id
)
.
try
(
:update_coverage
)
Ci
::
Build
.
find_by
(
id:
build_id
)
&
.
update_coverage
end
end
lib/gitlab/ci/trace/stream.rb
View file @
ac2bd99c
...
...
@@ -76,11 +76,14 @@ module Gitlab
stream
.
each_line
do
|
line
|
matches
=
line
.
scan
(
regex
)
next
unless
matches
.
is_a?
(
Array
)
next
if
matches
.
empty?
match
=
matches
.
flatten
.
last
coverage
=
match
.
gsub
(
/\d+(\.\d+)?/
).
first
return
coverage
.
to_f
if
coverage
.
present?
return
coverage
if
coverage
.
present?
end
nil
rescue
# if bad regex or something goes wrong we dont want to interrupt transition
# so we just silentrly ignore error for now
...
...
spec/lib/gitlab/ci/trace/stream_spec.rb
View file @
ac2bd99c
...
...
@@ -167,7 +167,7 @@ describe Gitlab::Ci::Trace::Stream do
let
(
:data
)
{
'Coverage 1033 / 1051 LOC (98.29%) covered'
}
let
(
:regex
)
{
'\(\d+.\d+\%\) covered'
}
it
{
is_expected
.
to
eq
(
98.29
)
}
it
{
is_expected
.
to
eq
(
"98.29"
)
}
end
context
'valid content & bad regex'
do
...
...
@@ -188,14 +188,14 @@ describe Gitlab::Ci::Trace::Stream do
let
(
:data
)
{
' (98.39%) covered. (98.29%) covered'
}
let
(
:regex
)
{
'\(\d+.\d+\%\) covered'
}
it
{
is_expected
.
to
eq
(
98.29
)
}
it
{
is_expected
.
to
eq
(
"98.29"
)
}
end
context
'using a regex capture'
do
let
(
:data
)
{
'TOTAL 9926 3489 65%'
}
let
(
:regex
)
{
'TOTAL\s+\d+\s+\d+\s+(\d{1,3}\%)'
}
it
{
is_expected
.
to
eq
(
65
)
}
it
{
is_expected
.
to
eq
(
"65"
)
}
end
end
end
spec/lib/gitlab/ci/trace_spec.rb
View file @
ac2bd99c
...
...
@@ -40,12 +40,24 @@ describe Gitlab::Ci::Trace do
describe
'#extract_coverage'
do
let
(
:regex
)
{
'\(\d+.\d+\%\) covered'
}
context
'matching coverage'
do
before
do
trace
.
set
(
'Coverage 1033 / 1051 LOC (98.29%) covered'
)
end
it
"returns valid coverage"
do
expect
(
trace
.
extract_coverage
(
regex
)).
to
eq
(
98.29
)
expect
(
trace
.
extract_coverage
(
regex
)).
to
eq
(
"98.29"
)
end
end
context
'no coverage'
do
before
do
trace
.
set
(
'No coverage'
)
end
it
'returs nil'
do
expect
(
trace
.
extract_coverage
(
regex
)).
to
be_nil
end
end
end
...
...
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