Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
eaad745c8a56
Commit
f2e651e5
authored
Mar 05, 2018
by
Shinya Maeda
Browse files
Rework to minimize changes
parent
d1eb43d584a2
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/services/projects/update_pages_service.rb
View file @
eaad745c
module
Projects
class
UpdatePagesService
<
BaseService
InvaildStateError
=
Class
.
new
(
StandardError
)
BLOCK_SIZE
=
32
.
kilobytes
MAX_SIZE
=
1
.
terabyte
SITE_PATH
=
'public/'
.
freeze
...
...
@@ -11,13 +12,15 @@ def initialize(project, build)
end
def
execute
register_attempt
# Create status notifying the deployment of pages
@status
=
create_status
@status
.
enqueue!
@status
.
run!
raise
'missing pages artifacts'
unless
build
.
artifacts?
raise
'pages are outdated'
unless
latest?
raise
InvaildStateError
,
'missing pages artifacts'
unless
build
.
artifacts?
raise
InvaildStateError
,
'pages are outdated'
unless
latest?
# Create temporary directory in which we will extract the artifacts
FileUtils
.
mkdir_p
(
tmp_path
)
...
...
@@ -26,24 +29,22 @@ def execute
# Check if we did extract public directory
archive_public_path
=
File
.
join
(
archive_path
,
'public'
)
raise
'pages miss the public folder'
unless
Dir
.
exist?
(
archive_public_path
)
raise
'pages are outdated'
unless
latest?
raise
InvaildStateError
,
'pages miss the public folder'
unless
Dir
.
exist?
(
archive_public_path
)
raise
InvaildStateError
,
'pages are outdated'
unless
latest?
deploy_page!
(
archive_public_path
)
success
end
rescue
=>
e
rescue
InvaildStateError
=>
e
register_failure
error
(
e
.
message
)
ensure
register_attempt
build
.
erase_artifacts!
unless
build
.
has_expiring_artifacts?
end
private
def
success
@status
.
success
delete_artifact!
super
end
...
...
@@ -52,6 +53,7 @@ def error(message, http_status = nil)
@status
.
allow_failure
=
!
latest?
@status
.
description
=
message
@status
.
drop
(
:script_failure
)
delete_artifact!
super
end
...
...
@@ -163,6 +165,11 @@ def artifacts
build
.
artifacts_file
.
path
end
def
delete_artifact!
build
.
reload
build
.
erase_artifacts!
unless
build
.
has_expiring_artifacts?
end
def
latest_sha
project
.
commit
(
build
.
ref
).
try
(
:sha
).
to_s
end
...
...
app/workers/pages_worker.rb
View file @
eaad745c
class
PagesWorker
include
ApplicationWorker
sidekiq_options
retry:
false
sidekiq_options
retry:
3
def
perform
(
action
,
*
arg
)
send
(
action
,
*
arg
)
# rubocop:disable GitlabSecurity/PublicSend
...
...
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