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
5e7ed643
Commit
5e7ed643
authored
Jan 03, 2020
by
GitLab Bot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add latest changes from gitlab-org/gitlab@master
parent
511e761b
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
90 additions
and
52 deletions
+90
-52
app/assets/stylesheets/framework/typography.scss
app/assets/stylesheets/framework/typography.scss
+5
-5
app/assets/stylesheets/framework/variables_overrides.scss
app/assets/stylesheets/framework/variables_overrides.scss
+1
-0
app/models/deployment.rb
app/models/deployment.rb
+4
-0
app/services/deployments/after_create_service.rb
app/services/deployments/after_create_service.rb
+0
-9
app/services/deployments/link_merge_requests_service.rb
app/services/deployments/link_merge_requests_service.rb
+4
-1
app/workers/deployments/finished_worker.rb
app/workers/deployments/finished_worker.rb
+12
-1
changelogs/unreleased/27884-fix-table-styles.yml
changelogs/unreleased/27884-fix-table-styles.yml
+5
-0
changelogs/unreleased/fix-linking-merge-requests.yml
changelogs/unreleased/fix-linking-merge-requests.yml
+5
-0
spec/models/deployment_spec.rb
spec/models/deployment_spec.rb
+23
-0
spec/services/deployments/after_create_service_spec.rb
spec/services/deployments/after_create_service_spec.rb
+0
-34
spec/services/deployments/link_merge_requests_service_spec.rb
.../services/deployments/link_merge_requests_service_spec.rb
+5
-2
spec/workers/deployments/finished_worker_spec.rb
spec/workers/deployments/finished_worker_spec.rb
+26
-0
No files found.
app/assets/stylesheets/framework/typography.scss
View file @
5e7ed643
...
@@ -179,15 +179,15 @@
...
@@ -179,15 +179,15 @@
tbody
{
tbody
{
background-color
:
$white-light
;
background-color
:
$white-light
;
td
{
border-color
:
$gray-200
;
}
}
}
tr
{
tr
{
th
{
th
{
border-bottom
:
solid
2px
$gl-gray-200
;
border-bottom
:
solid
2px
$gray-300
;
}
td
{
border-color
:
$gl-gray-200
;
}
}
}
}
...
...
app/assets/stylesheets/framework/variables_overrides.scss
View file @
5e7ed643
...
@@ -12,6 +12,7 @@ $font-family-sans-serif: $regular-font;
...
@@ -12,6 +12,7 @@ $font-family-sans-serif: $regular-font;
$font-family-monospace
:
$monospace-font
;
$font-family-monospace
:
$monospace-font
;
$btn-line-height
:
20px
;
$btn-line-height
:
20px
;
$table-accent-bg
:
$gray-light
;
$table-accent-bg
:
$gray-light
;
$table-border-color
:
$gray-200
;
$card-border-color
:
$border-color
;
$card-border-color
:
$border-color
;
$card-cap-bg
:
$gray-light
;
$card-cap-bg
:
$gray-light
;
$success
:
$green-500
;
$success
:
$green-500
;
...
...
app/models/deployment.rb
View file @
5e7ed643
...
@@ -212,10 +212,14 @@ class Deployment < ApplicationRecord
...
@@ -212,10 +212,14 @@ class Deployment < ApplicationRecord
# We don't use `Gitlab::Database.bulk_insert` here so that we don't need to
# We don't use `Gitlab::Database.bulk_insert` here so that we don't need to
# first pluck lots of IDs into memory.
# first pluck lots of IDs into memory.
#
# We also ignore any duplicates so this method can be called multiple times
# for the same deployment, only inserting any missing merge requests.
DeploymentMergeRequest
.
connection
.
execute
(
<<~
SQL
)
DeploymentMergeRequest
.
connection
.
execute
(
<<~
SQL
)
INSERT INTO
#{
DeploymentMergeRequest
.
table_name
}
INSERT INTO
#{
DeploymentMergeRequest
.
table_name
}
(merge_request_id, deployment_id)
(merge_request_id, deployment_id)
#{
select
}
#{
select
}
ON CONFLICT DO NOTHING
SQL
SQL
end
end
...
...
app/services/deployments/after_create_service.rb
View file @
5e7ed643
...
@@ -34,21 +34,12 @@ module Deployments
...
@@ -34,21 +34,12 @@ module Deployments
if
environment
.
save
&&
!
environment
.
stopped?
if
environment
.
save
&&
!
environment
.
stopped?
deployment
.
update_merge_request_metrics!
deployment
.
update_merge_request_metrics!
link_merge_requests
(
deployment
)
end
end
end
end
end
end
private
private
def
link_merge_requests
(
deployment
)
unless
Feature
.
enabled?
(
:deployment_merge_requests
,
deployment
.
project
)
return
end
LinkMergeRequestsService
.
new
(
deployment
).
execute
end
def
environment_options
def
environment_options
options
&
.
dig
(
:environment
)
||
{}
options
&
.
dig
(
:environment
)
||
{}
end
end
...
...
app/services/deployments/link_merge_requests_service.rb
View file @
5e7ed643
...
@@ -13,7 +13,10 @@ module Deployments
...
@@ -13,7 +13,10 @@ module Deployments
end
end
def
execute
def
execute
return
unless
deployment
.
success?
# Review apps have the environment type set (e.g. to `review`, though the
# exact value may differ). We don't want to link merge requests to review
# app deployments, as this is not useful.
return
if
deployment
.
environment
.
environment_type
if
(
prev
=
deployment
.
previous_environment_deployment
)
if
(
prev
=
deployment
.
previous_environment_deployment
)
link_merge_requests_for_range
(
prev
.
sha
,
deployment
.
sha
)
link_merge_requests_for_range
(
prev
.
sha
,
deployment
.
sha
)
...
...
app/workers/deployments/finished_worker.rb
View file @
5e7ed643
...
@@ -9,7 +9,18 @@ module Deployments
...
@@ -9,7 +9,18 @@ module Deployments
worker_resource_boundary
:cpu
worker_resource_boundary
:cpu
def
perform
(
deployment_id
)
def
perform
(
deployment_id
)
Deployment
.
find_by_id
(
deployment_id
).
try
(
:execute_hooks
)
if
(
deploy
=
Deployment
.
find_by_id
(
deployment_id
))
link_merge_requests
(
deploy
)
deploy
.
execute_hooks
end
end
def
link_merge_requests
(
deployment
)
unless
Feature
.
enabled?
(
:deployment_merge_requests
,
deployment
.
project
)
return
end
LinkMergeRequestsService
.
new
(
deployment
).
execute
end
end
end
end
end
end
changelogs/unreleased/27884-fix-table-styles.yml
0 → 100644
View file @
5e7ed643
---
title
:
Fix markdown table border colors
merge_request
:
22314
author
:
type
:
fixed
changelogs/unreleased/fix-linking-merge-requests.yml
0 → 100644
View file @
5e7ed643
---
title
:
Enable the linking of merge requests to all non review app deployments
merge_request
:
author
:
type
:
added
spec/models/deployment_spec.rb
View file @
5e7ed643
...
@@ -399,6 +399,29 @@ describe Deployment do
...
@@ -399,6 +399,29 @@ describe Deployment do
expect
(
deploy
.
merge_requests
).
to
include
(
mr1
,
mr2
)
expect
(
deploy
.
merge_requests
).
to
include
(
mr1
,
mr2
)
end
end
it
'ignores already linked merge requests'
do
deploy
=
create
(
:deployment
)
mr1
=
create
(
:merge_request
,
:merged
,
target_project:
deploy
.
project
,
source_project:
deploy
.
project
)
deploy
.
link_merge_requests
(
deploy
.
project
.
merge_requests
)
mr2
=
create
(
:merge_request
,
:merged
,
target_project:
deploy
.
project
,
source_project:
deploy
.
project
)
deploy
.
link_merge_requests
(
deploy
.
project
.
merge_requests
)
expect
(
deploy
.
merge_requests
).
to
include
(
mr1
,
mr2
)
end
end
end
describe
'#previous_environment_deployment'
do
describe
'#previous_environment_deployment'
do
...
...
spec/services/deployments/after_create_service_spec.rb
View file @
5e7ed643
...
@@ -61,14 +61,6 @@ describe Deployments::AfterCreateService do
...
@@ -61,14 +61,6 @@ describe Deployments::AfterCreateService do
service
.
execute
service
.
execute
end
end
it
'links merge requests to deployment'
do
expect_next_instance_of
(
Deployments
::
LinkMergeRequestsService
,
deployment
)
do
|
link_mr_service
|
expect
(
link_mr_service
).
to
receive
(
:execute
)
end
service
.
execute
end
it
'returns the deployment'
do
it
'returns the deployment'
do
expect
(
subject
.
execute
).
to
eq
(
deployment
)
expect
(
subject
.
execute
).
to
eq
(
deployment
)
end
end
...
@@ -272,30 +264,4 @@ describe Deployments::AfterCreateService do
...
@@ -272,30 +264,4 @@ describe Deployments::AfterCreateService do
end
end
end
end
end
end
describe
'#update_environment'
do
it
'links the merge requests'
do
double
=
instance_double
(
Deployments
::
LinkMergeRequestsService
)
allow
(
Deployments
::
LinkMergeRequestsService
)
.
to
receive
(
:new
)
.
with
(
deployment
)
.
and_return
(
double
)
expect
(
double
).
to
receive
(
:execute
)
service
.
update_environment
(
deployment
)
end
context
'when the tracking of merge requests is disabled'
do
it
'does nothing'
do
stub_feature_flags
(
deployment_merge_requests:
false
)
expect
(
Deployments
::
LinkMergeRequestsService
)
.
not_to
receive
(
:new
)
service
.
update_environment
(
deployment
)
end
end
end
end
end
spec/services/deployments/link_merge_requests_service_spec.rb
View file @
5e7ed643
...
@@ -6,9 +6,12 @@ describe Deployments::LinkMergeRequestsService do
...
@@ -6,9 +6,12 @@ describe Deployments::LinkMergeRequestsService do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
describe
'#execute'
do
describe
'#execute'
do
context
'when the deployment
did not succeed
'
do
context
'when the deployment
is for a review environment
'
do
it
'does nothing'
do
it
'does nothing'
do
deploy
=
create
(
:deployment
,
:failed
)
environment
=
create
(
:environment
,
environment_type:
'review'
,
name:
'review/foo'
)
deploy
=
create
(
:deployment
,
:success
,
environment:
environment
)
expect
(
deploy
).
not_to
receive
(
:link_merge_requests
)
expect
(
deploy
).
not_to
receive
(
:link_merge_requests
)
...
...
spec/workers/deployments/finished_worker_spec.rb
View file @
5e7ed643
...
@@ -10,6 +10,20 @@ describe Deployments::FinishedWorker do
...
@@ -10,6 +10,20 @@ describe Deployments::FinishedWorker do
allow
(
ProjectServiceWorker
).
to
receive
(
:perform_async
)
allow
(
ProjectServiceWorker
).
to
receive
(
:perform_async
)
end
end
it
'links merge requests to the deployment'
do
deployment
=
create
(
:deployment
)
service
=
instance_double
(
Deployments
::
LinkMergeRequestsService
)
expect
(
Deployments
::
LinkMergeRequestsService
)
.
to
receive
(
:new
)
.
with
(
deployment
)
.
and_return
(
service
)
expect
(
service
).
to
receive
(
:execute
)
worker
.
perform
(
deployment
.
id
)
end
it
'executes project services for deployment_hooks'
do
it
'executes project services for deployment_hooks'
do
deployment
=
create
(
:deployment
)
deployment
=
create
(
:deployment
)
project
=
deployment
.
project
project
=
deployment
.
project
...
@@ -35,5 +49,17 @@ describe Deployments::FinishedWorker do
...
@@ -35,5 +49,17 @@ describe Deployments::FinishedWorker do
expect
(
ProjectServiceWorker
).
not_to
have_received
(
:perform_async
)
expect
(
ProjectServiceWorker
).
not_to
have_received
(
:perform_async
)
end
end
context
'when the tracking of merge requests is disabled'
do
it
'does not track the deployed merge requests'
do
stub_feature_flags
(
deployment_merge_requests:
false
)
deployment
=
create
(
:deployment
)
expect
(
Deployments
::
LinkMergeRequestsService
).
not_to
receive
(
:new
)
worker
.
perform
(
deployment
.
id
)
end
end
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