Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
6c55a9d8
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,发现更多精彩内容 >>
提交
6c55a9d8
编写于
3月 29, 2018
作者:
J
Jacob Vosmaer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove support for legacy tar.gz pages artifacts
上级
4131c39a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
51 addition
and
67 deletion
+51
-67
app/services/projects/update_pages_service.rb
app/services/projects/update_pages_service.rb
+1
-13
spec/services/projects/update_pages_service_spec.rb
spec/services/projects/update_pages_service_spec.rb
+50
-54
未找到文件。
app/services/projects/update_pages_service.rb
浏览文件 @
6c55a9d8
...
...
@@ -74,25 +74,13 @@ module Projects
end
def
extract_archive!
(
temp_path
)
if
artifacts
.
ends_with?
(
'.tar.gz'
)
||
artifacts
.
ends_with?
(
'.tgz'
)
extract_tar_archive!
(
temp_path
)
elsif
artifacts
.
ends_with?
(
'.zip'
)
if
artifacts
.
ends_with?
(
'.zip'
)
extract_zip_archive!
(
temp_path
)
else
raise
InvaildStateError
,
'unsupported artifacts format'
end
end
def
extract_tar_archive!
(
temp_path
)
build
.
artifacts_file
.
use_file
do
|
artifacts_path
|
results
=
Open3
.
pipeline
(
%W(gunzip -c
#{
artifacts_path
}
)
,
%W(dd bs=
#{
BLOCK_SIZE
}
count=
#{
blocks
}
)
,
%W(tar -x -C
#{
temp_path
}
#{
SITE_PATH
}
)
,
err:
'/dev/null'
)
raise
FailedToExtractError
,
'pages failed to extract'
unless
results
.
compact
.
all?
(
&
:success?
)
end
end
def
extract_zip_archive!
(
temp_path
)
raise
InvaildStateError
,
'missing artifacts metadata'
unless
build
.
artifacts_metadata?
...
...
spec/services/projects/update_pages_service_spec.rb
浏览文件 @
6c55a9d8
...
...
@@ -21,76 +21,72 @@ describe Projects::UpdatePagesService do
end
context
'legacy artifacts'
do
%w(tar.gz zip)
.
each
do
|
format
|
let
(
:extension
)
{
format
}
let
(
:extension
)
{
'zip'
}
context
"for valid
#{
format
}
"
do
before
do
build
.
update_attributes
(
legacy_artifacts_file:
file
)
build
.
update_attributes
(
legacy_artifacts_metadata:
metadata
)
end
describe
'pages artifacts'
do
context
'with expiry date'
do
before
do
build
.
update_attributes
(
legacy_artifacts_file:
file
)
build
.
update_attributes
(
legacy_artifacts_metadata:
metadata
)
build
.
artifacts_expire_in
=
"2 days"
build
.
save!
end
describe
'pages artifacts'
do
context
'with expiry date'
do
before
do
build
.
artifacts_expire_in
=
"2 days"
build
.
save!
end
it
"doesn't delete artifacts"
do
expect
(
execute
).
to
eq
(
:success
)
expect
(
build
.
reload
.
artifacts?
).
to
eq
(
true
)
end
end
context
'without expiry date'
do
it
"does delete artifacts"
do
expect
(
execute
).
to
eq
(
:success
)
it
"doesn't delete artifacts"
do
expect
(
execute
).
to
eq
(
:success
)
expect
(
build
.
reload
.
artifacts?
).
to
eq
(
false
)
end
end
expect
(
build
.
reload
.
artifacts?
).
to
eq
(
true
)
end
end
it
'succeeds
'
do
expect
(
project
.
pages_deployed?
).
to
be_falsey
context
'without expiry date
'
do
it
"does delete artifacts"
do
expect
(
execute
).
to
eq
(
:success
)
expect
(
project
.
pages_deployed?
).
to
be_truthy
# Check that all expected files are extracted
%w[index.html zero .hidden/file]
.
each
do
|
filename
|
expect
(
File
.
exist?
(
File
.
join
(
project
.
public_pages_path
,
filename
))).
to
be_truthy
end
expect
(
build
.
reload
.
artifacts?
).
to
eq
(
false
)
end
end
end
it
'limits pages size
'
do
stub_application_setting
(
max_pages_size:
1
)
expect
(
execute
).
not_
to
eq
(
:success
)
end
it
'succeeds
'
do
expect
(
project
.
pages_deployed?
).
to
be_falsey
expect
(
execute
).
to
eq
(
:success
)
expect
(
project
.
pages_deployed?
).
to
be_truthy
it
'removes pages after destroy'
do
expect
(
PagesWorker
).
to
receive
(
:perform_in
)
expect
(
project
.
pages_deployed?
).
to
be_falsey
expect
(
execute
).
to
eq
(
:success
)
expect
(
project
.
pages_deployed?
).
to
be_truthy
project
.
destroy
expect
(
project
.
pages_deployed?
).
to
be_falsey
end
# Check that all expected files are extracted
%w[index.html zero .hidden/file]
.
each
do
|
filename
|
expect
(
File
.
exist?
(
File
.
join
(
project
.
public_pages_path
,
filename
))).
to
be_truthy
end
end
it
'fails if sha on branch is not latest'
do
build
.
update_attributes
(
ref:
'feature'
)
it
'limits pages size'
do
stub_application_setting
(
max_pages_size:
1
)
expect
(
execute
).
not_to
eq
(
:success
)
end
expect
(
execute
).
not_to
eq
(
:success
)
end
it
'removes pages after destroy'
do
expect
(
PagesWorker
).
to
receive
(
:perform_in
)
expect
(
project
.
pages_deployed?
).
to
be_falsey
expect
(
execute
).
to
eq
(
:success
)
expect
(
project
.
pages_deployed?
).
to
be_truthy
project
.
destroy
expect
(
project
.
pages_deployed?
).
to
be_falsey
end
it
'fails for empty file fails
'
do
build
.
update_attributes
(
legacy_artifacts_file:
empty_file
)
it
'fails if sha on branch is not latest
'
do
build
.
update_attributes
(
ref:
'feature'
)
expect
{
execute
}
.
to
raise_error
(
Projects
::
UpdatePagesService
::
FailedToExtractError
)
end
end
expect
(
execute
).
not_to
eq
(
:success
)
end
it
'fails for empty file fails'
do
build
.
update_attributes
(
legacy_artifacts_file:
empty_file
)
expect
{
execute
}
.
to
raise_error
(
Projects
::
UpdatePagesService
::
FailedToExtractError
)
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录