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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
b009a008
Commit
b009a008
authored
Jun 04, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove PagesService and instead make it explicit that we call PagesWorker
parent
f12ee2a2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
83 additions
and
69 deletions
+83
-69
app/models/ci/build.rb
app/models/ci/build.rb
+6
-1
app/services/pages_service.rb
app/services/pages_service.rb
+0
-15
changelogs/unreleased/optimise-pages-service-calling.yml
changelogs/unreleased/optimise-pages-service-calling.yml
+5
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+72
-0
spec/services/pages_service_spec.rb
spec/services/pages_service_spec.rb
+0
-53
No files found.
app/models/ci/build.rb
View file @
b009a008
...
...
@@ -144,6 +144,7 @@ module Ci
after_transition
any
=>
[
:success
]
do
|
build
|
build
.
run_after_commit
do
BuildSuccessWorker
.
perform_async
(
id
)
PagesWorker
.
perform_async
(
:deploy
,
id
)
if
build
.
pages_generator?
end
end
...
...
@@ -183,6 +184,11 @@ module Ci
pipeline
.
manual_actions
.
where
.
not
(
name:
name
)
end
def
pages_generator?
Gitlab
.
config
.
pages
.
enabled
&&
self
.
name
==
'pages'
end
def
playable?
action?
&&
(
manual?
||
retryable?
)
end
...
...
@@ -402,7 +408,6 @@ module Ci
build_data
=
Gitlab
::
DataBuilder
::
Build
.
build
(
self
)
project
.
execute_hooks
(
build_data
.
dup
,
:job_hooks
)
project
.
execute_services
(
build_data
.
dup
,
:job_hooks
)
PagesService
.
new
(
build_data
).
execute
end
def
browsable_artifacts?
...
...
app/services/pages_service.rb
deleted
100644 → 0
View file @
f12ee2a2
class
PagesService
attr_reader
:data
def
initialize
(
data
)
@data
=
data
end
def
execute
return
unless
Settings
.
pages
.
enabled
return
unless
data
[
:build_name
]
==
'pages'
return
unless
data
[
:build_status
]
==
'success'
PagesWorker
.
perform_async
(
:deploy
,
data
[
:build_id
])
end
end
changelogs/unreleased/optimise-pages-service-calling.yml
0 → 100644
View file @
b009a008
---
title
:
Optimise PagesWorker usage
merge_request
:
author
:
type
:
performance
spec/models/ci/build_spec.rb
View file @
b009a008
...
...
@@ -2506,4 +2506,76 @@ describe Ci::Build do
end
end
end
describe
'pages deployments'
do
set
(
:build
)
{
create
(
:ci_build
,
project:
project
,
user:
user
)
}
context
'when job is "pages"'
do
before
do
build
.
name
=
'pages'
end
context
'when pages are enabled'
do
before
do
allow
(
Gitlab
.
config
.
pages
).
to
receive_messages
(
enabled:
true
)
end
it
'is marked as pages generator'
do
expect
(
build
).
to
be_pages_generator
end
context
'job succeeds'
do
it
"calls pages worker"
do
expect
(
PagesWorker
).
to
receive
(
:perform_async
).
with
(
:deploy
,
build
.
id
)
build
.
success!
end
end
context
'job fails'
do
it
"does not call pages worker"
do
expect
(
PagesWorker
).
not_to
receive
(
:perform_async
)
build
.
drop!
end
end
end
context
'when pages are disabled'
do
before
do
allow
(
Gitlab
.
config
.
pages
).
to
receive_messages
(
enabled:
false
)
end
it
'is not marked as pages generator'
do
expect
(
build
).
not_to
be_pages_generator
end
context
'job succeeds'
do
it
"does not call pages worker"
do
expect
(
PagesWorker
).
not_to
receive
(
:perform_async
)
build
.
success!
end
end
end
end
context
'when job is not "pages"'
do
before
do
build
.
name
=
'other-job'
end
it
'is not marked as pages generator'
do
expect
(
build
).
not_to
be_pages_generator
end
context
'job succeeds'
do
it
"does not call pages worker"
do
expect
(
PagesWorker
).
not_to
receive
(
:perform_async
)
build
.
success
end
end
end
end
end
spec/services/pages_service_spec.rb
deleted
100644 → 0
View file @
f12ee2a2
require
'spec_helper'
describe
PagesService
do
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:data
)
{
Gitlab
::
DataBuilder
::
Build
.
build
(
build
)
}
let
(
:service
)
{
described_class
.
new
(
data
)
}
before
do
allow
(
Gitlab
.
config
.
pages
).
to
receive
(
:enabled
).
and_return
(
true
)
end
context
'execute asynchronously for pages job'
do
before
do
build
.
name
=
'pages'
end
context
'on success'
do
before
do
build
.
success
end
it
'executes worker'
do
expect
(
PagesWorker
).
to
receive
(
:perform_async
)
service
.
execute
end
end
%w(pending running failed canceled)
.
each
do
|
status
|
context
"on
#{
status
}
"
do
before
do
build
.
status
=
status
end
it
'does not execute worker'
do
expect
(
PagesWorker
).
not_to
receive
(
:perform_async
)
service
.
execute
end
end
end
end
context
'for other jobs'
do
before
do
build
.
name
=
'other job'
build
.
success
end
it
'does not execute worker'
do
expect
(
PagesWorker
).
not_to
receive
(
:perform_async
)
service
.
execute
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