Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.rubocop.yml5
-rw-r--r--app/views/projects/settings/ci_cd/_autodevops_form.html.haml2
-rw-r--r--app/views/users/_deletion_guidance.html.haml7
-rw-r--r--changelogs/unreleased/208132-add-ecs-to-autodeploy.yml5
-rw-r--r--changelogs/unreleased/22691-externelize-i18n-strings-from---app-views-users-_deletion_guidance-.yml5
-rw-r--r--doc/topics/autodevops/index.md32
-rw-r--r--doc/user/application_security/index.md1
-rw-r--r--lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml3
-rw-r--r--lib/gitlab/ci/templates/Jobs/Deploy.gitlab-ci.yml3
-rw-r--r--lib/gitlab/ci/templates/Jobs/Deploy/ECS.gitlab-ci.yml30
-rw-r--r--locale/gitlab.pot14
-rw-r--r--spec/graphql/gitlab_schema_spec.rb16
-rw-r--r--spec/helpers/visibility_level_helper_spec.rb26
-rw-r--r--spec/initializers/secret_token_spec.rb9
-rw-r--r--spec/lib/declarative_policy_spec.rb6
-rw-r--r--spec/lib/gitlab/background_migration/migrate_issue_trackers_sensitive_data_spec.rb61
-rw-r--r--spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb94
-rw-r--r--spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb2
18 files changed, 232 insertions, 89 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index 77dd43f5d87..4ee8d4962b3 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -348,12 +348,7 @@ RSpec/LeakyConstantDeclaration:
Enabled: true
Exclude:
- 'spec/db/schema_spec.rb'
- - 'spec/graphql/gitlab_schema_spec.rb'
- - 'spec/helpers/visibility_level_helper_spec.rb'
- - 'spec/initializers/secret_token_spec.rb'
- - 'spec/lib/declarative_policy_spec.rb'
- 'spec/lib/feature_spec.rb'
- - 'spec/lib/gitlab/background_migration/migrate_issue_trackers_sensitive_data_spec.rb'
- 'spec/lib/gitlab/ci/build/credentials/factory_spec.rb'
- 'spec/lib/gitlab/ci/config/entry/retry_spec.rb'
- 'spec/lib/gitlab/cluster/mixins/puma_cluster_spec.rb'
diff --git a/app/views/projects/settings/ci_cd/_autodevops_form.html.haml b/app/views/projects/settings/ci_cd/_autodevops_form.html.haml
index 6702786fdb3..8b84acb67c1 100644
--- a/app/views/projects/settings/ci_cd/_autodevops_form.html.haml
+++ b/app/views/projects/settings/ci_cd/_autodevops_form.html.haml
@@ -30,7 +30,7 @@
.card-footer.js-extra-settings{ class: auto_devops_enabled || 'hidden' }
- if @project.all_clusters.empty?
%p.settings-message.text-center
- = s_('CICD|You must add a %{kubernetes_cluster_link_start}Kubernetes cluster integration%{link_end} to this project with a domain in order for your deployment strategy to work correctly.').html_safe % { kubernetes_cluster_link_start: kubernetes_cluster_link_start, link_end: link_end }
+ = s_('CICD|Add a %{kubernetes_cluster_link_start}Kubernetes cluster integration%{link_end} with a domain or create an AUTO_DEVOPS_PLATFORM_TARGET CI variable.').html_safe % { kubernetes_cluster_link_start: kubernetes_cluster_link_start, link_end: link_end }
- elsif !has_base_domain
%p.settings-message.text-center
= s_('CICD|You must add a %{base_domain_link_start}base domain%{link_end} to your %{kubernetes_cluster_link_start}Kubernetes cluster%{link_end} in order for your deployment strategy to work.').html_safe % { base_domain_link_start: base_domain_link_start, kubernetes_cluster_link_start: kubernetes_cluster_link_start, link_end: link_end }
diff --git a/app/views/users/_deletion_guidance.html.haml b/app/views/users/_deletion_guidance.html.haml
index 0545cab538c..7169aebea74 100644
--- a/app/views/users/_deletion_guidance.html.haml
+++ b/app/views/users/_deletion_guidance.html.haml
@@ -3,8 +3,9 @@
%ul
%li
%p
- Certain user content will be moved to a system-wide "Ghost User" in order to maintain content for posterity. For further information, please refer to the
- = link_to 'user account deletion documentation.', help_page_path("user/profile/account/delete_account", anchor: "associated-records")
+ - link_start = '<a href="%{url}">'.html_safe % { url: help_page_path("user/profile/account/delete_account", anchor: "associated-records") }
+ = _('Certain user content will be moved to a system-wide "Ghost User" in order to maintain content for posterity. For further information, please refer to the %{link_start}user account deletion documentation.%{link_end}').html_safe % { link_start: link_start, link_end: '</a>'.html_safe }
- personal_projects_count = user.personal_projects.count
- unless personal_projects_count.zero?
- %li #{pluralize(personal_projects_count, 'personal project')} will be removed and cannot be restored
+ %li
+ = n_('personal project will be removed and cannot be restored', '%d personal projects will be removed and cannot be restored', personal_projects_count)
diff --git a/changelogs/unreleased/208132-add-ecs-to-autodeploy.yml b/changelogs/unreleased/208132-add-ecs-to-autodeploy.yml
new file mode 100644
index 00000000000..92f77c1fe86
--- /dev/null
+++ b/changelogs/unreleased/208132-add-ecs-to-autodeploy.yml
@@ -0,0 +1,5 @@
+---
+title: Add Deployment to ECS process to AutoDevOps
+merge_request: 29971
+author:
+type: added
diff --git a/changelogs/unreleased/22691-externelize-i18n-strings-from---app-views-users-_deletion_guidance-.yml b/changelogs/unreleased/22691-externelize-i18n-strings-from---app-views-users-_deletion_guidance-.yml
new file mode 100644
index 00000000000..6f4a1864a18
--- /dev/null
+++ b/changelogs/unreleased/22691-externelize-i18n-strings-from---app-views-users-_deletion_guidance-.yml
@@ -0,0 +1,5 @@
+---
+title: Externalize i18n strings from ./app/views/users/_deletion_guidance.html.haml
+merge_request: 32097
+author: Gilang Gumilar
+type: changed
diff --git a/doc/topics/autodevops/index.md b/doc/topics/autodevops/index.md
index ceea065710d..a4d433ec264 100644
--- a/doc/topics/autodevops/index.md
+++ b/doc/topics/autodevops/index.md
@@ -53,6 +53,9 @@ If you use a self-managed instance of GitLab, you must configure the
configuring a cluster on GKE. After configuring the provider, you can follow
the steps in the [quick start guide](quick_start_guide.md) to get started.
+In [GitLab 13.0](https://gitlab.com/gitlab-org/gitlab/-/issues/208132) and later, it is
+possible to leverage Auto DevOps to deploy to [AWS ECS](#aws-ecs).
+
## Comparison to application platforms and PaaS
Auto DevOps provides features often included in an application
@@ -110,7 +113,9 @@ Auto DevOps.
## Requirements
-To make full use of Auto DevOps, you need:
+### Kubernetes
+
+To make full use of Auto DevOps with Kubernetes, you need:
- **Kubernetes** (for [Auto Review Apps](stages.md#auto-review-apps),
[Auto Deploy](stages.md#auto-deploy), and [Auto Monitoring](stages.md#auto-monitoring))
@@ -202,6 +207,31 @@ are skipped.
After all requirements are met, you can [enable Auto DevOps](#enablingdisabling-auto-devops).
+### AWS ECS
+
+> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/208132) in GitLab 13.0.
+
+You can choose to target [AWS ECS](../../ci/cloud_deployment/index.md) as a deployment platform instead of using Kubernetes.
+
+To get started on Auto DevOps to ECS, you'll have to add a specific Environment
+Variable. To do so, follow these steps:
+
+1. In your project, go to **Settings > CI / CD** and expand the **Variables**
+ section.
+
+1. Specify which AWS platform to target during the Auto DevOps deployment
+ by adding the `AUTO_DEVOPS_PLATFORM_TARGET` variable.
+
+1. Give this variable the value `ECS` before saving it.
+
+When you trigger a pipeline, if you have AutoDev Ops enabled and if you have correctly
+[entered AWS credentials as environment variables](../../ci/cloud_deployment/index.md#deploy-your-application-to-aws-elastic-container-service-ecs),
+your application will be deployed to AWS ECS.
+
+NOTE: **Note:**
+If you have both a valid `AUTO_DEVOPS_PLATFORM_TARGET` variable and a Kubernetes cluster tied to your project,
+only the deployment to Kubernetes will run.
+
## Auto DevOps base domain
The Auto DevOps base domain is required to use
diff --git a/doc/user/application_security/index.md b/doc/user/application_security/index.md
index a86da0ef16f..eefa52eb5c3 100644
--- a/doc/user/application_security/index.md
+++ b/doc/user/application_security/index.md
@@ -60,6 +60,7 @@ GitLab uses the following tools to scan and report known vulnerabilities found i
| [Dependency List](dependency_list/index.md) **(ULTIMATE)** | View your project's dependencies and their known vulnerabilities. |
| [Dependency Scanning](dependency_scanning/index.md) **(ULTIMATE)** | Analyze your dependencies for known vulnerabilities. |
| [Dynamic Application Security Testing (DAST)](dast/index.md) **(ULTIMATE)** | Analyze running web applications for known vulnerabilities. |
+| [Secret Detection](secret_detection/index.md) **(ULTIMATE)** | Analyze Git history for leaked secrets. |
| [Security Dashboard](security_dashboard/index.md) **(ULTIMATE)** | View vulnerabilities in all your projects and groups. |
| [Static Application Security Testing (SAST)](sast/index.md) **(ULTIMATE)** | Analyze source code for known vulnerabilities. |
diff --git a/lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml b/lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml
index 9e6c1c8d7be..82b2f5c035e 100644
--- a/lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml
+++ b/lib/gitlab/ci/templates/Deploy-ECS.gitlab-ci.yml
@@ -5,6 +5,9 @@ stages:
- deploy
- production
+variables:
+ AUTO_DEVOPS_PLATFORM_TARGET: ECS
+
include:
- template: Jobs/Build.gitlab-ci.yml
- template: Jobs/Deploy/ECS.gitlab-ci.yml
diff --git a/lib/gitlab/ci/templates/Jobs/Deploy.gitlab-ci.yml b/lib/gitlab/ci/templates/Jobs/Deploy.gitlab-ci.yml
index a09506dc692..b4e5a41a34d 100644
--- a/lib/gitlab/ci/templates/Jobs/Deploy.gitlab-ci.yml
+++ b/lib/gitlab/ci/templates/Jobs/Deploy.gitlab-ci.yml
@@ -1,6 +1,9 @@
.auto-deploy:
image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-deploy-image:v0.15.0"
+include:
+ - template: Jobs/Deploy/ECS.gitlab-ci.yml
+
review:
extends: .auto-deploy
stage: review
diff --git a/lib/gitlab/ci/templates/Jobs/Deploy/ECS.gitlab-ci.yml b/lib/gitlab/ci/templates/Jobs/Deploy/ECS.gitlab-ci.yml
index 6579aab2b42..642f0ebeaf7 100644
--- a/lib/gitlab/ci/templates/Jobs/Deploy/ECS.gitlab-ci.yml
+++ b/lib/gitlab/ci/templates/Jobs/Deploy/ECS.gitlab-ci.yml
@@ -1,26 +1,30 @@
.deploy_to_ecs:
- image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-ecs:latest
+ image: 'registry.gitlab.com/gitlab-org/cloud-deploy/aws-ecs:latest'
script:
- ecs update-task-definition
-review:
+review_ecs:
extends: .deploy_to_ecs
stage: review
environment:
name: review/$CI_COMMIT_REF_NAME
- only:
- refs:
- - branches
- - tags
- except:
- refs:
- - master
+ rules:
+ - if: '$AUTO_DEVOPS_PLATFORM_TARGET != "ECS"'
+ when: never
+ - if: '$CI_KUBERNETES_ACTIVE'
+ when: never
+ - if: '$REVIEW_DISABLED'
+ when: never
+ - if: '$CI_COMMIT_BRANCH != "master"'
-production:
+production_ecs:
extends: .deploy_to_ecs
stage: production
environment:
name: production
- only:
- refs:
- - master
+ rules:
+ - if: '$AUTO_DEVOPS_PLATFORM_TARGET != "ECS"'
+ when: never
+ - if: '$CI_KUBERNETES_ACTIVE'
+ when: never
+ - if: '$CI_COMMIT_BRANCH == "master"'
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 3521d0115e6..7897870ff4d 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -3569,6 +3569,9 @@ msgstr ""
msgid "CI/CD settings"
msgstr ""
+msgid "CICD|Add a %{kubernetes_cluster_link_start}Kubernetes cluster integration%{link_end} with a domain or create an AUTO_DEVOPS_PLATFORM_TARGET CI variable."
+msgstr ""
+
msgid "CICD|Auto DevOps"
msgstr ""
@@ -3599,9 +3602,6 @@ msgstr ""
msgid "CICD|You must add a %{base_domain_link_start}base domain%{link_end} to your %{kubernetes_cluster_link_start}Kubernetes cluster%{link_end} in order for your deployment strategy to work."
msgstr ""
-msgid "CICD|You must add a %{kubernetes_cluster_link_start}Kubernetes cluster integration%{link_end} to this project with a domain in order for your deployment strategy to work correctly."
-msgstr ""
-
msgid "CICD|group enabled"
msgstr ""
@@ -3722,6 +3722,9 @@ msgstr ""
msgid "Capacity threshold"
msgstr ""
+msgid "Certain user content will be moved to a system-wide \"Ghost User\" in order to maintain content for posterity. For further information, please refer to the %{link_start}user account deletion documentation.%{link_end}"
+msgstr ""
+
msgid "Certificate"
msgstr ""
@@ -26194,6 +26197,11 @@ msgstr ""
msgid "personal access tokens"
msgstr ""
+msgid "personal project will be removed and cannot be restored"
+msgid_plural "%d personal projects will be removed and cannot be restored"
+msgstr[0] ""
+msgstr[1] ""
+
msgid "pipeline"
msgstr ""
diff --git a/spec/graphql/gitlab_schema_spec.rb b/spec/graphql/gitlab_schema_spec.rb
index 0f21a55f7e9..8960ad91543 100644
--- a/spec/graphql/gitlab_schema_spec.rb
+++ b/spec/graphql/gitlab_schema_spec.rb
@@ -191,13 +191,17 @@ describe GitlabSchema do
context 'for other classes' do
# We cannot use an anonymous class here as `GlobalID` expects `.name` not
# to return `nil`
- class TestGlobalId
- include GlobalID::Identification
- attr_accessor :id
-
- def initialize(id)
- @id = id
+ before do
+ test_global_id = Class.new do
+ include GlobalID::Identification
+ attr_accessor :id
+
+ def initialize(id)
+ @id = id
+ end
end
+
+ stub_const('TestGlobalId', test_global_id)
end
it 'falls back to a regular find' do
diff --git a/spec/helpers/visibility_level_helper_spec.rb b/spec/helpers/visibility_level_helper_spec.rb
index debe4401308..b7a88ee5010 100644
--- a/spec/helpers/visibility_level_helper_spec.rb
+++ b/spec/helpers/visibility_level_helper_spec.rb
@@ -146,22 +146,22 @@ describe VisibilityLevelHelper do
using RSpec::Parameterized::TableSyntax
- PUBLIC = Gitlab::VisibilityLevel::PUBLIC
- INTERNAL = Gitlab::VisibilityLevel::INTERNAL
- PRIVATE = Gitlab::VisibilityLevel::PRIVATE
+ public_vis = Gitlab::VisibilityLevel::PUBLIC
+ internal_vis = Gitlab::VisibilityLevel::INTERNAL
+ private_vis = Gitlab::VisibilityLevel::PRIVATE
# This is a subset of all the permutations
where(:requested_level, :max_allowed, :global_default_level, :restricted_levels, :expected) do
- PUBLIC | PUBLIC | PUBLIC | [] | PUBLIC
- PUBLIC | PUBLIC | PUBLIC | [PUBLIC] | INTERNAL
- INTERNAL | PUBLIC | PUBLIC | [] | INTERNAL
- INTERNAL | PRIVATE | PRIVATE | [] | PRIVATE
- PRIVATE | PUBLIC | PUBLIC | [] | PRIVATE
- PUBLIC | PRIVATE | INTERNAL | [] | PRIVATE
- PUBLIC | INTERNAL | PUBLIC | [] | INTERNAL
- PUBLIC | PRIVATE | PUBLIC | [] | PRIVATE
- PUBLIC | INTERNAL | INTERNAL | [] | INTERNAL
- PUBLIC | PUBLIC | INTERNAL | [] | PUBLIC
+ public_vis | public_vis | public_vis | [] | public_vis
+ public_vis | public_vis | public_vis | [public_vis] | internal_vis
+ internal_vis | public_vis | public_vis | [] | internal_vis
+ internal_vis | private_vis | private_vis | [] | private_vis
+ private_vis | public_vis | public_vis | [] | private_vis
+ public_vis | private_vis | internal_vis | [] | private_vis
+ public_vis | internal_vis | public_vis | [] | internal_vis
+ public_vis | private_vis | public_vis | [] | private_vis
+ public_vis | internal_vis | internal_vis | [] | internal_vis
+ public_vis | public_vis | internal_vis | [] | public_vis
end
before do
diff --git a/spec/initializers/secret_token_spec.rb b/spec/initializers/secret_token_spec.rb
index c29f46e7779..b7979144c72 100644
--- a/spec/initializers/secret_token_spec.rb
+++ b/spec/initializers/secret_token_spec.rb
@@ -7,9 +7,8 @@ describe 'create_tokens' do
include StubENV
let(:secrets) { ActiveSupport::OrderedOptions.new }
-
- HEX_KEY = /\h{128}/.freeze
- RSA_KEY = /\A-----BEGIN RSA PRIVATE KEY-----\n.+\n-----END RSA PRIVATE KEY-----\n\Z/m.freeze
+ let(:hex_key) { /\h{128}/.freeze }
+ let(:rsa_key) { /\A-----BEGIN RSA PRIVATE KEY-----\n.+\n-----END RSA PRIVATE KEY-----\n\Z/m.freeze }
before do
allow(File).to receive(:write)
@@ -35,7 +34,7 @@ describe 'create_tokens' do
keys = secrets.values_at(:secret_key_base, :otp_key_base, :db_key_base)
expect(keys.uniq).to eq(keys)
- expect(keys).to all(match(HEX_KEY))
+ expect(keys).to all(match(hex_key))
end
it 'generates an RSA key for openid_connect_signing_key' do
@@ -44,7 +43,7 @@ describe 'create_tokens' do
keys = secrets.values_at(:openid_connect_signing_key)
expect(keys.uniq).to eq(keys)
- expect(keys).to all(match(RSA_KEY))
+ expect(keys).to all(match(rsa_key))
end
it 'warns about the secrets to add to secrets.yml' do
diff --git a/spec/lib/declarative_policy_spec.rb b/spec/lib/declarative_policy_spec.rb
index 0904b084c57..5fdb3c27738 100644
--- a/spec/lib/declarative_policy_spec.rb
+++ b/spec/lib/declarative_policy_spec.rb
@@ -23,8 +23,10 @@ describe DeclarativePolicy do
end
context 'when found policy class does not inherit base' do
- class Foo; end
- class FooPolicy; end
+ before do
+ stub_const('Foo', Class.new)
+ stub_const('FooPolicy', Class.new)
+ end
it 'raises error if inferred class does not inherit Base' do
instance = Foo.new
diff --git a/spec/lib/gitlab/background_migration/migrate_issue_trackers_sensitive_data_spec.rb b/spec/lib/gitlab/background_migration/migrate_issue_trackers_sensitive_data_spec.rb
index 09a4d4444eb..4411dca3fd9 100644
--- a/spec/lib/gitlab/background_migration/migrate_issue_trackers_sensitive_data_spec.rb
+++ b/spec/lib/gitlab/background_migration/migrate_issue_trackers_sensitive_data_spec.rb
@@ -4,40 +4,45 @@ require 'spec_helper'
describe Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData, schema: 20200130145430 do
let(:services) { table(:services) }
- # we need to define the classes due to encryption
- class IssueTrackerData < ApplicationRecord
- self.table_name = 'issue_tracker_data'
-
- def self.encryption_options
- {
- key: Settings.attr_encrypted_db_key_base_32,
- encode: true,
- mode: :per_attribute_iv,
- algorithm: 'aes-256-gcm'
- }
+ before do
+ # we need to define the classes due to encryption
+ issue_tracker_data = Class.new(ApplicationRecord) do
+ self.table_name = 'issue_tracker_data'
+
+ def self.encryption_options
+ {
+ key: Settings.attr_encrypted_db_key_base_32,
+ encode: true,
+ mode: :per_attribute_iv,
+ algorithm: 'aes-256-gcm'
+ }
+ end
+
+ attr_encrypted :project_url, encryption_options
+ attr_encrypted :issues_url, encryption_options
+ attr_encrypted :new_issue_url, encryption_options
end
- attr_encrypted :project_url, encryption_options
- attr_encrypted :issues_url, encryption_options
- attr_encrypted :new_issue_url, encryption_options
- end
+ jira_tracker_data = Class.new(ApplicationRecord) do
+ self.table_name = 'jira_tracker_data'
- class JiraTrackerData < ApplicationRecord
- self.table_name = 'jira_tracker_data'
+ def self.encryption_options
+ {
+ key: Settings.attr_encrypted_db_key_base_32,
+ encode: true,
+ mode: :per_attribute_iv,
+ algorithm: 'aes-256-gcm'
+ }
+ end
- def self.encryption_options
- {
- key: Settings.attr_encrypted_db_key_base_32,
- encode: true,
- mode: :per_attribute_iv,
- algorithm: 'aes-256-gcm'
- }
+ attr_encrypted :url, encryption_options
+ attr_encrypted :api_url, encryption_options
+ attr_encrypted :username, encryption_options
+ attr_encrypted :password, encryption_options
end
- attr_encrypted :url, encryption_options
- attr_encrypted :api_url, encryption_options
- attr_encrypted :username, encryption_options
- attr_encrypted :password, encryption_options
+ stub_const('IssueTrackerData', issue_tracker_data)
+ stub_const('JiraTrackerData', jira_tracker_data)
end
let(:url) { 'http://base-url.tracker.com' }
diff --git a/spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb b/spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb
index e98f9fe1b04..af6ec25b9d6 100644
--- a/spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb
+++ b/spec/lib/gitlab/ci/templates/auto_devops_gitlab_ci_yaml_spec.rb
@@ -20,23 +20,101 @@ describe 'Auto-DevOps.gitlab-ci.yml' do
allow(project).to receive(:default_branch).and_return(default_branch)
end
+ shared_examples 'no Kubernetes deployment job' do
+ it 'does not create any Kubernetes deployment-related builds' do
+ expect(build_names).not_to include('production')
+ expect(build_names).not_to include('production_manual')
+ expect(build_names).not_to include('staging')
+ expect(build_names).not_to include('canary')
+ expect(build_names).not_to include('review')
+ expect(build_names).not_to include(a_string_matching(/rollout \d+%/))
+ end
+ end
+
it 'creates a build and a test job' do
expect(build_names).to include('build', 'test')
end
+ context 'when the project is set for deployment to AWS' do
+ let(:platform_value) { 'ECS' }
+
+ before do
+ create(:ci_variable, project: project, key: 'AUTO_DEVOPS_PLATFORM_TARGET', value: platform_value)
+ end
+
+ shared_examples 'no ECS job when AUTO_DEVOPS_PLATFORM_TARGET is not present' do |job_name|
+ context 'when AUTO_DEVOPS_PLATFORM_TARGET is nil' do
+ let(:platform_value) { nil }
+
+ it 'does not trigger the job' do
+ expect(build_names).not_to include(job_name)
+ end
+ end
+
+ context 'when AUTO_DEVOPS_PLATFORM_TARGET is empty' do
+ let(:platform_value) { '' }
+
+ it 'does not trigger the job' do
+ expect(build_names).not_to include(job_name)
+ end
+ end
+ end
+
+ it_behaves_like 'no Kubernetes deployment job'
+
+ it_behaves_like 'no ECS job when AUTO_DEVOPS_PLATFORM_TARGET is not present' do
+ let(:job_name) { 'production_ecs' }
+ end
+
+ it 'creates an ECS deployment job for production only' do
+ expect(build_names).not_to include('review_ecs')
+ expect(build_names).to include('production_ecs')
+ end
+
+ context 'and we are not on the default branch' do
+ let(:platform_value) { 'ECS' }
+ let(:pipeline_branch) { 'patch-1' }
+
+ before do
+ project.repository.create_branch(pipeline_branch)
+ end
+
+ it_behaves_like 'no ECS job when AUTO_DEVOPS_PLATFORM_TARGET is not present' do
+ let(:job_name) { 'review_ecs' }
+ end
+
+ it 'creates an ECS deployment job for review only' do
+ expect(build_names).to include('review_ecs')
+ expect(build_names).not_to include('production_ecs')
+ expect(build_names).not_to include('review')
+ expect(build_names).not_to include('production')
+ end
+ end
+
+ context 'and when the project has an active cluster' do
+ let(:cluster) { create(:cluster, :project, :provided_by_gcp, projects: [project]) }
+
+ before do
+ allow(cluster).to receive(:active?).and_return(true)
+ end
+
+ context 'on default branch' do
+ it 'triggers the deployment to Kubernetes, not to ECS' do
+ expect(build_names).not_to include('review')
+ expect(build_names).to include('production')
+ expect(build_names).not_to include('production_ecs')
+ expect(build_names).not_to include('review_ecs')
+ end
+ end
+ end
+ end
+
context 'when the project has no active cluster' do
it 'only creates a build and a test stage' do
expect(pipeline.stages_names).to eq(%w(build test))
end
- it 'does not create any deployment-related builds' do
- expect(build_names).not_to include('production')
- expect(build_names).not_to include('production_manual')
- expect(build_names).not_to include('staging')
- expect(build_names).not_to include('canary')
- expect(build_names).not_to include('review')
- expect(build_names).not_to include(a_string_matching(/rollout \d+%/))
- end
+ it_behaves_like 'no Kubernetes deployment job'
end
context 'when the project has an active cluster' do
diff --git a/spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb b/spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb
index 94a85486cfa..d25860ab301 100644
--- a/spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb
+++ b/spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb
@@ -13,7 +13,7 @@ describe 'projects/settings/ci_cd/_autodevops_form' do
it 'shows a warning message about Kubernetes cluster' do
render
- expect(rendered).to have_text('You must add a Kubernetes cluster integration to this project with a domain in order for your deployment strategy to work correctly.')
+ expect(rendered).to have_text('Add a Kubernetes cluster integration with a domain or create an AUTO_DEVOPS_PLATFORM_TARGET CI variable')
end
context 'when the project has an available kubernetes cluster' do