Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
b67bb566
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b67bb566
编写于
4月 18, 2017
作者:
F
Filipa Lacerda
提交者:
Phil Hughes
4月 18, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improves support for long build traces:
上级
e30fe47e
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
163 addition
and
40 deletion
+163
-40
app/assets/javascripts/build.js
app/assets/javascripts/build.js
+17
-7
app/assets/javascripts/lib/utils/constants.js
app/assets/javascripts/lib/utils/constants.js
+2
-0
app/assets/javascripts/lib/utils/number_utils.js
app/assets/javascripts/lib/utils/number_utils.js
+11
-1
app/assets/stylesheets/pages/builds.scss
app/assets/stylesheets/pages/builds.scss
+12
-1
app/views/projects/builds/show.html.haml
app/views/projects/builds/show.html.haml
+5
-5
lib/gitlab/ci/trace/stream.rb
lib/gitlab/ci/trace/stream.rb
+1
-1
spec/javascripts/build_spec.js
spec/javascripts/build_spec.js
+107
-24
spec/javascripts/lib/utils/number_utility_spec.js
spec/javascripts/lib/utils/number_utility_spec.js
+8
-1
未找到文件。
app/assets/javascripts/build.js
浏览文件 @
b67bb566
...
...
@@ -2,6 +2,8 @@
consistent-return, prefer-rest-params */
/* global Breakpoints */
import
{
bytesToKiB
}
from
'
./lib/utils/number_utils
'
;
const
bind
=
function
(
fn
,
me
)
{
return
function
()
{
return
fn
.
apply
(
me
,
arguments
);
};
};
const
AUTO_SCROLL_OFFSET
=
75
;
const
DOWN_BUILD_TRACE
=
'
#down-build-trace
'
;
...
...
@@ -20,6 +22,7 @@ window.Build = (function () {
this
.
state
=
this
.
options
.
logState
;
this
.
buildStage
=
this
.
options
.
buildStage
;
this
.
$document
=
$
(
document
);
this
.
logBytes
=
0
;
this
.
updateDropdown
=
bind
(
this
.
updateDropdown
,
this
);
...
...
@@ -98,15 +101,22 @@ window.Build = (function () {
if
(
log
.
append
)
{
$buildContainer
.
append
(
log
.
html
);
this
.
logBytes
+=
log
.
size
;
}
else
{
$buildContainer
.
html
(
log
.
html
);
if
(
log
.
truncated
)
{
$
(
'
.js-truncated-info-size
'
).
html
(
`
${
log
.
size
}
`
);
this
.
$truncatedInfo
.
removeClass
(
'
hidden
'
);
this
.
initAffixTruncatedInfo
();
}
else
{
this
.
$truncatedInfo
.
addClass
(
'
hidden
'
);
}
this
.
logBytes
=
log
.
size
;
}
// if the incremental sum of logBytes we received is less than the total
// we need to show a message warning the user about that.
if
(
this
.
logBytes
<
log
.
total
)
{
// size is in bytes, we need to calculate KiB
const
size
=
bytesToKiB
(
this
.
logBytes
);
$
(
'
.js-truncated-info-size
'
).
html
(
`
${
size
}
`
);
this
.
$truncatedInfo
.
removeClass
(
'
hidden
'
);
this
.
initAffixTruncatedInfo
();
}
else
{
this
.
$truncatedInfo
.
addClass
(
'
hidden
'
);
}
this
.
checkAutoscroll
();
...
...
app/assets/javascripts/lib/utils/constants.js
0 → 100644
浏览文件 @
b67bb566
/* eslint-disable import/prefer-default-export */
export
const
BYTES_IN_KIB
=
1024
;
app/assets/javascripts/lib/utils/number_utils.js
浏览文件 @
b67bb566
/* eslint-disable import/prefer-default-export */
import
{
BYTES_IN_KIB
}
from
'
./constants
'
;
/**
* Function that allows a number with an X amount of decimals
...
...
@@ -32,3 +32,13 @@ export function formatRelevantDigits(number) {
}
return
formattedNumber
;
}
/**
* Utility function that calculates KiB of the given bytes.
*
* @param {Number} number bytes
* @return {Number} KiB
*/
export
function
bytesToKiB
(
number
)
{
return
number
/
BYTES_IN_KIB
;
}
app/assets/stylesheets/pages/builds.scss
浏览文件 @
b67bb566
...
...
@@ -61,8 +61,9 @@
.truncated-info
{
text-align
:
center
;
border-bottom
:
1px
solid
;
background-color
:
$black
-transparent
;
background-color
:
$black
;
height
:
45px
;
padding
:
15px
;
&
.affix
{
top
:
0
;
...
...
@@ -87,6 +88,16 @@
right
:
5px
;
left
:
5px
;
}
.truncated-info-size
{
margin
:
0
5px
;
}
.raw-link
{
color
:
inherit
;
margin-left
:
5px
;
text-decoration
:
underline
;
}
}
}
...
...
app/views/projects/builds/show.html.haml
浏览文件 @
b67bb566
...
...
@@ -71,11 +71,11 @@
=
custom_icon
(
'scroll_down_hover_active'
)
#up-build-trace
%pre
.build-trace
#build-trace
.js-truncated-info.truncated-info.hidden
%span<
Showing
last
%span
.js-truncated-info-size
><
KiB
of
log
.js-truncated-info.truncated-info.hidden
<
Showing
last
%span
.js-truncated-info-size.truncated-info-size
><
KiB
of
log
-
%a
.js-raw-link.raw-link
{
:href
=>
raw_namespace_project_build_path
(
@project
.
namespace
,
@project
,
@build
)
}><
Complete
Raw
%code
.bash.js-build-output
.build-loader-animation.js-build-refresh
...
...
lib/gitlab/ci/trace/stream.rb
浏览文件 @
b67bb566
...
...
@@ -4,7 +4,7 @@ module Gitlab
# This was inspired from: http://stackoverflow.com/a/10219411/1520132
class
Stream
BUFFER_SIZE
=
4096
LIMIT_SIZE
=
50
.
kilobytes
LIMIT_SIZE
=
50
0
.
kilobytes
attr_reader
:stream
...
...
spec/javascripts/build_spec.js
浏览文件 @
b67bb566
/* eslint-disable no-new */
/* global Build */
require
(
'
~/lib/utils/datetime_utility
'
)
;
require
(
'
~/lib/utils/url_utility
'
)
;
require
(
'
~/build
'
)
;
require
(
'
~/breakpoints
'
)
;
require
(
'
vendor/jquery.nicescroll
'
)
;
import
{
bytesToKiB
}
from
'
~/lib/utils/number_utils
'
;
import
'
~/lib/utils/datetime_utility
'
;
import
'
~/lib/utils/url_utility
'
;
import
'
~/build
'
;
import
'
~/breakpoints
'
;
import
'
vendor/jquery.nicescroll
'
;
describe
(
'
Build
'
,
()
=>
{
const
BUILD_URL
=
`
${
gl
.
TEST_HOST
}
/frontend-fixtures/builds-project/builds/1`
;
...
...
@@ -144,24 +144,6 @@ describe('Build', () => {
expect
(
$
(
'
#build-trace .js-build-output
'
).
text
()).
toMatch
(
/Different/
);
});
it
(
'
shows information about truncated log
'
,
()
=>
{
jasmine
.
clock
().
tick
(
4001
);
const
[{
success
}]
=
$
.
ajax
.
calls
.
argsFor
(
0
);
success
.
call
(
$
,
{
html
:
'
<span>Update</span>
'
,
status
:
'
success
'
,
append
:
false
,
truncated
:
true
,
size
:
'
50
'
,
});
expect
(
$
(
'
#build-trace .js-truncated-info
'
).
text
().
trim
(),
).
toContain
(
'
Showing last 50 KiB of log
'
);
expect
(
$
(
'
#build-trace .js-truncated-info-size
'
).
text
()).
toMatch
(
'
50
'
);
});
it
(
'
reloads the page when the build is done
'
,
()
=>
{
spyOn
(
gl
.
utils
,
'
visitUrl
'
);
...
...
@@ -176,6 +158,107 @@ describe('Build', () => {
expect
(
gl
.
utils
.
visitUrl
).
toHaveBeenCalledWith
(
BUILD_URL
);
});
describe
(
'
truncated information
'
,
()
=>
{
describe
(
'
when size is less than total
'
,
()
=>
{
it
(
'
shows information about truncated log
'
,
()
=>
{
jasmine
.
clock
().
tick
(
4001
);
const
[{
success
}]
=
$
.
ajax
.
calls
.
argsFor
(
0
);
success
.
call
(
$
,
{
html
:
'
<span>Update</span>
'
,
status
:
'
success
'
,
append
:
false
,
size
:
50
,
total
:
100
,
});
expect
(
document
.
querySelector
(
'
.js-truncated-info
'
).
classList
).
not
.
toContain
(
'
hidden
'
);
});
it
(
'
shows the size in KiB
'
,
()
=>
{
jasmine
.
clock
().
tick
(
4001
);
const
[{
success
}]
=
$
.
ajax
.
calls
.
argsFor
(
0
);
const
size
=
50
;
success
.
call
(
$
,
{
html
:
'
<span>Update</span>
'
,
status
:
'
success
'
,
append
:
false
,
size
,
total
:
100
,
});
expect
(
document
.
querySelector
(
'
.js-truncated-info-size
'
).
textContent
.
trim
(),
).
toEqual
(
`
${
bytesToKiB
(
size
)}
`
);
});
it
(
'
shows incremented size
'
,
()
=>
{
jasmine
.
clock
().
tick
(
4001
);
let
args
=
$
.
ajax
.
calls
.
argsFor
(
0
)[
0
];
args
.
success
.
call
(
$
,
{
html
:
'
<span>Update</span>
'
,
status
:
'
success
'
,
append
:
false
,
size
:
50
,
total
:
100
,
});
expect
(
document
.
querySelector
(
'
.js-truncated-info-size
'
).
textContent
.
trim
(),
).
toEqual
(
`
${
bytesToKiB
(
50
)}
`
);
jasmine
.
clock
().
tick
(
4001
);
args
=
$
.
ajax
.
calls
.
argsFor
(
2
)[
0
];
args
.
success
.
call
(
$
,
{
html
:
'
<span>Update</span>
'
,
status
:
'
success
'
,
append
:
true
,
size
:
10
,
total
:
100
,
});
expect
(
document
.
querySelector
(
'
.js-truncated-info-size
'
).
textContent
.
trim
(),
).
toEqual
(
`
${
bytesToKiB
(
60
)}
`
);
});
it
(
'
renders the raw link
'
,
()
=>
{
jasmine
.
clock
().
tick
(
4001
);
const
[{
success
}]
=
$
.
ajax
.
calls
.
argsFor
(
0
);
success
.
call
(
$
,
{
html
:
'
<span>Update</span>
'
,
status
:
'
success
'
,
append
:
false
,
size
:
50
,
total
:
100
,
});
expect
(
document
.
querySelector
(
'
.js-raw-link
'
).
textContent
.
trim
(),
).
toContain
(
'
Complete Raw
'
);
});
});
describe
(
'
when size is equal than total
'
,
()
=>
{
it
(
'
does not show the trunctated information
'
,
()
=>
{
jasmine
.
clock
().
tick
(
4001
);
const
[{
success
}]
=
$
.
ajax
.
calls
.
argsFor
(
0
);
success
.
call
(
$
,
{
html
:
'
<span>Update</span>
'
,
status
:
'
success
'
,
append
:
false
,
size
:
100
,
total
:
100
,
});
expect
(
document
.
querySelector
(
'
.js-truncated-info
'
).
classList
).
toContain
(
'
hidden
'
);
});
});
});
});
});
});
spec/javascripts/lib/utils/number_utility_spec.js
浏览文件 @
b67bb566
import
{
formatRelevantDigits
}
from
'
~/lib/utils/number_utils
'
;
import
{
formatRelevantDigits
,
bytesToKiB
}
from
'
~/lib/utils/number_utils
'
;
describe
(
'
Number Utils
'
,
()
=>
{
describe
(
'
formatRelevantDigits
'
,
()
=>
{
...
...
@@ -38,4 +38,11 @@ describe('Number Utils', () => {
expect
(
leftFromDecimal
.
length
).
toBe
(
3
);
});
});
describe
(
'
bytesToKiB
'
,
()
=>
{
it
(
'
calculates KiB for the given bytes
'
,
()
=>
{
expect
(
bytesToKiB
(
1024
)).
toEqual
(
1
);
expect
(
bytesToKiB
(
1000
)).
toEqual
(
0.9765625
);
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录