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:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-12-13 09:07:20 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-13 09:07:20 +0300
commit99bb3eedd09ba55be5934da8138e2678a3e1be4d (patch)
treefa311712cbb8865319be191c5f31b78950e2a65f
parentb4558e74dac09cdce238caa99f89f5ff9863815c (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--app/assets/javascripts/webhooks/constants.js4
-rw-r--r--app/models/environment.rb6
-rw-r--r--config/feature_flags/development/list_refs_for_find_all_tags_branches.yml8
-rw-r--r--data/deprecations/14-5-runner-api-status-does-contain-paused.yml2
-rw-r--r--data/deprecations/14-8-ci-build-variables.yml2
-rw-r--r--data/deprecations/14-8-runner-api-active-field-replaced-with-paused-breaking-change.yml2
-rw-r--r--data/deprecations/14-8-runner-api-status-filter-does-accept-active-or-paused.yml2
-rw-r--r--data/deprecations/15-7-dast-api-variable-deprecation.yml2
-rw-r--r--db/post_migrate/20221205151917_schedule_backfill_environment_tier.rb21
-rw-r--r--db/schema_migrations/202212051519171
-rw-r--r--doc/update/deprecations.md10
-rw-r--r--doc/user/application_security/dast/authentication.md46
-rw-r--r--doc/user/project/settings/import_export.md4
-rw-r--r--lib/gitlab/background_migration/backfill_environment_tiers.rb40
-rw-r--r--lib/gitlab/git/repository.rb20
-rw-r--r--lib/gitlab/gitaly_client/ref_service.rb12
-rw-r--r--locale/gitlab.pot8
-rw-r--r--qa/qa/page/project/web_ide/edit.rb8
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb8
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/web_ide/add_new_directory_in_web_ide_spec.rb14
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/web_ide/create_first_file_in_web_ide_spec.rb8
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/web_ide/link_to_line_in_web_ide_spec.rb5
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/web_ide/open_fork_in_web_ide_spec.rb11
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/web_ide/open_web_ide_from_diff_tab_spec.rb9
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/web_ide/review_merge_request_spec.rb17
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/web_ide/server_hooks_custom_error_message_spec.rb10
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb9
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/web_ide/web_terminal_spec.rb4
-rw-r--r--spec/frontend/webhooks/components/__snapshots__/push_events_spec.js.snap4
-rw-r--r--spec/lib/gitlab/background_migration/backfill_environment_tiers_spec.rb119
-rw-r--r--spec/lib/gitlab/git/repository_spec.rb69
-rw-r--r--spec/lib/gitlab/gitaly_client/ref_service_spec.rb22
-rw-r--r--spec/migrations/20221205151917_schedule_backfill_environment_tier_spec.rb24
-rw-r--r--spec/services/deployments/update_environment_service_spec.rb2
34 files changed, 349 insertions, 184 deletions
diff --git a/app/assets/javascripts/webhooks/constants.js b/app/assets/javascripts/webhooks/constants.js
index 6710a418117..96632b47e6b 100644
--- a/app/assets/javascripts/webhooks/constants.js
+++ b/app/assets/javascripts/webhooks/constants.js
@@ -7,13 +7,13 @@ export const BRANCH_FILTER_REGEX = 'regex';
export const WILDCARD_CODE_STABLE = '*-stable';
export const WILDCARD_CODE_PRODUCTION = 'production/*';
-export const REGEX_CODE = '(feature|hotfix)/*';
+export const REGEX_CODE = '^(feature|hotfix)/';
export const descriptionText = {
[BRANCH_FILTER_WILDCARD]: s__(
'Webhooks|Wildcards such as %{WILDCARD_CODE_STABLE} or %{WILDCARD_CODE_PRODUCTION} are supported.',
),
- [BRANCH_FILTER_REGEX]: s__('Webhooks|Regex such as %{REGEX_CODE} is supported.'),
+ [BRANCH_FILTER_REGEX]: s__('Webhooks|Regular expressions such as %{REGEX_CODE} are supported.'),
};
export const MASK_ITEM_VALUE_HIDDEN = '************';
diff --git a/app/models/environment.rb b/app/models/environment.rb
index a5e958a0645..2fa0b7936a6 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -48,9 +48,9 @@ class Environment < ApplicationRecord
has_one :latest_opened_most_severe_alert, -> { order_severity_with_open_prometheus_alert }, class_name: 'AlertManagement::Alert', inverse_of: :environment
before_validation :generate_slug, if: ->(env) { env.slug.blank? }
+ before_validation :ensure_environment_tier
before_save :set_environment_type
- before_save :ensure_environment_tier
after_save :clear_reactive_cache!
validates :name,
@@ -71,6 +71,10 @@ class Environment < ApplicationRecord
length: { maximum: 255 },
allow_nil: true
+ # Currently, the tier presence is validaed for newly created environments.
+ # After the `BackfillEnvironmentTiers` background migration has been completed, we should remove `on: :create`.
+ # See https://gitlab.com/gitlab-org/gitlab/-/issues/385253.
+ validates :tier, presence: true, on: :create
validate :safe_external_url
validate :merge_request_not_changed
diff --git a/config/feature_flags/development/list_refs_for_find_all_tags_branches.yml b/config/feature_flags/development/list_refs_for_find_all_tags_branches.yml
deleted file mode 100644
index f4d9da9fb5c..00000000000
--- a/config/feature_flags/development/list_refs_for_find_all_tags_branches.yml
+++ /dev/null
@@ -1,8 +0,0 @@
----
-name: list_refs_for_find_all_tags_branches
-introduced_by_url: "https://gitlab.com/gitlab-org/gitlab/-/merge_requests/102002"
-rollout_issue_url: "https://gitlab.com/gitlab-org/gitlab/-/issues/383617"
-milestone: '15.7'
-type: development
-group: group::gitaly
-default_enabled: false
diff --git a/data/deprecations/14-5-runner-api-status-does-contain-paused.yml b/data/deprecations/14-5-runner-api-status-does-contain-paused.yml
index 75a0a7de666..9cf1294467a 100644
--- a/data/deprecations/14-5-runner-api-status-does-contain-paused.yml
+++ b/data/deprecations/14-5-runner-api-status-does-contain-paused.yml
@@ -2,7 +2,7 @@
announcement_milestone: "14.5" # The milestone when this feature was first announced as deprecated.
announcement_date: "2021-11-22"
removal_milestone: "16.0" # the milestone when this feature is planned to be removed
- removal_date: "2023-04-22" # the date of the milestone release when this feature is planned to be removed
+ removal_date: "2023-05-22" # the date of the milestone release when this feature is planned to be removed
breaking_change: true
body: | # Do not modify this line, instead modify the lines below.
The GitLab Runner GraphQL API endpoints will not return `paused` or `active` as a status in GitLab 16.0.
diff --git a/data/deprecations/14-8-ci-build-variables.yml b/data/deprecations/14-8-ci-build-variables.yml
index de531becdab..f12f6dda5a6 100644
--- a/data/deprecations/14-8-ci-build-variables.yml
+++ b/data/deprecations/14-8-ci-build-variables.yml
@@ -2,7 +2,7 @@
announcement_milestone: "14.8"
announcement_date: "2022-02-22"
removal_milestone: "16.0"
- removal_date: "2023-04-22"
+ removal_date: "2023-05-22"
breaking_change: true
reporter: dhershkovitch
body: |
diff --git a/data/deprecations/14-8-runner-api-active-field-replaced-with-paused-breaking-change.yml b/data/deprecations/14-8-runner-api-active-field-replaced-with-paused-breaking-change.yml
index 358192888ad..a8173a80047 100644
--- a/data/deprecations/14-8-runner-api-active-field-replaced-with-paused-breaking-change.yml
+++ b/data/deprecations/14-8-runner-api-active-field-replaced-with-paused-breaking-change.yml
@@ -2,7 +2,7 @@
announcement_milestone: "14.8"
announcement_date: "2022-02-22"
removal_milestone: "16.0"
- removal_date: "2023-04-22"
+ removal_date: "2023-05-22"
breaking_change: true
reporter: pedropombeiro
body: |
diff --git a/data/deprecations/14-8-runner-api-status-filter-does-accept-active-or-paused.yml b/data/deprecations/14-8-runner-api-status-filter-does-accept-active-or-paused.yml
index d652346a8fa..cf0476ae768 100644
--- a/data/deprecations/14-8-runner-api-status-filter-does-accept-active-or-paused.yml
+++ b/data/deprecations/14-8-runner-api-status-filter-does-accept-active-or-paused.yml
@@ -2,7 +2,7 @@
announcement_milestone: "14.8" # The milestone when this feature was first announced as deprecated.
announcement_date: "2022-02-22"
removal_milestone: "16.0"
- removal_date: "2023-04-22"
+ removal_date: "2023-05-22"
breaking_change: true
body: | # Do not modify this line, instead modify the lines below.
The GitLab Runner GraphQL endpoints will stop accepting `paused` or `active` as a status value in GitLab 16.0.
diff --git a/data/deprecations/15-7-dast-api-variable-deprecation.yml b/data/deprecations/15-7-dast-api-variable-deprecation.yml
index 6e037c79b92..724c24cf440 100644
--- a/data/deprecations/15-7-dast-api-variable-deprecation.yml
+++ b/data/deprecations/15-7-dast-api-variable-deprecation.yml
@@ -2,7 +2,7 @@
announcement_milestone: "15.7" # (required) The milestone when this feature was first announced as deprecated.
announcement_date: "2022-12-22" # (required) The date of the milestone release when this feature was first announced as deprecated. This should almost always be the 22nd of a month (YYYY-MM-22), unless you did an out of band blog post.
removal_milestone: "16.0" # (required) The milestone when this feature is planned to be removed
- removal_date: "2022-05-22" # (required) The date of the milestone release when this feature is planned to be removed. This should almost always be the 22nd of a month (YYYY-MM-22), unless you did an out of band blog post.
+ removal_date: "2023-05-22" # (required) The date of the milestone release when this feature is planned to be removed. This should almost always be the 22nd of a month (YYYY-MM-22), unless you did an out of band blog post.
breaking_change: true # (required) If this deprecation is a breaking change, set this value to true
reporter: derekferguson # (required) GitLab username of the person reporting the deprecation
stage: Secure # (required) String value of the stage that the feature was created in. e.g., Growth
diff --git a/db/post_migrate/20221205151917_schedule_backfill_environment_tier.rb b/db/post_migrate/20221205151917_schedule_backfill_environment_tier.rb
new file mode 100644
index 00000000000..eb62e50ea65
--- /dev/null
+++ b/db/post_migrate/20221205151917_schedule_backfill_environment_tier.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+class ScheduleBackfillEnvironmentTier < Gitlab::Database::Migration[2.0]
+ MIGRATION = 'BackfillEnvironmentTiers'
+ DELAY_INTERVAL = 2.minutes
+
+ restrict_gitlab_migration gitlab_schema: :gitlab_main
+
+ def up
+ queue_batched_background_migration(
+ MIGRATION,
+ :environments,
+ :id,
+ job_interval: DELAY_INTERVAL
+ )
+ end
+
+ def down
+ delete_batched_background_migration(MIGRATION, :environments, :id, [])
+ end
+end
diff --git a/db/schema_migrations/20221205151917 b/db/schema_migrations/20221205151917
new file mode 100644
index 00000000000..6ae6787c2a9
--- /dev/null
+++ b/db/schema_migrations/20221205151917
@@ -0,0 +1 @@
+64c4d48759a28b2dbac035d290724ee82b8af4af2bef75e1d7e07eefe10e6d17 \ No newline at end of file
diff --git a/doc/update/deprecations.md b/doc/update/deprecations.md
index f7b5c065138..7965e18e005 100644
--- a/doc/update/deprecations.md
+++ b/doc/update/deprecations.md
@@ -54,7 +54,7 @@ sole discretion of GitLab Inc.
### DAST API variables
-Planned removal: GitLab <span class="removal-milestone">16.0</span> (2022-05-22)
+Planned removal: GitLab <span class="removal-milestone">16.0</span> (2023-05-22)
WARNING:
This is a [breaking change](https://docs.gitlab.com/ee/development/deprecation_guidelines/).
@@ -1122,7 +1122,7 @@ To align with this change, API calls to list external status checks will also re
### GraphQL API Runner will not accept `status` filter values of `active` or `paused`
-Planned removal: GitLab <span class="removal-milestone">16.0</span> (2023-04-22)
+Planned removal: GitLab <span class="removal-milestone">16.0</span> (2023-05-22)
WARNING:
This is a [breaking change](https://docs.gitlab.com/ee/development/deprecation_guidelines/).
@@ -1302,7 +1302,7 @@ The `instanceStatisticsMeasurements` GraphQL node has been renamed to `usageTren
### REST and GraphQL API Runner usage of `active` replaced by `paused`
-Planned removal: GitLab <span class="removal-milestone">16.0</span> (2023-04-22)
+Planned removal: GitLab <span class="removal-milestone">16.0</span> (2023-05-22)
WARNING:
This is a [breaking change](https://docs.gitlab.com/ee/development/deprecation_guidelines/).
@@ -1627,7 +1627,7 @@ The new security approvals feature is similar to vulnerability check. For exampl
### `CI_BUILD_*` predefined variables
-Planned removal: GitLab <span class="removal-milestone">16.0</span> (2023-04-22)
+Planned removal: GitLab <span class="removal-milestone">16.0</span> (2023-05-22)
WARNING:
This is a [breaking change](https://docs.gitlab.com/ee/development/deprecation_guidelines/).
@@ -2091,7 +2091,7 @@ Administrators who need to add runners for multiple projects can register a runn
### GraphQL API Runner status will not return `paused`
-Planned removal: GitLab <span class="removal-milestone">16.0</span> (2023-04-22)
+Planned removal: GitLab <span class="removal-milestone">16.0</span> (2023-05-22)
WARNING:
This is a [breaking change](https://docs.gitlab.com/ee/development/deprecation_guidelines/).
diff --git a/doc/user/application_security/dast/authentication.md b/doc/user/application_security/dast/authentication.md
index 66fd9c13589..a240a496bab 100644
--- a/doc/user/application_security/dast/authentication.md
+++ b/doc/user/application_security/dast/authentication.md
@@ -51,22 +51,22 @@ To run a DAST authenticated scan:
### Available CI/CD variables
-| CI/CD variable | Type | Description |
-|:-----------------------------------------------|:--------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| `DAST_AUTH_COOKIES` | string | Set to a comma-separated list of cookie names to specify which cookies are used for authentication. |
-| `DAST_AUTH_REPORT` | boolean | Used in combination with exporting the `gl-dast-debug-auth-report.html` artifact to aid in debugging authentication issues. |
-| `DAST_AUTH_URL` <sup>1</sup> | URL | The URL of the page containing the sign-in HTML form on the target website. `DAST_USERNAME` and `DAST_PASSWORD` are submitted with the login form to create an authenticated scan. Example: `https://login.example.com`. |
-| `DAST_AUTH_VERIFICATION_LOGIN_FORM` | boolean | Verifies successful authentication by checking for the absence of a login form once the login form has been submitted. |
-| `DAST_AUTH_VERIFICATION_SELECTOR` | selector | Verifies successful authentication by checking for presence of a selector once the login form has been submitted. Example: `css:.user-photo`. |
-| `DAST_AUTH_VERIFICATION_URL` <sup>1</sup> | URL | Verifies successful authentication by checking the URL in the browser once the login form has been submitted. Example: `"https://example.com/loggedin_page"`. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/207335) in GitLab 13.8. |
-| `DAST_BROWSER_PATH_TO_LOGIN_FORM` <sup>1</sup> | selector | Comma-separated list of selectors that are selected prior to attempting to enter `DAST_USERNAME` and `DAST_PASSWORD` into the login form. Example: `"css:.navigation-menu,css:.login-menu-item"`. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/326633) in GitLab 14.1. |
-| `DAST_EXCLUDE_URLS` <sup>1</sup> | URLs | The URLs to skip during the authenticated scan; comma-separated. Regular expression syntax can be used to match multiple URLs. For example, `.*` matches an arbitrary character sequence. |
-| `DAST_FIRST_SUBMIT_FIELD` | string | The `id` or `name` of the element that when selected submits the username form of a multi-page login process. For example, `css:button[type='user-submit']`. [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/9894) in GitLab 12.4. |
-| `DAST_PASSWORD` <sup>1</sup> | string | The password to authenticate to in the website. Example: `P@55w0rd!` |
-| `DAST_PASSWORD_FIELD` | string | The selector of password field at the sign-in HTML form. Example: `id:password` |
-| `DAST_SUBMIT_FIELD` | string | The `id` or `name` of the element that when selected submits the login form or the password form of a multi-page login process. For example, `css:button[type='submit']`. [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/9894) in GitLab 12.4. |
-| `DAST_USERNAME` <sup>1</sup> | string | The username to authenticate to in the website. Example: `admin` |
-| `DAST_USERNAME_FIELD` <sup>1</sup> | string | The selector of username field at the sign-in HTML form. Example: `name:username` |
+| CI/CD variable | Type | Description |
+|:-----------------------------------------------|:------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| `DAST_AUTH_COOKIES` | string | Set to a comma-separated list of cookie names to specify which cookies are used for authentication. |
+| `DAST_AUTH_REPORT` | boolean | Used in combination with exporting the `gl-dast-debug-auth-report.html` artifact to aid in debugging authentication issues. |
+| `DAST_AUTH_URL` <sup>1</sup> | URL | The URL of the page containing the sign-in HTML form on the target website. `DAST_USERNAME` and `DAST_PASSWORD` are submitted with the login form to create an authenticated scan. Example: `https://login.example.com`. |
+| `DAST_AUTH_VERIFICATION_LOGIN_FORM` | boolean | Verifies successful authentication by checking for the absence of a login form once the login form has been submitted. |
+| `DAST_AUTH_VERIFICATION_SELECTOR` | [selector](#finding-an-elements-selector) | Verifies successful authentication by checking for presence of a selector once the login form has been submitted. Example: `css:.user-photo`. |
+| `DAST_AUTH_VERIFICATION_URL` <sup>1</sup> | URL | Verifies successful authentication by checking the URL in the browser once the login form has been submitted. Example: `"https://example.com/loggedin_page"`. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/207335) in GitLab 13.8. |
+| `DAST_BROWSER_PATH_TO_LOGIN_FORM` <sup>1</sup> | [selector](#finding-an-elements-selector) | Comma-separated list of selectors that are selected prior to attempting to enter `DAST_USERNAME` and `DAST_PASSWORD` into the login form. Example: `"css:.navigation-menu,css:.login-menu-item"`. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/326633) in GitLab 14.1. |
+| `DAST_EXCLUDE_URLS` <sup>1</sup> | URLs | The URLs to skip during the authenticated scan; comma-separated. Regular expression syntax can be used to match multiple URLs. For example, `.*` matches an arbitrary character sequence. |
+| `DAST_FIRST_SUBMIT_FIELD` | string | The `id` or `name` of the element that when selected submits the username form of a multi-page login process. For example, `css:button[type='user-submit']`. [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/9894) in GitLab 12.4. |
+| `DAST_PASSWORD` <sup>1</sup> | string | The password to authenticate to in the website. Example: `P@55w0rd!` |
+| `DAST_PASSWORD_FIELD` | string | The selector of password field at the sign-in HTML form. Example: `id:password` |
+| `DAST_SUBMIT_FIELD` | string | The `id` or `name` of the element that when selected submits the login form or the password form of a multi-page login process. For example, `css:button[type='submit']`. [Introduced](https://gitlab.com/gitlab-org/gitlab-ee/issues/9894) in GitLab 12.4. |
+| `DAST_USERNAME` <sup>1</sup> | string | The username to authenticate to in the website. Example: `admin` |
+| `DAST_USERNAME_FIELD` <sup>1</sup> | string | The selector of username field at the sign-in HTML form. Example: `name:username` |
1. Available to an on-demand proxy-based DAST scan.
@@ -188,13 +188,13 @@ dast:
Selectors are used by CI/CD variables to specify the location of an element displayed on a page in a browser.
Selectors have the format `type`:`search string`. DAST searches for the selector using the search string based on the type.
-| Selector type | Example | Description |
-| ------------- | ---------------------------------- | ----------- |
-| `css` | `css:.password-field` | Searches for a HTML element having the supplied CSS selector. Selectors should be as specific as possible for performance reasons. |
-| `id` | `id:element` | Searches for an HTML element with the provided element ID. |
-| `name` | `name:element` | Searches for an HTML element with the provided element name. |
-| `xpath` | `xpath://input[@id="my-button"]/a` | Searches for a HTML element with the provided XPath. Note that XPath searches are expected to be less performant than other searches. |
-| None provided | `a.click-me` | Defaults to searching using a CSS selector. |
+| Selector type | Example | Description |
+|---------------|------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| `css` | `css:.password-field` | Searches for a HTML element having the supplied CSS selector. Selectors should be as specific as possible for performance reasons. |
+| `id` | `id:element` | Searches for an HTML element with the provided element ID. |
+| `name` | `name:element` | Searches for an HTML element with the provided element name. |
+| `xpath` | `xpath://input[@id="my-button"]/a` | Searches for a HTML element with the provided XPath. Note that XPath searches are expected to be less performant than other searches. |
+| None provided | `a.click-me` | Defaults to searching using a CSS selector. **{warning}** **[Deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/383348)** in GitLab 15.8. Replaced by explicitly declaring the selector type. |
#### Find selectors with Google Chrome
diff --git a/doc/user/project/settings/import_export.md b/doc/user/project/settings/import_export.md
index 803a14e9903..02949813ce7 100644
--- a/doc/user/project/settings/import_export.md
+++ b/doc/user/project/settings/import_export.md
@@ -208,8 +208,8 @@ is NDJSON.
### 13.0+
Starting with GitLab 13.0, GitLab can import bundles that were exported from a different GitLab deployment.
-This ability is limited to two previous GitLab [minor](../../../policy/maintenance.md#versioning)
-releases, which is similar to our process for [Security Releases](../../../policy/maintenance.md#security-releases).
+**This ability is limited to two previous GitLab [minor](../../../policy/maintenance.md#versioning)
+releases**, which is similar to our process for [Security Releases](../../../policy/maintenance.md#security-releases).
For example:
diff --git a/lib/gitlab/background_migration/backfill_environment_tiers.rb b/lib/gitlab/background_migration/backfill_environment_tiers.rb
new file mode 100644
index 00000000000..6f381577274
--- /dev/null
+++ b/lib/gitlab/background_migration/backfill_environment_tiers.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module BackgroundMigration
+ # This class backfills the `environments.tier` column by using `guess_tier` logic.
+ # Environments created after 13.10 already have a value, however, environments created before 13.10 don't.
+ # See https://gitlab.com/gitlab-org/gitlab/-/issues/300741 for more information.
+ class BackfillEnvironmentTiers < BatchedMigrationJob
+ operation_name :backfill_environment_tiers
+
+ # Equivalent to `Environment#guess_tier` pattern matching.
+ PRODUCTION_TIER = 0
+ STAGING_TIER = 1
+ TESTING_TIER = 2
+ DEVELOPMENT_TIER = 3
+ OTHER_TIER = 4
+
+ TIER_REGEXP_PAIR = [
+ { tier: DEVELOPMENT_TIER, regexp: '(dev|review|trunk)' },
+ { tier: TESTING_TIER, regexp: '(test|tst|int|ac(ce|)pt|qa|qc|control|quality)' },
+ { tier: STAGING_TIER, regexp: '(st(a|)g|mod(e|)l|pre|demo|non)' },
+ { tier: PRODUCTION_TIER, regexp: '(pr(o|)d|live)' }
+ ].freeze
+
+ def perform
+ TIER_REGEXP_PAIR.each do |pair|
+ each_sub_batch(
+ batching_scope: ->(relation) { relation.where(tier: nil).where("name ~* '#{pair[:regexp]}'") } # rubocop:disable GitlabSecurity/SqlInjection
+ ) do |sub_batch|
+ sub_batch.update_all(tier: pair[:tier])
+ end
+ end
+
+ each_sub_batch(batching_scope: ->(relation) { relation.where(tier: nil) }) do |sub_batch|
+ sub_batch.update_all(tier: OTHER_TIER)
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index 7539452065b..bb4d9f78276 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -116,15 +116,9 @@ module Gitlab
# Returns an Array of branch names
# sorted by name ASC
def branch_names
- if Feature.enabled?(:list_refs_for_find_all_tags_branches, self)
- refs = list_refs([Gitlab::Git::BRANCH_REF_PREFIX])
+ refs = list_refs([Gitlab::Git::BRANCH_REF_PREFIX])
- refs.map { |ref| Gitlab::Git.branch_name(ref.name) }
- else
- wrapped_gitaly_errors do
- gitaly_ref_client.branch_names
- end
- end
+ refs.map { |ref| Gitlab::Git.branch_name(ref.name) }
end
# Returns an Array of Branches
@@ -215,15 +209,9 @@ module Gitlab
# Returns an Array of tag names
def tag_names
- if Feature.enabled?(:list_refs_for_find_all_tags_branches, self)
- refs = list_refs([Gitlab::Git::TAG_REF_PREFIX])
+ refs = list_refs([Gitlab::Git::TAG_REF_PREFIX])
- refs.map { |ref| Gitlab::Git.tag_name(ref.name) }
- else
- wrapped_gitaly_errors do
- gitaly_ref_client.tag_names
- end
- end
+ refs.map { |ref| Gitlab::Git.tag_name(ref.name) }
end
# Returns an Array of Tags
diff --git a/lib/gitlab/gitaly_client/ref_service.rb b/lib/gitlab/gitaly_client/ref_service.rb
index 4248ec4e3d0..da579276101 100644
--- a/lib/gitlab/gitaly_client/ref_service.rb
+++ b/lib/gitlab/gitaly_client/ref_service.rb
@@ -56,18 +56,6 @@ module Gitlab
Gitlab::Git.branch_name(response.name)
end
- def branch_names
- request = Gitaly::FindAllBranchNamesRequest.new(repository: @gitaly_repo)
- response = gitaly_client_call(@storage, :ref_service, :find_all_branch_names, request, timeout: GitalyClient.fast_timeout)
- consume_refs_response(response) { |name| Gitlab::Git.branch_name(name) }
- end
-
- def tag_names
- request = Gitaly::FindAllTagNamesRequest.new(repository: @gitaly_repo)
- response = gitaly_client_call(@storage, :ref_service, :find_all_tag_names, request, timeout: GitalyClient.fast_timeout)
- consume_refs_response(response) { |name| Gitlab::Git.tag_name(name) }
- end
-
def local_branches(sort_by: nil, pagination_params: nil)
request = Gitaly::FindLocalBranchesRequest.new(repository: @gitaly_repo, pagination_params: pagination_params)
request.sort_by = sort_local_branches_by_param(sort_by) if sort_by
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 51f59e4516e..fb20322327a 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -32743,10 +32743,10 @@ msgstr ""
msgid "ProjectSettings|Users can copy the repository to a new project."
msgstr ""
-msgid "ProjectSettings|Users can only push commits to this repository if the committer email is one of their own verified emails."
+msgid "ProjectSettings|Users can only push commits to this repository if the commit author name is consistent with their GitLab account name."
msgstr ""
-msgid "ProjectSettings|Users can only push commits to this repository if the committer name is consistent with their git config username."
+msgid "ProjectSettings|Users can only push commits to this repository if the committer email is one of their own verified emails."
msgstr ""
msgid "ProjectSettings|Users can request access"
@@ -46326,10 +46326,10 @@ msgstr ""
msgid "Webhooks|Pipeline events"
msgstr ""
-msgid "Webhooks|Regex such as %{REGEX_CODE} is supported."
+msgid "Webhooks|Regular expression"
msgstr ""
-msgid "Webhooks|Regular expression"
+msgid "Webhooks|Regular expressions such as %{REGEX_CODE} are supported."
msgstr ""
msgid "Webhooks|Releases events"
diff --git a/qa/qa/page/project/web_ide/edit.rb b/qa/qa/page/project/web_ide/edit.rb
index 293fcd1e676..975d3c8ea14 100644
--- a/qa/qa/page/project/web_ide/edit.rb
+++ b/qa/qa/page/project/web_ide/edit.rb
@@ -109,6 +109,14 @@ module QA
element :file_to_commit_content
end
+ # Used for stablility, due to feature_caching of vscode_web_ide
+ def wait_until_ide_loads
+ Support::Waiter.wait_until(sleep_interval: 2, max_duration: 60, reload_page: page,
+ retry_on_exception: true) do
+ has_element?(:commit_mode_tab)
+ end
+ end
+
def has_file?(file_name)
within_element(:file_list_container) do
has_element?(:file_name_content, file_name: file_name)
diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb
index 8ea65e17e13..93f804f1e39 100644
--- a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module QA
- RSpec.describe 'Create', product_group: :editor do
+ RSpec.describe 'Create', feature_flag: { name: 'vscode_web_ide', scope: :project }, product_group: :editor do
describe 'Web IDE file templates' do
include Runtime::Fixtures
@@ -11,6 +11,11 @@ module QA
project.description = 'Add file templates via the Web IDE'
project.initialize_with_readme = true
end
+ Runtime::Feature.disable(:vscode_web_ide, project: @project)
+ end
+
+ after(:all) do
+ Runtime::Feature.enable(:vscode_web_ide, project: @project)
end
templates = [
@@ -54,6 +59,7 @@ module QA
Page::Project::Show.perform(&:open_web_ide!)
Page::Project::WebIDE::Edit.perform do |ide|
+ ide.wait_until_ide_loads
ide.create_new_file_from_template template[:file_name], template[:name]
expect(ide.has_file?(template[:file_name])).to be_truthy
diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_new_directory_in_web_ide_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_new_directory_in_web_ide_spec.rb
index 1da9ed652fe..a001dee891a 100644
--- a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_new_directory_in_web_ide_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_new_directory_in_web_ide_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module QA
- RSpec.describe 'Create', product_group: :editor do
+ RSpec.describe 'Create', feature_flag: { name: 'vscode_web_ide', scope: :project }, product_group: :editor do
describe 'Add a directory in Web IDE' do
let(:project) do
Resource::Project.fabricate_via_api! do |project|
@@ -11,11 +11,15 @@ module QA
end
before do
+ Runtime::Feature.disable(:vscode_web_ide, project: project)
Flow::Login.sign_in
-
project.visit!
end
+ after do
+ Runtime::Feature.enable(:vscode_web_ide, project: project)
+ end
+
context 'when a directory with the same name already exists' do
let(:directory_name) { 'first_directory' }
@@ -38,6 +42,11 @@ module QA
it 'throws an error', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347733' do
Page::Project::WebIDE::Edit.perform do |ide|
+ # Support::Waiter.wait_until(sleep_interval: 2, max_duration: 60, reload_page: page,
+ # retry_on_exception: true) do
+ # expect(ide).to have_element(:commit_mode_tab)
+ # end
+ ide.wait_until_ide_loads
ide.add_directory(directory_name)
end
@@ -54,6 +63,7 @@ module QA
it 'shows in the tree view but cannot be committed', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347732' do
Page::Project::WebIDE::Edit.perform do |ide|
+ ide.wait_until_ide_loads
ide.add_directory(directory_name)
expect(ide).to have_file(directory_name)
diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/create_first_file_in_web_ide_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/create_first_file_in_web_ide_spec.rb
index 1dfda1608f4..cb0da601a88 100644
--- a/qa/qa/specs/features/browser_ui/3_create/web_ide/create_first_file_in_web_ide_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/create_first_file_in_web_ide_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module QA
- RSpec.describe 'Create', product_group: :editor do
+ RSpec.describe 'Create', feature_flag: { name: 'vscode_web_ide', scope: :project }, product_group: :editor do
describe 'First file using Web IDE' do
let(:project) do
Resource::Project.fabricate_via_api! do |project|
@@ -13,14 +13,20 @@ module QA
let(:file_name) { 'the very first file.txt' }
before do
+ Runtime::Feature.disable(:vscode_web_ide, project: project)
Flow::Login.sign_in
end
+ after do
+ Runtime::Feature.enable(:vscode_web_ide, project: project)
+ end
+
it "creates the first file in an empty project via Web IDE", testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347803' do
project.visit!
Page::Project::Show.perform(&:create_first_new_file!)
Page::Project::WebIDE::Edit.perform do |ide|
+ ide.wait_until_ide_loads
ide.create_first_file(file_name)
ide.commit_changes
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/link_to_line_in_web_ide_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/link_to_line_in_web_ide_spec.rb
index 56cf2a08bd9..2007fe4a667 100644
--- a/qa/qa/specs/features/browser_ui/3_create/web_ide/link_to_line_in_web_ide_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/link_to_line_in_web_ide_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module QA
- RSpec.describe 'Create', product_group: :editor do
+ RSpec.describe 'Create', feature_flag: { name: 'vscode_web_ide', scope: :project }, product_group: :editor do
describe 'Link to line in Web IDE' do
let(:user) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) }
let(:project) do
@@ -11,10 +11,12 @@ module QA
end
before do
+ Runtime::Feature.disable(:vscode_web_ide, project: project)
Flow::Login.sign_in
end
after do
+ Runtime::Feature.enable(:vscode_web_ide, project: project)
project.remove_via_api!
end
@@ -25,6 +27,7 @@ module QA
Page::Project::Show.perform(&:open_web_ide_via_shortcut)
Page::Project::WebIDE::Edit.perform do |ide|
+ ide.wait_until_ide_loads
ide.select_file('app.js')
@link = ide.link_line('26')
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/open_fork_in_web_ide_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/open_fork_in_web_ide_spec.rb
index 820b47a3175..dc9f68c5c73 100644
--- a/qa/qa/specs/features/browser_ui/3_create/web_ide/open_fork_in_web_ide_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/open_fork_in_web_ide_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module QA
- RSpec.describe 'Create', product_group: :editor do
+ RSpec.describe 'Create', feature_flag: { name: 'vscode_web_ide', scope: :project }, product_group: :editor do
describe 'Open a fork in Web IDE',
skip: {
issue: "https://gitlab.com/gitlab-org/gitlab/-/issues/351696",
@@ -14,6 +14,14 @@ module QA
end
end
+ before do
+ Runtime::Feature.disable(:vscode_web_ide, project: parent_project)
+ end
+
+ after do
+ Runtime::Feature.enable(:vscode_web_ide, project: parent_project)
+ end
+
context 'when a user does not have permissions to commit to the project' do
let(:user) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_2, Runtime::Env.gitlab_qa_password_2) }
@@ -57,6 +65,7 @@ module QA
def submit_merge_request_upstream
Page::Project::WebIDE::Edit.perform do |ide|
+ ide.wait_until_ide_loads
expect(ide).to have_project_path("#{user.username}/#{parent_project.name}")
ide.add_file('new file', 'some random text')
diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/open_web_ide_from_diff_tab_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/open_web_ide_from_diff_tab_spec.rb
index 685cd2d4ad6..039d25477bf 100644
--- a/qa/qa/specs/features/browser_ui/3_create/web_ide/open_web_ide_from_diff_tab_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/open_web_ide_from_diff_tab_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module QA
- RSpec.describe 'Create', product_group: :editor do
+ RSpec.describe 'Create', feature_flag: { name: 'vscode_web_ide', scope: :project }, product_group: :editor do
describe 'Open Web IDE from Diff Tab' do
files = [
{
@@ -44,11 +44,15 @@ module QA
end
before do
+ Runtime::Feature.disable(:vscode_web_ide, project: project)
Flow::Login.sign_in
-
merge_request.visit!
end
+ after do
+ Runtime::Feature.enable(:vscode_web_ide, project: project)
+ end
+
it 'opens and edits a multi-file merge request in Web IDE from Diff Tab', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347724' do
Page::MergeRequest::Show.perform do |show|
show.click_diffs_tab
@@ -56,6 +60,7 @@ module QA
end
Page::Project::WebIDE::Edit.perform do |ide|
+ ide.wait_until_ide_loads
files.each do |files|
expect(ide).to have_file(files[:file_path])
expect(ide).to have_file_content(files[:file_path], files[:content])
diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/review_merge_request_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/review_merge_request_spec.rb
index 69557fb359a..fe0060e9bbc 100644
--- a/qa/qa/specs/features/browser_ui/3_create/web_ide/review_merge_request_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/review_merge_request_spec.rb
@@ -1,31 +1,44 @@
# frozen_string_literal: true
module QA
- RSpec.describe 'Create', product_group: :editor do
+ RSpec.describe 'Create', feature_flag: { name: 'vscode_web_ide', scope: :project }, product_group: :editor do
describe 'Review a merge request in Web IDE' do
let(:new_file) { 'awesome_new_file.txt' }
let(:original_text) { 'Text' }
let(:review_text) { 'Reviewed ' }
+ let(:project) do
+ Resource::Project.fabricate_via_api! do |project|
+ project.name = 'review-merge-request-spec-project'
+ project.initialize_with_readme = true
+ end
+ end
+
let(:merge_request) do
Resource::MergeRequest.fabricate_via_api! do |mr|
mr.file_name = new_file
mr.file_content = original_text
+ mr.project = project
end
end
before do
+ Runtime::Feature.disable(:vscode_web_ide, project: project)
Flow::Login.sign_in
-
merge_request.visit!
end
+ after do
+ Runtime::Feature.enable(:vscode_web_ide, project: project)
+ end
+
it 'opens and edits a merge request in Web IDE', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347786' do
Page::MergeRequest::Show.perform do |show|
show.click_open_in_web_ide
end
Page::Project::WebIDE::Edit.perform do |ide|
+ ide.wait_until_ide_loads
ide.has_file?(new_file)
ide.add_to_modified_content(review_text)
ide.commit_changes
diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/server_hooks_custom_error_message_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/server_hooks_custom_error_message_spec.rb
index 0972e4f3e3d..3cd14ecd799 100644
--- a/qa/qa/specs/features/browser_ui/3_create/web_ide/server_hooks_custom_error_message_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/server_hooks_custom_error_message_spec.rb
@@ -1,7 +1,9 @@
# frozen_string_literal: true
module QA
- RSpec.describe 'Create', :skip_live_env, except: { job: 'review-qa-*' }, product_group: :editor do
+ RSpec.describe 'Create', :skip_live_env, except: { job: 'review-qa-*' },
+ feature_flag: { name: 'vscode_web_ide', scope: :project },
+ product_group: :editor do
describe 'Git Server Hooks' do
let(:file_path) { File.absolute_path(File.join('qa', 'fixtures', 'web_ide', 'README.md')) }
@@ -14,15 +16,21 @@ module QA
end
before do
+ Runtime::Feature.disable(:vscode_web_ide, project: project)
Flow::Login.sign_in
project.visit!
end
+ after do
+ Runtime::Feature.enable(:vscode_web_ide, project: project)
+ end
+
context 'Custom error messages' do
it 'renders preconfigured error message when user hook failed on commit in WebIDE',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/364751' do
Page::Project::Show.perform(&:open_web_ide_via_shortcut)
Page::Project::WebIDE::Edit.perform do |ide|
+ ide.wait_until_ide_loads
ide.upload_file(file_path)
ide.commit_changes(wait_for_success: false)
expect(ide).to have_text('Custom error message rejecting prereceive hook for projects with GL_PROJECT_PATH')
diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb
index c0f65416a1c..c6e283f67e0 100644
--- a/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/upload_new_file_in_web_ide_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module QA
- RSpec.describe 'Create', product_group: :editor do
+ RSpec.describe 'Create', feature_flag: { name: 'vscode_web_ide', scope: :project }, product_group: :editor do
describe 'Upload a file in Web IDE' do
let(:file_path) { File.absolute_path(File.join('qa', 'fixtures', 'web_ide', file_name)) }
@@ -13,17 +13,23 @@ module QA
end
before do
+ Runtime::Feature.disable(:vscode_web_ide, project: project)
Flow::Login.sign_in
project.visit!
Page::Project::Show.perform(&:open_web_ide!)
end
+ after do
+ Runtime::Feature.enable(:vscode_web_ide, project: project)
+ end
+
context 'when a file with the same name already exists' do
let(:file_name) { 'README.md' }
it 'throws an error', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347850' do
Page::Project::WebIDE::Edit.perform do |ide|
+ ide.wait_until_ide_loads
ide.upload_file(file_path)
end
@@ -36,6 +42,7 @@ module QA
it 'shows the Edit tab with the text', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347852' do
Page::Project::WebIDE::Edit.perform do |ide|
+ ide.wait_until_ide_loads
ide.upload_file(file_path)
expect(ide).to have_file(file_name)
diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/web_terminal_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/web_terminal_spec.rb
index f90676ee15a..695b295bd86 100644
--- a/qa/qa/specs/features/browser_ui/3_create/web_ide/web_terminal_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/web_terminal_spec.rb
@@ -10,10 +10,12 @@ module QA
issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/338179',
type: :bug
},
+ feature_flag: { name: 'vscode_web_ide', scope: :project },
product_group: :editor
) do
describe 'Web IDE web terminal' do
before do
+ Runtime::Feature.disable(:vscode_web_ide, project: project)
project = Resource::Project.fabricate_via_api! do |project|
project.name = 'web-terminal-project'
end
@@ -56,6 +58,7 @@ module QA
end
after do
+ Runtime::Feature.enable(:vscode_web_ide, project: project)
@runner.remove_via_api! if @runner
end
@@ -76,6 +79,7 @@ module QA
# There are also FE specs
# * spec/frontend/ide/components/terminal/terminal_controls_spec.js
Page::Project::WebIDE::Edit.perform do |edit|
+ edit.wait_until_ide_loads
edit.start_web_terminal
expect(edit).to have_no_alert
diff --git a/spec/frontend/webhooks/components/__snapshots__/push_events_spec.js.snap b/spec/frontend/webhooks/components/__snapshots__/push_events_spec.js.snap
index 3dbff024a6b..aec0f84cb82 100644
--- a/spec/frontend/webhooks/components/__snapshots__/push_events_spec.js.snap
+++ b/spec/frontend/webhooks/components/__snapshots__/push_events_spec.js.snap
@@ -141,7 +141,7 @@ exports[`Webhook push events form editor component Different push events rules w
class="form-text text-muted custom-control"
>
<gl-sprintf-stub
- message="Regex such as %{REGEX_CODE} is supported."
+ message="Regular expressions such as %{REGEX_CODE} are supported."
/>
</p>
</gl-form-radio-group-stub>
@@ -367,7 +367,7 @@ exports[`Webhook push events form editor component Different push events rules w
class="form-text text-muted custom-control"
>
<gl-sprintf-stub
- message="Regex such as %{REGEX_CODE} is supported."
+ message="Regular expressions such as %{REGEX_CODE} are supported."
/>
</p>
</gl-form-radio-group-stub>
diff --git a/spec/lib/gitlab/background_migration/backfill_environment_tiers_spec.rb b/spec/lib/gitlab/background_migration/backfill_environment_tiers_spec.rb
new file mode 100644
index 00000000000..788ed40b61e
--- /dev/null
+++ b/spec/lib/gitlab/background_migration/backfill_environment_tiers_spec.rb
@@ -0,0 +1,119 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Gitlab::BackgroundMigration::BackfillEnvironmentTiers,
+ :migration, schema: 20221205151917, feature_category: :continuous_delivery do
+ let!(:namespace) { table(:namespaces).create!(name: 'user', path: 'user') }
+ let!(:project) { table(:projects).create!(namespace_id: namespace.id, project_namespace_id: namespace.id) }
+
+ let(:migration) do
+ described_class.new(start_id: 1, end_id: 1000,
+ batch_table: :environments, batch_column: :id,
+ sub_batch_size: 10, pause_ms: 0,
+ connection: ApplicationRecord.connection)
+ end
+
+ describe '#perform' do
+ let!(:production) { table(:environments).create!(name: 'production', slug: 'production', project_id: project.id) }
+ let!(:staging) { table(:environments).create!(name: 'staging', slug: 'staging', project_id: project.id) }
+ let!(:testing) { table(:environments).create!(name: 'testing', slug: 'testing', project_id: project.id) }
+
+ let!(:development) do
+ table(:environments).create!(name: 'development', slug: 'development', project_id: project.id)
+ end
+
+ let!(:other) { table(:environments).create!(name: 'other', slug: 'other', project_id: project.id) }
+
+ it 'backfill tiers for all environments in range' do
+ expect(production.tier).to be_nil
+ expect(staging.tier).to be_nil
+ expect(testing.tier).to be_nil
+ expect(development.tier).to be_nil
+ expect(other.tier).to be_nil
+
+ migration.perform
+
+ expect(production.reload.tier).to eq(described_class::PRODUCTION_TIER)
+ expect(staging.reload.tier).to eq(described_class::STAGING_TIER)
+ expect(testing.reload.tier).to eq(described_class::TESTING_TIER)
+ expect(development.reload.tier).to eq(described_class::DEVELOPMENT_TIER)
+ expect(other.reload.tier).to eq(described_class::OTHER_TIER)
+ end
+ end
+
+ # Equivalent to spec/models/environment_spec.rb#guess_tier
+ describe 'same behavior with guess tier' do
+ using RSpec::Parameterized::TableSyntax
+
+ let(:environment) { table(:environments).create!(name: name, slug: name, project_id: project.id) }
+
+ where(:name, :tier) do
+ 'review/feature' | described_class::DEVELOPMENT_TIER
+ 'review/product' | described_class::DEVELOPMENT_TIER
+ 'DEV' | described_class::DEVELOPMENT_TIER
+ 'development' | described_class::DEVELOPMENT_TIER
+ 'trunk' | described_class::DEVELOPMENT_TIER
+ 'dev' | described_class::DEVELOPMENT_TIER
+ 'review/app' | described_class::DEVELOPMENT_TIER
+ 'PRODUCTION' | described_class::PRODUCTION_TIER
+ 'prod' | described_class::PRODUCTION_TIER
+ 'prod-east-2' | described_class::PRODUCTION_TIER
+ 'us-prod-east' | described_class::PRODUCTION_TIER
+ 'fe-production' | described_class::PRODUCTION_TIER
+ 'test' | described_class::TESTING_TIER
+ 'TEST' | described_class::TESTING_TIER
+ 'testing' | described_class::TESTING_TIER
+ 'testing-prd' | described_class::TESTING_TIER
+ 'acceptance-testing' | described_class::TESTING_TIER
+ 'production-test' | described_class::TESTING_TIER
+ 'test-production' | described_class::TESTING_TIER
+ 'QC' | described_class::TESTING_TIER
+ 'qa-env-2' | described_class::TESTING_TIER
+ 'gstg' | described_class::STAGING_TIER
+ 'staging' | described_class::STAGING_TIER
+ 'stage' | described_class::STAGING_TIER
+ 'Model' | described_class::STAGING_TIER
+ 'MODL' | described_class::STAGING_TIER
+ 'Pre-production' | described_class::STAGING_TIER
+ 'pre' | described_class::STAGING_TIER
+ 'Demo' | described_class::STAGING_TIER
+ 'staging' | described_class::STAGING_TIER
+ 'pre-prod' | described_class::STAGING_TIER
+ 'blue-kit-stage' | described_class::STAGING_TIER
+ 'nonprod' | described_class::STAGING_TIER
+ 'nonlive' | described_class::STAGING_TIER
+ 'non-prod' | described_class::STAGING_TIER
+ 'non-live' | described_class::STAGING_TIER
+ 'gprd' | described_class::PRODUCTION_TIER
+ 'gprd-cny' | described_class::PRODUCTION_TIER
+ 'production' | described_class::PRODUCTION_TIER
+ 'Production' | described_class::PRODUCTION_TIER
+ 'PRODUCTION' | described_class::PRODUCTION_TIER
+ 'Production/eu' | described_class::PRODUCTION_TIER
+ 'production/eu' | described_class::PRODUCTION_TIER
+ 'PRODUCTION/EU' | described_class::PRODUCTION_TIER
+ 'productioneu' | described_class::PRODUCTION_TIER
+ 'store-produce' | described_class::PRODUCTION_TIER
+ 'unproductive' | described_class::PRODUCTION_TIER
+ 'production/www.gitlab.com' | described_class::PRODUCTION_TIER
+ 'prod' | described_class::PRODUCTION_TIER
+ 'PROD' | described_class::PRODUCTION_TIER
+ 'Live' | described_class::PRODUCTION_TIER
+ 'canary' | described_class::OTHER_TIER
+ 'other' | described_class::OTHER_TIER
+ 'EXP' | described_class::OTHER_TIER
+ 'something-else' | described_class::OTHER_TIER
+ end
+
+ with_them do
+ it 'backfill tiers for all environments in range' do
+ expect(environment.tier).to be_nil
+
+ migration.perform
+
+ expect(environment.reload.tier).to eq(tier)
+ end
+ end
+ end
+end
diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb
index 80c3c33939b..39c2c61980b 100644
--- a/spec/lib/gitlab/git/repository_spec.rb
+++ b/spec/lib/gitlab/git/repository_spec.rb
@@ -71,25 +71,6 @@ RSpec.describe Gitlab::Git::Repository do
it { is_expected.not_to include("branch-from-space") }
it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::RefService, :list_refs
-
- context 'feature list_refs_for_find_all_tags_branches disabled' do
- before do
- stub_feature_flags(list_refs_for_find_all_tags_branches: false)
- end
-
- it 'has TestRepo::BRANCH_SHA.size elements' do
- expect(subject.size).to eq(TestEnv::BRANCH_SHA.size)
- end
-
- it 'returns UTF-8' do
- expect(subject.first).to be_utf8
- end
-
- it { is_expected.to include("master") }
- it { is_expected.not_to include("branch-from-space") }
-
- it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::RefService, :branch_names
- end
end
describe '#tag_names' do
@@ -115,33 +96,6 @@ RSpec.describe Gitlab::Git::Repository do
it { is_expected.not_to include("v5.0.0") }
it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::RefService, :list_refs
-
- context 'feature list_refs_for_find_all_tags_branches disabled' do
- before do
- stub_feature_flags(list_refs_for_find_all_tags_branches: false)
- end
-
- it { is_expected.to be_kind_of Array }
-
- it 'has some elements' do
- expect(subject.size).to be >= 1
- end
-
- it 'returns UTF-8' do
- expect(subject.first).to be_utf8
- end
-
- describe '#last' do
- subject { super().last }
-
- it { is_expected.to eq("v1.1.1") }
- end
-
- it { is_expected.to include("v1.0.0") }
- it { is_expected.not_to include("v5.0.0") }
-
- it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::RefService, :tag_names
- end
end
describe '#tags' do
@@ -1476,29 +1430,6 @@ RSpec.describe Gitlab::Git::Repository do
expect(repository.branch_count).to eq(repository.local_branches.count)
end
end
-
- context 'feature list_refs_for_find_all_tags_branches disabled' do
- before do
- stub_feature_flags(list_refs_for_find_all_tags_branches: false)
- end
-
- it 'returns the number of branches' do
- expect(repository.branch_count).to eq(TestEnv::BRANCH_SHA.size)
- end
-
- context 'with local and remote branches' do
- let(:repository) { mutable_repository }
-
- before do
- create_remote_branch('joe', 'remote_branch', 'master')
- repository.create_branch('local_branch')
- end
-
- it 'returns the count of local branches' do
- expect(repository.branch_count).to eq(repository.local_branches.count)
- end
- end
- end
end
describe '#merged_branch_names' do
diff --git a/spec/lib/gitlab/gitaly_client/ref_service_spec.rb b/spec/lib/gitlab/gitaly_client/ref_service_spec.rb
index b413c47e033..ae2e343377d 100644
--- a/spec/lib/gitlab/gitaly_client/ref_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/ref_service_spec.rb
@@ -71,28 +71,6 @@ RSpec.describe Gitlab::GitalyClient::RefService do
end
end
- describe '#branch_names' do
- it 'sends a find_all_branch_names message' do
- expect_any_instance_of(Gitaly::RefService::Stub)
- .to receive(:find_all_branch_names)
- .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
- .and_return([])
-
- client.branch_names
- end
- end
-
- describe '#tag_names' do
- it 'sends a find_all_tag_names message' do
- expect_any_instance_of(Gitaly::RefService::Stub)
- .to receive(:find_all_tag_names)
- .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
- .and_return([])
-
- client.tag_names
- end
- end
-
describe '#find_branch' do
it 'sends a find_branch message' do
expect_any_instance_of(Gitaly::RefService::Stub)
diff --git a/spec/migrations/20221205151917_schedule_backfill_environment_tier_spec.rb b/spec/migrations/20221205151917_schedule_backfill_environment_tier_spec.rb
new file mode 100644
index 00000000000..b76f889d743
--- /dev/null
+++ b/spec/migrations/20221205151917_schedule_backfill_environment_tier_spec.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require_migration!
+
+RSpec.describe ScheduleBackfillEnvironmentTier, category: :continuous_delivery do
+ let!(:batched_migration) { described_class::MIGRATION }
+
+ it 'schedules a new batched migration' do
+ reversible_migration do |migration|
+ migration.before -> {
+ expect(batched_migration).not_to have_scheduled_batched_migration
+ }
+
+ migration.after -> {
+ expect(batched_migration).to have_scheduled_batched_migration(
+ table_name: :environments,
+ column_name: :id,
+ interval: described_class::DELAY_INTERVAL
+ )
+ }
+ end
+ end
+end
diff --git a/spec/services/deployments/update_environment_service_spec.rb b/spec/services/deployments/update_environment_service_spec.rb
index c952bcddd9a..31a3abda8c7 100644
--- a/spec/services/deployments/update_environment_service_spec.rb
+++ b/spec/services/deployments/update_environment_service_spec.rb
@@ -115,7 +115,7 @@ RSpec.describe Deployments::UpdateEnvironmentService do
let(:external_url) { 'javascript:alert("hello")' }
it 'fails to update the tier due to validation error' do
- expect { subject.execute }.not_to change { environment.tier }
+ expect { subject.execute }.not_to change { environment.reload.tier }
end
it 'tracks an exception' do