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
Jérome Perrin
gitlab-ce
Commits
6c55a9d8
Commit
6c55a9d8
authored
Mar 29, 2018
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove support for legacy tar.gz pages artifacts
parent
4131c39a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
67 deletions
+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
No files found.
app/services/projects/update_pages_service.rb
View file @
6c55a9d8
...
@@ -74,25 +74,13 @@ module Projects
...
@@ -74,25 +74,13 @@ module Projects
end
end
def
extract_archive!
(
temp_path
)
def
extract_archive!
(
temp_path
)
if
artifacts
.
ends_with?
(
'.tar.gz'
)
||
artifacts
.
ends_with?
(
'.tgz'
)
if
artifacts
.
ends_with?
(
'.zip'
)
extract_tar_archive!
(
temp_path
)
elsif
artifacts
.
ends_with?
(
'.zip'
)
extract_zip_archive!
(
temp_path
)
extract_zip_archive!
(
temp_path
)
else
else
raise
InvaildStateError
,
'unsupported artifacts format'
raise
InvaildStateError
,
'unsupported artifacts format'
end
end
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
)
def
extract_zip_archive!
(
temp_path
)
raise
InvaildStateError
,
'missing artifacts metadata'
unless
build
.
artifacts_metadata?
raise
InvaildStateError
,
'missing artifacts metadata'
unless
build
.
artifacts_metadata?
...
...
spec/services/projects/update_pages_service_spec.rb
View file @
6c55a9d8
...
@@ -21,76 +21,72 @@ describe Projects::UpdatePagesService do
...
@@ -21,76 +21,72 @@ describe Projects::UpdatePagesService do
end
end
context
'legacy artifacts'
do
context
'legacy artifacts'
do
%w(tar.gz zip)
.
each
do
|
format
|
let
(
:extension
)
{
'zip'
}
let
(
:extension
)
{
format
}
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
before
do
build
.
update_attributes
(
legacy_artifacts_file:
file
)
build
.
artifacts_expire_in
=
"2 days"
build
.
update_attributes
(
legacy_artifacts_metadata:
metadata
)
build
.
save!
end
end
describe
'pages artifacts'
do
it
"doesn't delete artifacts"
do
context
'with expiry date'
do
expect
(
execute
).
to
eq
(
:success
)
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
)
expect
(
build
.
reload
.
artifacts?
).
to
eq
(
false
)
expect
(
build
.
reload
.
artifacts?
).
to
eq
(
true
)
end
end
end
end
end
it
'succeeds
'
do
context
'without expiry date
'
do
expect
(
project
.
pages_deployed?
).
to
be_falsey
it
"does delete artifacts"
do
expect
(
execute
).
to
eq
(
:success
)
expect
(
execute
).
to
eq
(
:success
)
expect
(
project
.
pages_deployed?
).
to
be_truthy
# Check that all expected files are extracted
expect
(
build
.
reload
.
artifacts?
).
to
eq
(
false
)
%w[index.html zero .hidden/file]
.
each
do
|
filename
|
expect
(
File
.
exist?
(
File
.
join
(
project
.
public_pages_path
,
filename
))).
to
be_truthy
end
end
end
end
end
it
'limits pages size
'
do
it
'succeeds
'
do
stub_application_setting
(
max_pages_size:
1
)
expect
(
project
.
pages_deployed?
).
to
be_falsey
expect
(
execute
).
not_
to
eq
(
:success
)
expect
(
execute
).
to
eq
(
:success
)
end
expect
(
project
.
pages_deployed?
).
to
be_truthy
it
'removes pages after destroy'
do
# Check that all expected files are extracted
expect
(
PagesWorker
).
to
receive
(
:perform_in
)
%w[index.html zero .hidden/file]
.
each
do
|
filename
|
expect
(
project
.
pages_deployed?
).
to
be_falsey
expect
(
File
.
exist?
(
File
.
join
(
project
.
public_pages_path
,
filename
))).
to
be_truthy
expect
(
execute
).
to
eq
(
:success
)
end
expect
(
project
.
pages_deployed?
).
to
be_truthy
end
project
.
destroy
expect
(
project
.
pages_deployed?
).
to
be_falsey
end
it
'fails if sha on branch is not latest'
do
it
'limits pages size'
do
build
.
update_attributes
(
ref:
'feature'
)
stub_application_setting
(
max_pages_size:
1
)
expect
(
execute
).
not_to
eq
(
:success
)
end
expect
(
execute
).
not_to
eq
(
:success
)
it
'removes pages after destroy'
do
end
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
it
'fails if sha on branch is not latest
'
do
build
.
update_attributes
(
legacy_artifacts_file:
empty_file
)
build
.
update_attributes
(
ref:
'feature'
)
expect
{
execute
}
expect
(
execute
).
not_to
eq
(
:success
)
.
to
raise_error
(
Projects
::
UpdatePagesService
::
FailedToExtractError
)
end
end
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
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