diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-03 18:07:40 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-03 18:07:40 +0000 |
commit | 5e7ed643dca39625fcc7b0d0e9e15550f5a9f1f8 (patch) | |
tree | 6a1d9d1fc3825e7fcaf4d688f96bc97954eaa904 | |
parent | 511e761b41b81484c85e3d125f45873ce38e9201 (diff) | |
download | gitlab-ce-5e7ed643dca39625fcc7b0d0e9e15550f5a9f1f8.tar.gz |
Add latest changes from gitlab-org/gitlab@master
-rw-r--r-- | app/assets/stylesheets/framework/typography.scss | 10 | ||||
-rw-r--r-- | app/assets/stylesheets/framework/variables_overrides.scss | 1 | ||||
-rw-r--r-- | app/models/deployment.rb | 4 | ||||
-rw-r--r-- | app/services/deployments/after_create_service.rb | 9 | ||||
-rw-r--r-- | app/services/deployments/link_merge_requests_service.rb | 5 | ||||
-rw-r--r-- | app/workers/deployments/finished_worker.rb | 13 | ||||
-rw-r--r-- | changelogs/unreleased/27884-fix-table-styles.yml | 5 | ||||
-rw-r--r-- | changelogs/unreleased/fix-linking-merge-requests.yml | 5 | ||||
-rw-r--r-- | spec/models/deployment_spec.rb | 23 | ||||
-rw-r--r-- | spec/services/deployments/after_create_service_spec.rb | 34 | ||||
-rw-r--r-- | spec/services/deployments/link_merge_requests_service_spec.rb | 7 | ||||
-rw-r--r-- | spec/workers/deployments/finished_worker_spec.rb | 26 |
12 files changed, 90 insertions, 52 deletions
diff --git a/app/assets/stylesheets/framework/typography.scss b/app/assets/stylesheets/framework/typography.scss index 39e7e4bb7e5..a1bfa03a5ac 100644 --- a/app/assets/stylesheets/framework/typography.scss +++ b/app/assets/stylesheets/framework/typography.scss @@ -179,15 +179,15 @@ tbody { background-color: $white-light; + + td { + border-color: $gray-200; + } } tr { th { - border-bottom: solid 2px $gl-gray-200; - } - - td { - border-color: $gl-gray-200; + border-bottom: solid 2px $gray-300; } } diff --git a/app/assets/stylesheets/framework/variables_overrides.scss b/app/assets/stylesheets/framework/variables_overrides.scss index 604b48e11ab..7538459c97b 100644 --- a/app/assets/stylesheets/framework/variables_overrides.scss +++ b/app/assets/stylesheets/framework/variables_overrides.scss @@ -12,6 +12,7 @@ $font-family-sans-serif: $regular-font; $font-family-monospace: $monospace-font; $btn-line-height: 20px; $table-accent-bg: $gray-light; +$table-border-color: $gray-200; $card-border-color: $border-color; $card-cap-bg: $gray-light; $success: $green-500; diff --git a/app/models/deployment.rb b/app/models/deployment.rb index 101f18f3886..5a22a6ada9d 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -212,10 +212,14 @@ class Deployment < ApplicationRecord # We don't use `Gitlab::Database.bulk_insert` here so that we don't need to # 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) INSERT INTO #{DeploymentMergeRequest.table_name} (merge_request_id, deployment_id) #{select} + ON CONFLICT DO NOTHING SQL end diff --git a/app/services/deployments/after_create_service.rb b/app/services/deployments/after_create_service.rb index 1d9cb666cff..3560f9c983b 100644 --- a/app/services/deployments/after_create_service.rb +++ b/app/services/deployments/after_create_service.rb @@ -34,21 +34,12 @@ module Deployments if environment.save && !environment.stopped? deployment.update_merge_request_metrics! - link_merge_requests(deployment) end end end private - def link_merge_requests(deployment) - unless Feature.enabled?(:deployment_merge_requests, deployment.project) - return - end - - LinkMergeRequestsService.new(deployment).execute - end - def environment_options options&.dig(:environment) || {} end diff --git a/app/services/deployments/link_merge_requests_service.rb b/app/services/deployments/link_merge_requests_service.rb index 71186659290..a1d6d50bbb4 100644 --- a/app/services/deployments/link_merge_requests_service.rb +++ b/app/services/deployments/link_merge_requests_service.rb @@ -13,7 +13,10 @@ module Deployments end 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) link_merge_requests_for_range(prev.sha, deployment.sha) diff --git a/app/workers/deployments/finished_worker.rb b/app/workers/deployments/finished_worker.rb index 90bbc193651..bab197a82ff 100644 --- a/app/workers/deployments/finished_worker.rb +++ b/app/workers/deployments/finished_worker.rb @@ -9,7 +9,18 @@ module Deployments worker_resource_boundary :cpu 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 diff --git a/changelogs/unreleased/27884-fix-table-styles.yml b/changelogs/unreleased/27884-fix-table-styles.yml new file mode 100644 index 00000000000..346c7f32e3f --- /dev/null +++ b/changelogs/unreleased/27884-fix-table-styles.yml @@ -0,0 +1,5 @@ +--- +title: Fix markdown table border colors +merge_request: 22314 +author: +type: fixed diff --git a/changelogs/unreleased/fix-linking-merge-requests.yml b/changelogs/unreleased/fix-linking-merge-requests.yml new file mode 100644 index 00000000000..dbc21802b28 --- /dev/null +++ b/changelogs/unreleased/fix-linking-merge-requests.yml @@ -0,0 +1,5 @@ +--- +title: Enable the linking of merge requests to all non review app deployments +merge_request: +author: +type: added diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index 15745441698..0c1b259d6bf 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -399,6 +399,29 @@ describe Deployment do expect(deploy.merge_requests).to include(mr1, mr2) 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 describe '#previous_environment_deployment' do diff --git a/spec/services/deployments/after_create_service_spec.rb b/spec/services/deployments/after_create_service_spec.rb index 14b6dd4a74e..51c6de2c0b9 100644 --- a/spec/services/deployments/after_create_service_spec.rb +++ b/spec/services/deployments/after_create_service_spec.rb @@ -61,14 +61,6 @@ describe Deployments::AfterCreateService do service.execute 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 expect(subject.execute).to eq(deployment) end @@ -272,30 +264,4 @@ describe Deployments::AfterCreateService do 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 diff --git a/spec/services/deployments/link_merge_requests_service_spec.rb b/spec/services/deployments/link_merge_requests_service_spec.rb index a0fb3b0abb0..307fe22a192 100644 --- a/spec/services/deployments/link_merge_requests_service_spec.rb +++ b/spec/services/deployments/link_merge_requests_service_spec.rb @@ -6,9 +6,12 @@ describe Deployments::LinkMergeRequestsService do let(:project) { create(:project, :repository) } 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 - 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) diff --git a/spec/workers/deployments/finished_worker_spec.rb b/spec/workers/deployments/finished_worker_spec.rb index df62821e2cd..f0e3439fdfa 100644 --- a/spec/workers/deployments/finished_worker_spec.rb +++ b/spec/workers/deployments/finished_worker_spec.rb @@ -10,6 +10,20 @@ describe Deployments::FinishedWorker do allow(ProjectServiceWorker).to receive(:perform_async) 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 deployment = create(:deployment) project = deployment.project @@ -35,5 +49,17 @@ describe Deployments::FinishedWorker do expect(ProjectServiceWorker).not_to have_received(:perform_async) 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 |