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>2023-10-04 12:11:44 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-10-04 12:11:44 +0300
commitb68afda3299d372ef0b3745e0603a9d51369650b (patch)
tree4eeb684ff6f0aca066333aae1292a3f5f3823923
parentb5029334981dea8dbda5ac0b69722adcc8490035 (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--.gitlab/ci/rails.gitlab-ci.yml4
-rw-r--r--.rubocop_todo/lint/unused_block_argument.yml1
-rw-r--r--.rubocop_todo/style/string_concatenation.yml1
-rw-r--r--app/assets/javascripts/repository/components/blob_controls.vue6
-rw-r--r--app/assets/javascripts/repository/index.js11
-rw-r--r--app/assets/javascripts/repository/queries/blob_controls.query.graphql4
-rw-r--r--app/controllers/projects/blame_controller.rb1
-rw-r--r--app/helpers/access_tokens_helper.rb9
-rw-r--r--app/helpers/commits_helper.rb5
-rw-r--r--app/mailers/emails/profile.rb4
-rw-r--r--app/mailers/previews/notify_preview.rb8
-rw-r--r--app/models/integrations/chat_message/alert_message.rb4
-rw-r--r--app/models/integrations/chat_message/deployment_message.rb24
-rw-r--r--app/models/integrations/chat_message/issue_message.rb6
-rw-r--r--app/models/integrations/chat_message/pipeline_message.rb18
-rw-r--r--app/models/integrations/chat_message/push_message.rb8
-rw-r--r--app/models/integrations/discord.rb29
-rw-r--r--app/presenters/blob_presenter.rb4
-rw-r--r--app/views/groups/settings/access_tokens/index.html.haml1
-rw-r--r--app/views/projects/blob/_breadcrumb.html.haml6
-rw-r--r--config/initializers/doorkeeper.rb2
-rw-r--r--config/locales/doorkeeper.en.yml35
-rw-r--r--doc/development/testing_guide/end_to_end/resources.md9
-rw-r--r--doc/user/group/saml_sso/index.md2
-rw-r--r--qa/qa/factories/commits.rb8
-rw-r--r--qa/qa/resource/repository/commit.rb5
-rw-r--r--qa/qa/specs/features/api/12_systems/gitaly/automatic_failover_and_recovery_spec.rb15
-rw-r--r--qa/qa/specs/features/api/12_systems/gitaly/changing_repository_storage_spec.rb10
-rw-r--r--qa/qa/specs/features/api/12_systems/gitaly/gitaly_mtls_spec.rb13
-rw-r--r--qa/qa/specs/features/api/1_manage/group_access_token_spec.rb16
-rw-r--r--qa/qa/specs/features/api/1_manage/migration/gitlab_migration_pipeline_spec.rb29
-rw-r--r--qa/qa/specs/features/api/1_manage/project_access_token_spec.rb32
-rw-r--r--qa/qa/specs/features/api/3_create/merge_request/push_options_mwps_spec.rb58
-rw-r--r--qa/qa/specs/features/api/3_create/repository/commit_to_templated_project_spec.rb23
-rw-r--r--qa/qa/specs/features/api/3_create/repository/project_archive_compare_spec.rb9
-rw-r--r--qa/qa/specs/features/api/4_verify/file_variable_downstream_pipeline_spec.rb9
-rw-r--r--qa/qa/specs/features/api/4_verify/file_variable_spec.rb61
-rw-r--r--qa/qa/specs/features/api/5_package/container_registry/saas/container_registry_spec.rb12
-rw-r--r--qa/qa/specs/features/api/9_data_stores/user_inherited_access_spec.rb32
-rw-r--r--qa/qa/specs/features/browser_ui/1_manage/integrations/pipeline_status_emails_spec.rb15
-rw-r--r--qa/qa/specs/features/browser_ui/1_manage/user/user_access_termination_spec.rb17
-rw-r--r--qa/qa/specs/features/browser_ui/2_plan/issue/custom_issue_template_spec.rb14
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/merge_request/cherry_pick/cherry_pick_commit_spec.rb14
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_from_push_notification_spec.rb14
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_via_template_spec.rb18
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/merge_request/merge_when_pipeline_succeeds_spec.rb31
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/merge_request/rebase_merge_request_spec.rb7
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/merge_request/revert/revert_commit_spec.rb8
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/add_new_branch_rule_spec.rb13
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/branch_with_unusual_name_spec.rb14
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/license_detection_spec.rb7
-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_old/open_web_ide_from_diff_tab_spec.rb27
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_parent_child_pipelines_spec.rb28
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_pipelines_spec.rb24
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/ci_variable/custom_variable_spec.rb37
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/ci_variable/pipeline_with_protected_variable_spec.rb50
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/ci_variable/prefill_variables_spec.rb55
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/ci_variable/raw_variables_defined_in_yaml_spec.rb87
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/pipeline/include_local_config_file_paths_with_wildcard_spec.rb12
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/pipeline/include_multiple_files_from_multiple_projects_spec.rb23
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/pipeline/merge_mr_when_pipline_is_blocked_spec.rb47
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_independent_relationship_spec.rb17
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/pipeline/pass_dotenv_variables_to_downstream_via_bridge_spec.rb8
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/pipeline/pipeline_with_image_pull_policy_spec.rb39
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/pipeline/run_pipeline_via_web_only_spec.rb34
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/pipeline/run_pipeline_with_manual_jobs_spec.rb79
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/pipeline/trigger_child_pipeline_with_manual_spec.rb15
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/pipeline/trigger_matrix_spec.rb13
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/pipeline/update_ci_file_with_pipeline_editor_spec.rb23
-rw-r--r--qa/qa/specs/features/browser_ui/5_package/container_registry/saas/container_registry_spec.rb11
-rw-r--r--qa/qa/specs/features/browser_ui/5_package/container_registry/self_managed/container_registry_spec.rb114
-rw-r--r--qa/qa/specs/features/browser_ui/5_package/dependency_proxy/dependency_proxy_spec.rb50
-rw-r--r--qa/qa/specs/features/browser_ui/5_package/infrastructure_registry/terraform_module_registry_spec.rb21
-rw-r--r--qa/qa/specs/features/browser_ui/5_package/package_registry/composer_registry_spec.rb21
-rw-r--r--qa/qa/specs/features/browser_ui/5_package/package_registry/conan_repository_spec.rb13
-rw-r--r--qa/qa/specs/features/browser_ui/5_package/package_registry/generic_repository_spec.rb21
-rwxr-xr-xscripts/changed-feature-flags114
-rwxr-xr-xscripts/feature_flags/used-feature-flags (renamed from scripts/used-feature-flags)59
-rw-r--r--spec/features/projects/blobs/blob_line_permalink_updater_spec.rb48
-rw-r--r--spec/frontend/ci/runner/admin_runners/admin_runners_app_spec.js4
-rw-r--r--spec/helpers/access_tokens_helper_spec.rb1
-rw-r--r--spec/models/integrations/chat_message/alert_message_spec.rb6
-rw-r--r--spec/models/integrations/chat_message/deployment_message_spec.rb65
-rw-r--r--spec/models/integrations/chat_message/issue_message_spec.rb6
-rw-r--r--spec/models/integrations/chat_message/pipeline_message_spec.rb27
-rw-r--r--spec/models/integrations/chat_message/push_message_spec.rb6
-rw-r--r--spec/models/integrations/discord_spec.rb2
-rw-r--r--spec/presenters/blob_presenter_spec.rb50
-rw-r--r--spec/requests/oauth/tokens_controller_spec.rb15
-rw-r--r--spec/scripts/changed-feature-flags_spec.rb168
91 files changed, 938 insertions, 1222 deletions
diff --git a/.gitlab/ci/rails.gitlab-ci.yml b/.gitlab/ci/rails.gitlab-ci.yml
index 419c659e745..bbe631b2a4a 100644
--- a/.gitlab/ci/rails.gitlab-ci.yml
+++ b/.gitlab/ci/rails.gitlab-ci.yml
@@ -524,9 +524,9 @@ rspec:feature-flags:
- source scripts/utils.sh
script:
- if [ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]; then
- run_timed_command "scripts/used-feature-flags" || (scripts/slack master-broken "☠️ \`${CI_JOB_NAME}\` failed! ☠️ See ${CI_JOB_URL}" ci_failing "GitLab Bot" && exit 1);
+ run_timed_command "scripts/feature_flags/used-feature-flags" || (scripts/slack master-broken "☠️ \`${CI_JOB_NAME}\` failed! ☠️ See ${CI_JOB_URL}" ci_failing "GitLab Bot" && exit 1);
else
- run_timed_command "scripts/used-feature-flags";
+ run_timed_command "scripts/feature_flags/used-feature-flags";
fi
rspec:flaky-tests-report:
diff --git a/.rubocop_todo/lint/unused_block_argument.yml b/.rubocop_todo/lint/unused_block_argument.yml
index 2cf77e80405..5f78bf30811 100644
--- a/.rubocop_todo/lint/unused_block_argument.yml
+++ b/.rubocop_todo/lint/unused_block_argument.yml
@@ -281,7 +281,6 @@ Lint/UnusedBlockArgument:
- 'scripts/perf/gc/collect_gc_stats.rb'
- 'scripts/qa/testcases-check'
- 'scripts/review_apps/automated_cleanup.rb'
- - 'scripts/used-feature-flags'
- 'sidekiq_cluster/cli.rb'
- 'spec/components/pajamas/button_component_spec.rb'
- 'spec/components/previews/pajamas/banner_component_preview.rb'
diff --git a/.rubocop_todo/style/string_concatenation.yml b/.rubocop_todo/style/string_concatenation.yml
index ba88524e16d..d899ff9d98f 100644
--- a/.rubocop_todo/style/string_concatenation.yml
+++ b/.rubocop_todo/style/string_concatenation.yml
@@ -141,7 +141,6 @@ Style/StringConcatenation:
- 'qa/qa/tools/generate_perf_testdata.rb'
- 'scripts/perf/gc/print_gc_stats.rb'
- 'scripts/perf/query_limiting_report.rb'
- - 'scripts/used-feature-flags'
- 'spec/config/settings_spec.rb'
- 'spec/controllers/concerns/redirects_for_missing_path_on_tree_spec.rb'
- 'spec/controllers/groups/uploads_controller_spec.rb'
diff --git a/app/assets/javascripts/repository/components/blob_controls.vue b/app/assets/javascripts/repository/components/blob_controls.vue
index 460db0fe2ae..4730c9575da 100644
--- a/app/assets/javascripts/repository/components/blob_controls.vue
+++ b/app/assets/javascripts/repository/components/blob_controls.vue
@@ -30,6 +30,7 @@ export default {
projectPath: this.projectPath,
filePath: this.filePath,
ref: this.ref,
+ refType: this.refType?.toUpperCase(),
};
},
skip() {
@@ -45,6 +46,11 @@ export default {
type: String,
required: true,
},
+ refType: {
+ type: String,
+ required: false,
+ default: null,
+ },
},
data() {
return {
diff --git a/app/assets/javascripts/repository/index.js b/app/assets/javascripts/repository/index.js
index aea7a92e7c2..afe3f7b1983 100644
--- a/app/assets/javascripts/repository/index.js
+++ b/app/assets/javascripts/repository/index.js
@@ -137,6 +137,7 @@ export default function setupVueRepositoryList() {
return h(BlobControls, {
props: {
projectPath,
+ refType: this.$route.meta.refType || this.$route.query.ref_type,
},
});
},
@@ -231,19 +232,21 @@ export default function setupVueRepositoryList() {
const treeHistoryLinkEl = document.getElementById('js-tree-history-link');
const { historyLink } = treeHistoryLinkEl.dataset;
-
// eslint-disable-next-line no-new
new Vue({
el: treeHistoryLinkEl,
router,
render(h) {
+ const url = new URL(window.location.href);
+ url.pathname = `${historyLink}/${
+ this.$route.params.path ? escapeFileUrl(this.$route.params.path) : ''
+ }`;
+ url.searchParams.set('ref_type', this.$route.meta.refType || this.$route.query.ref_type);
return h(
GlButton,
{
attrs: {
- href: `${historyLink}/${
- this.$route.params.path ? escapeFileUrl(this.$route.params.path) : ''
- }`,
+ href: url.href,
// Ideally passing this class to `props` should work
// But it doesn't work here. :(
class: 'btn btn-default btn-md gl-button',
diff --git a/app/assets/javascripts/repository/queries/blob_controls.query.graphql b/app/assets/javascripts/repository/queries/blob_controls.query.graphql
index fc1cf5f254b..0c284dcc8e6 100644
--- a/app/assets/javascripts/repository/queries/blob_controls.query.graphql
+++ b/app/assets/javascripts/repository/queries/blob_controls.query.graphql
@@ -1,8 +1,8 @@
-query getBlobControls($projectPath: ID!, $filePath: String!, $ref: String!) {
+query getBlobControls($projectPath: ID!, $filePath: String!, $ref: String!, $refType: RefType) {
project(fullPath: $projectPath) {
id
repository {
- blobs(paths: [$filePath], ref: $ref) {
+ blobs(paths: [$filePath], ref: $ref, refType: $refType) {
nodes {
id
findFilePath
diff --git a/app/controllers/projects/blame_controller.rb b/app/controllers/projects/blame_controller.rb
index f621adbebc7..b37962b850f 100644
--- a/app/controllers/projects/blame_controller.rb
+++ b/app/controllers/projects/blame_controller.rb
@@ -15,6 +15,7 @@ class Projects::BlameController < Projects::ApplicationController
urgency :low, [:show]
def show
+ @ref_type = ref_type
load_environment
load_blame
end
diff --git a/app/helpers/access_tokens_helper.rb b/app/helpers/access_tokens_helper.rb
index 44200e84afb..4bb6ae29151 100644
--- a/app/helpers/access_tokens_helper.rb
+++ b/app/helpers/access_tokens_helper.rb
@@ -5,7 +5,14 @@ module AccessTokensHelper
include ApplicationHelper
def scope_description(prefix)
- prefix == :project_access_token ? [:doorkeeper, :project_access_token_scope_desc] : [:doorkeeper, :scope_desc]
+ case prefix
+ when :project_access_token
+ [:doorkeeper, :project_access_token_scope_desc]
+ when :group_access_token
+ [:doorkeeper, :group_access_token_scope_desc]
+ else
+ [:doorkeeper, :scope_desc]
+ end
end
def tokens_app_data
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb
index 42871dcc56f..6ffef1b612b 100644
--- a/app/helpers/commits_helper.rb
+++ b/app/helpers/commits_helper.rb
@@ -42,7 +42,7 @@ module CommitsHelper
crumbs = content_tag(:li, class: 'breadcrumb-item') do
link_to(
@project.path,
- project_commits_path(@project, @ref)
+ project_commits_path(@project, @ref, ref_type: @ref_type)
)
end
@@ -56,7 +56,8 @@ module CommitsHelper
part,
project_commits_path(
@project,
- tree_join(@ref, parts[0..i].join('/'))
+ tree_join(@ref, parts[0..i].join('/')),
+ ref_type: @ref_type
)
)
end
diff --git a/app/mailers/emails/profile.rb b/app/mailers/emails/profile.rb
index 37957e67dd0..ef91f6cac86 100644
--- a/app/mailers/emails/profile.rb
+++ b/app/mailers/emails/profile.rb
@@ -102,7 +102,7 @@ module Emails
@target_url = profile_personal_access_tokens_url
@days_to_expire = PersonalAccessToken::DAYS_TO_EXPIRE
- mail_with_locale(to: @user.notification_email_or_default, subject: subject(_("Your personal access tokens will expire in %{days_to_expire} days or less") % { days_to_expire: @days_to_expire }))
+ email_with_layout(to: @user.notification_email_or_default, subject: subject(_("Your personal access tokens will expire in %{days_to_expire} days or less") % { days_to_expire: @days_to_expire }))
end
def access_token_expired_email(user, token_names = [])
@@ -172,7 +172,7 @@ module Emails
@user = user
- mail_with_locale(to: @user.notification_email_or_default, subject: subject(_("Two-factor authentication disabled")))
+ email_with_layout(to: @user.notification_email_or_default, subject: subject(_("Two-factor authentication disabled")))
end
def new_email_address_added_email(user, email)
diff --git a/app/mailers/previews/notify_preview.rb b/app/mailers/previews/notify_preview.rb
index 638df56b770..6548b6d1088 100644
--- a/app/mailers/previews/notify_preview.rb
+++ b/app/mailers/previews/notify_preview.rb
@@ -81,6 +81,10 @@ class NotifyPreview < ActionMailer::Preview
Notify.access_token_revoked_email(user, 'token_name').message
end
+ def access_token_about_to_expire_email
+ Notify.access_token_about_to_expire_email(user, ['%w', '%w']).message
+ end
+
def ssh_key_expired_email
fingerprints = []
Notify.ssh_key_expired_email(user, fingerprints).message
@@ -222,6 +226,10 @@ class NotifyPreview < ActionMailer::Preview
Notify.two_factor_otp_attempt_failed_email(user, '127.0.0.1').message
end
+ def disabled_two_factor_email
+ Notify.disabled_two_factor_email(user).message
+ end
+
def new_email_address_added_email
Notify.new_email_address_added_email(user, 'someone@gitlab.com').message
end
diff --git a/app/models/integrations/chat_message/alert_message.rb b/app/models/integrations/chat_message/alert_message.rb
index e2c689f9435..6c7ea9aed7c 100644
--- a/app/models/integrations/chat_message/alert_message.rb
+++ b/app/models/integrations/chat_message/alert_message.rb
@@ -34,12 +34,12 @@ module Integrations
"Alert firing in #{strip_markup(project_name)}"
end
- private
-
def attachment_color
"#C95823"
end
+ private
+
def attachment_fields
[
{
diff --git a/app/models/integrations/chat_message/deployment_message.rb b/app/models/integrations/chat_message/deployment_message.rb
index 0367459dfcb..4d3e962d885 100644
--- a/app/models/integrations/chat_message/deployment_message.rb
+++ b/app/models/integrations/chat_message/deployment_message.rb
@@ -30,7 +30,7 @@ module Integrations
[{
text: format(description_message),
- color: color
+ color: attachment_color
}]
end
@@ -38,17 +38,7 @@ module Integrations
{}
end
- private
-
- def message
- if running?
- "Starting deploy to #{strip_markup(environment)}"
- else
- "Deploy to #{strip_markup(environment)} #{humanized_status}"
- end
- end
-
- def color
+ def attachment_color
case status
when 'success'
'good'
@@ -61,6 +51,16 @@ module Integrations
end
end
+ private
+
+ def message
+ if running?
+ "Starting deploy to #{strip_markup(environment)}"
+ else
+ "Deploy to #{strip_markup(environment)} #{humanized_status}"
+ end
+ end
+
def project_link
link(project_name, project_url)
end
diff --git a/app/models/integrations/chat_message/issue_message.rb b/app/models/integrations/chat_message/issue_message.rb
index dd516362491..4c144bc2f68 100644
--- a/app/models/integrations/chat_message/issue_message.rb
+++ b/app/models/integrations/chat_message/issue_message.rb
@@ -41,6 +41,10 @@ module Integrations
}
end
+ def attachment_color
+ '#C95823'
+ end
+
private
def message
@@ -56,7 +60,7 @@ module Integrations
title: issue_title,
title_link: issue_url,
text: format(SlackMarkdownSanitizer.sanitize_slack_link(description)),
- color: '#C95823'
+ color: attachment_color
}]
end
diff --git a/app/models/integrations/chat_message/pipeline_message.rb b/app/models/integrations/chat_message/pipeline_message.rb
index f8a634be336..2abe4a6e9c7 100644
--- a/app/models/integrations/chat_message/pipeline_message.rb
+++ b/app/models/integrations/chat_message/pipeline_message.rb
@@ -89,6 +89,15 @@ module Integrations
}
end
+ def attachment_color
+ case status
+ when 'success'
+ detailed_status == 'passed with warnings' ? 'warning' : 'good'
+ else
+ 'danger'
+ end
+ end
+
private
def actually_failed_jobs(builds)
@@ -180,15 +189,6 @@ module Integrations
end
end
- def attachment_color
- case status
- when 'success'
- detailed_status == 'passed with warnings' ? 'warning' : 'good'
- else
- 'danger'
- end
- end
-
def ref_url
if ref_type == 'tag'
"#{project_url}/-/tags/#{ref}"
diff --git a/app/models/integrations/chat_message/push_message.rb b/app/models/integrations/chat_message/push_message.rb
index b17e28bb6c6..ee44fc98791 100644
--- a/app/models/integrations/chat_message/push_message.rb
+++ b/app/models/integrations/chat_message/push_message.rb
@@ -35,6 +35,10 @@ module Integrations
}
end
+ def attachment_color
+ '#345'
+ end
+
private
def humanized_action(short: false)
@@ -111,10 +115,6 @@ module Integrations
['pushed to', ref_link, "of #{project_link} (#{compare_link})"]
end
end
-
- def attachment_color
- '#345'
- end
end
end
end
diff --git a/app/models/integrations/discord.rb b/app/models/integrations/discord.rb
index 815e3669d78..6aca9fc9921 100644
--- a/app/models/integrations/discord.rb
+++ b/app/models/integrations/discord.rb
@@ -68,7 +68,7 @@ module Integrations
builder.add_embed do |embed|
embed.author = Discordrb::Webhooks::EmbedAuthor.new(name: message.user_name, icon_url: message.user_avatar)
embed.description = (message.pretext + "\n" + Array.wrap(message.attachments).join("\n")).gsub(ATTACHMENT_REGEX, " \\k<entry> - \\k<name>\n")
- embed.colour = 16543014 # The hex "fc6d26" as an Integer
+ embed.colour = embed_color(message)
embed.timestamp = Time.now.utc
end
end
@@ -77,6 +77,33 @@ module Integrations
false
end
+ COLOR_OVERRIDES = {
+ 'good' => '#0d532a',
+ 'warning' => '#703800',
+ 'danger' => '#8d1300'
+ }.freeze
+
+ def embed_color(message)
+ return 'fc6d26'.hex unless message.respond_to?(:attachment_color)
+
+ color = message.attachment_color
+
+ color = COLOR_OVERRIDES[color] if COLOR_OVERRIDES.key?(color)
+
+ color = color.delete_prefix('#')
+
+ normalize_color(color).hex
+ end
+
+ # Expands the short notation to the full colorcode notation
+ # 123456 -> 123456
+ # 123 -> 112233
+ def normalize_color(color)
+ return (color[0, 1] * 2) + (color[1, 1] * 2) + (color[2, 1] * 2) if color.length == 3
+
+ color
+ end
+
def custom_data(data)
super(data).merge(markdown: true)
end
diff --git a/app/presenters/blob_presenter.rb b/app/presenters/blob_presenter.rb
index e8886f8c212..c52fc168c55 100644
--- a/app/presenters/blob_presenter.rb
+++ b/app/presenters/blob_presenter.rb
@@ -90,11 +90,11 @@ class BlobPresenter < Gitlab::View::Presenter::Delegated
end
def blame_path
- url_helpers.project_blame_path(project, ref_qualified_path)
+ url_helpers.project_blame_path(*path_params)
end
def history_path
- url_helpers.project_commits_path(project, ref_qualified_path)
+ url_helpers.project_commits_path(*path_params)
end
def permalink_path
diff --git a/app/views/groups/settings/access_tokens/index.html.haml b/app/views/groups/settings/access_tokens/index.html.haml
index ef85eab6778..832fd6e8ceb 100644
--- a/app/views/groups/settings/access_tokens/index.html.haml
+++ b/app/views/groups/settings/access_tokens/index.html.haml
@@ -50,6 +50,7 @@
access_levels: GroupMember.access_level_roles,
default_access_level: Gitlab::Access::GUEST,
prefix: :resource_access_token,
+ description_prefix: :group_access_token,
help_path: help_page_path('user/group/settings/group_access_tokens', anchor: 'scopes-for-a-group-access-token')
#js-access-token-table-app{ data: { access_token_type: type, access_token_type_plural: type_plural, initial_active_access_tokens: @active_access_tokens.to_json, no_active_tokens_message: _('This group has no active access tokens.'), show_role: true } }
diff --git a/app/views/projects/blob/_breadcrumb.html.haml b/app/views/projects/blob/_breadcrumb.html.haml
index 539453bf6af..c140eecd8c1 100644
--- a/app/views/projects/blob/_breadcrumb.html.haml
+++ b/app/views/projects/blob/_breadcrumb.html.haml
@@ -22,11 +22,11 @@
-# only show normal/blame view links for text files
- if blob.readable_text?
- if blame
- = link_button_to _('Normal view'), project_blob_path(@project, @id)
+ = link_button_to _('Normal view'), project_blob_path(@project, @id, ref_type: @ref_type)
- else
- = link_button_to _('Blame'), project_blame_path(@project, @id), class: 'js-blob-blame-link' unless blob.empty?
+ = link_button_to _('Blame'), project_blame_path(@project, @id, ref_type: @ref_type), class: 'js-blob-blame-link' unless blob.empty?
- = link_button_to _('History'), project_commits_path(@project, @id)
+ = link_button_to _('History'), project_commits_path(@project, @id, ref_type: @ref_type)
= link_button_to _('Permalink'), project_blob_path(@project, tree_join(@commit.sha, @path)),
class: 'js-data-file-blob-permalink-url'
diff --git a/config/initializers/doorkeeper.rb b/config/initializers/doorkeeper.rb
index c06620a97ad..3572c30cdd3 100644
--- a/config/initializers/doorkeeper.rb
+++ b/config/initializers/doorkeeper.rb
@@ -25,6 +25,8 @@ Doorkeeper.configure do
resource_owner_from_credentials do |_routes|
user = User.find_by_login(params[:username])
next unless user
+
+ next if user.password_automatically_set?
next if user.two_factor_enabled? || Gitlab::Auth::TwoFactorAuthVerifier.new(user).two_factor_authentication_enforced?
Gitlab::Auth.find_with_user_password(params[:username], params[:password], increment_failed_attempts: true)
diff --git a/config/locales/doorkeeper.en.yml b/config/locales/doorkeeper.en.yml
index 4b443870d43..ddbd4380d8f 100644
--- a/config/locales/doorkeeper.en.yml
+++ b/config/locales/doorkeeper.en.yml
@@ -114,6 +114,41 @@ en:
Grants create access to the runners.
k8s_proxy:
Grants permission to perform Kubernetes API calls using the agent for Kubernetes.
+ group_access_token_scope_desc:
+ api:
+ Grants complete read and write access to the scoped group and related project API, including the Package Registry.
+ read_api:
+ Grants read access to the scoped group and related project API, including the Package Registry.
+ read_user:
+ Grants read-only access to the authenticated user's profile through the /user API endpoint, which includes username, public email, and full name. Also grants access to read-only API endpoints under /users.
+ read_repository:
+ Grants read access (pull) to all repositories within a group.
+ write_repository:
+ Grants read and write access (pull and push) to all repositories within a group.
+ read_registry:
+ Grants read access (pull) to the Container Registry images if any project within a group is private and authorization is required.
+ write_registry:
+ Grants write access (push) to the Container Registry.
+ read_observability:
+ Grants read-only access to GitLab Observability.
+ write_observability:
+ Grants write access to GitLab Observability.
+ ai_features:
+ Grants permission to perform API actions for GitLab Duo.
+ openid:
+ Grants permission to authenticate with GitLab using OpenID Connect. Also gives read-only access to the user's profile and group memberships.
+ sudo:
+ Grants permission to perform API actions as any user in the system, when authenticated as an admin user.
+ profile:
+ Grants read-only access to the user's profile data using OpenID Connect.
+ email:
+ Grants read-only access to the user's primary email address using OpenID Connect.
+ admin_mode:
+ Grants permission to perform API actions as an administrator, when Admin Mode is enabled.
+ create_runner:
+ Grants permission to create runners in a group.
+ k8s_proxy:
+ Grants permission to perform Kubernetes API calls using the agent for Kubernetes in a group.
project_access_token_scope_desc:
api:
Grants complete read and write access to the scoped project API, including the Package Registry.
diff --git a/doc/development/testing_guide/end_to_end/resources.md b/doc/development/testing_guide/end_to_end/resources.md
index bf3f1c25f5e..735bab2fa0a 100644
--- a/doc/development/testing_guide/end_to_end/resources.md
+++ b/doc/development/testing_guide/end_to_end/resources.md
@@ -404,6 +404,15 @@ let(:issue) { create(:issue, project: project) }
# create a private project via the API with a specific name
let(:project) { create(:project, :private, name: 'my-project-name', add_name_uuid: false) }
+# create one commit in a project that performs three actions
+let(:commit) do
+ create(:commit, commit_message: 'my message', project: project, actions: [
+ { action: 'create', file_path: 'README.md', content: '# Welcome!' },
+ { action: 'update', file_path: 'README.md', content: '# Updated' },
+ { action: 'delete', file_path: 'README.md' }
+ ])
+end
+
###
# instantiate an Issue but don't create it via API yet
diff --git a/doc/user/group/saml_sso/index.md b/doc/user/group/saml_sso/index.md
index 0449848671b..322c910a3ee 100644
--- a/doc/user/group/saml_sso/index.md
+++ b/doc/user/group/saml_sso/index.md
@@ -357,7 +357,7 @@ when the account was created either:
#### Supported user attributes
- **can_create_group** - `true` or `false` to indicate whether the user can create
- new groups. Default is `true`.
+ new top-level groups. Default is `true`.
- **projects_limit** - The total number of personal projects a user can create.
A value of `0` means the user cannot create new projects in their personal
namespace. Default is `10000`.
diff --git a/qa/qa/factories/commits.rb b/qa/qa/factories/commits.rb
new file mode 100644
index 00000000000..5f06af4b3c8
--- /dev/null
+++ b/qa/qa/factories/commits.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+module QA
+ # https://docs.gitlab.com/ee/api/commits.html
+ FactoryBot.define do
+ factory :commit, class: 'QA::Resource::Repository::Commit'
+ end
+end
diff --git a/qa/qa/resource/repository/commit.rb b/qa/qa/resource/repository/commit.rb
index f84ffa6aac3..f39293cfa31 100644
--- a/qa/qa/resource/repository/commit.rb
+++ b/qa/qa/resource/repository/commit.rb
@@ -10,7 +10,8 @@ module QA
:commit_message,
:file_path,
:sha,
- :start_branch
+ :start_branch,
+ :actions
attribute :short_id
@@ -107,8 +108,6 @@ module QA
private
- attr_reader :actions
-
def validate_files!(files)
if !files.is_a?(Array) ||
files.empty? ||
diff --git a/qa/qa/specs/features/api/12_systems/gitaly/automatic_failover_and_recovery_spec.rb b/qa/qa/specs/features/api/12_systems/gitaly/automatic_failover_and_recovery_spec.rb
index 9ffca8d54c9..59b01ada8e5 100644
--- a/qa/qa/specs/features/api/12_systems/gitaly/automatic_failover_and_recovery_spec.rb
+++ b/qa/qa/specs/features/api/12_systems/gitaly/automatic_failover_and_recovery_spec.rb
@@ -43,16 +43,11 @@ module QA
praefect_manager.stop_node(praefect_manager.primary_node)
praefect_manager.wait_for_health_check_failure(praefect_manager.primary_node)
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = second_added_commit_message
- commit.add_files([
- {
- file_path: "file-#{SecureRandom.hex(8)}",
- content: 'This is created on gitaly2/gitaly3 while gitaly1 is unavailable'
- }
- ])
- end
+ create(:commit, project: project, commit_message: second_added_commit_message, actions: [{
+ action: 'create',
+ file_path: "file-#{SecureRandom.hex(8)}",
+ content: 'This is created on gitaly2/gitaly3 while gitaly1 is unavailable'
+ }])
# Confirm that we have access to the repo after failover,
# including the commit we just added
diff --git a/qa/qa/specs/features/api/12_systems/gitaly/changing_repository_storage_spec.rb b/qa/qa/specs/features/api/12_systems/gitaly/changing_repository_storage_spec.rb
index 6990aa0e08e..99a448aa8da 100644
--- a/qa/qa/specs/features/api/12_systems/gitaly/changing_repository_storage_spec.rb
+++ b/qa/qa/specs/features/api/12_systems/gitaly/changing_repository_storage_spec.rb
@@ -15,13 +15,9 @@ module QA
Support::Retrier.retry_on_exception(sleep_interval: 5) do
# For a short period of time after migrating, the repository can be 'read only' which may lead to errors
# 'The repository is temporarily read-only. Please try again later.'
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add new file'
- commit.add_files([
- { file_path: 'new_file', content: '# This is a new file' }
- ])
- end
+ create(:commit, project: project, commit_message: 'Add new file', actions: [
+ { action: 'create', file_path: 'new_file', content: '# This is a new file' }
+ ])
end
expect(project).to have_file('README.md')
diff --git a/qa/qa/specs/features/api/12_systems/gitaly/gitaly_mtls_spec.rb b/qa/qa/specs/features/api/12_systems/gitaly/gitaly_mtls_spec.rb
index 48d08136d28..c855c5f7c74 100644
--- a/qa/qa/specs/features/api/12_systems/gitaly/gitaly_mtls_spec.rb
+++ b/qa/qa/specs/features/api/12_systems/gitaly/gitaly_mtls_spec.rb
@@ -20,16 +20,9 @@ module QA
push.file_content = 'First commit'
end
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = second_added_commit_message
- commit.add_files(
- [{
- file_path: "file-#{SecureRandom.hex(8)}",
- content: 'Second commit'
- }]
- )
- end
+ create(:commit, project: project, commit_message: second_added_commit_message, actions: [
+ { action: 'create', file_path: "file-#{SecureRandom.hex(8)}", content: 'Second commit' }
+ ])
expect(project.commits.map { |commit| commit[:message].chomp })
.to include(intial_commit_message)
diff --git a/qa/qa/specs/features/api/1_manage/group_access_token_spec.rb b/qa/qa/specs/features/api/1_manage/group_access_token_spec.rb
index d730e1a80d4..0e1f6225b31 100644
--- a/qa/qa/specs/features/api/1_manage/group_access_token_spec.rb
+++ b/qa/qa/specs/features/api/1_manage/group_access_token_spec.rb
@@ -37,14 +37,14 @@ module QA
}
) do
expect do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.api_client = api_client
- commit.project = project
- commit.branch = "new_branch_#{SecureRandom.hex(8)}"
- commit.start_branch = project.default_branch
- commit.commit_message = 'Add new file'
- commit.add_files([{ file_path: "text-#{SecureRandom.hex(8)}.txt", content: 'new file' }])
- end
+ create(:commit,
+ api_client: api_client,
+ project: project,
+ branch: "new_branch_#{SecureRandom.hex(8)}",
+ start_branch: project.default_branch,
+ commit_message: 'Add new file', actions: [
+ { action: 'create', file_path: "text-#{SecureRandom.hex(8)}.txt", content: 'new file' }
+ ])
rescue StandardError => e
QA::Runtime::Logger.error("Full failure message: #{e.message}")
raise
diff --git a/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_pipeline_spec.rb b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_pipeline_spec.rb
index f8a83b68ea7..285d1f0b3b2 100644
--- a/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_pipeline_spec.rb
+++ b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_pipeline_spec.rb
@@ -23,22 +23,19 @@ module QA
end
before do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.api_client = source_admin_api_client
- commit.project = source_project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content: <<~YML
- test-success:
- script: echo 'OK'
- YML
- }
- ]
- )
- end
+ create(:commit,
+ api_client: source_admin_api_client,
+ project: source_project,
+ commit_message: 'Add .gitlab-ci.yml', actions: [
+ {
+ action: 'create',
+ file_path: '.gitlab-ci.yml',
+ content: <<~YML
+ test-success:
+ script: echo 'OK'
+ YML
+ }
+ ])
Support::Waiter.wait_until(max_duration: 10, sleep_interval: 1) do
!source_project.pipelines.empty?
diff --git a/qa/qa/specs/features/api/1_manage/project_access_token_spec.rb b/qa/qa/specs/features/api/1_manage/project_access_token_spec.rb
index 5400d22353a..6a144d8e8d3 100644
--- a/qa/qa/specs/features/api/1_manage/project_access_token_spec.rb
+++ b/qa/qa/specs/features/api/1_manage/project_access_token_spec.rb
@@ -23,14 +23,14 @@ module QA
it 'can be used to commit via the API', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347859' do
expect do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.api_client = @user_api_client
- commit.project = @project_access_token.project
- commit.branch = "new_branch_#{SecureRandom.hex(8)}"
- commit.start_branch = @project_access_token.project.default_branch
- commit.commit_message = 'Add new file'
- commit.add_files([{ file_path: "text-#{SecureRandom.hex(8)}.txt", content: 'new file' }])
- end
+ create(:commit,
+ api_client: @user_api_client,
+ project: @project_access_token.project,
+ branch: "new_branch_#{SecureRandom.hex(8)}",
+ start_branch: @project_access_token.project.default_branch,
+ commit_message: 'Add new file', actions: [
+ { action: 'create', file_path: "text-#{SecureRandom.hex(8)}.txt", content: 'new file' }
+ ])
rescue StandardError => e
QA::Runtime::Logger.error("Full failure message: #{e.message}")
raise
@@ -54,14 +54,14 @@ module QA
it 'cannot be used to commit via the API', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347861' do
expect do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.api_client = @user_api_client
- commit.project = @different_project
- commit.branch = "new_branch_#{SecureRandom.hex(8)}"
- commit.start_branch = @different_project.default_branch
- commit.commit_message = 'Add new file'
- commit.add_files([{ file_path: "text-#{SecureRandom.hex(8)}.txt", content: 'new file' }])
- end
+ create(:commit,
+ api_client: @user_api_client,
+ project: @different_project,
+ branch: "new_branch_#{SecureRandom.hex(8)}",
+ start_branch: @different_project.default_branch,
+ commit_message: 'Add new file', actions: [
+ { action: 'create', file_path: "text-#{SecureRandom.hex(8)}.txt", content: 'new file' }
+ ])
end.to raise_error(Resource::ApiFabricator::ResourceFabricationFailedError, /403 Forbidden - You are not allowed to push into this branch/)
end
diff --git a/qa/qa/specs/features/api/3_create/merge_request/push_options_mwps_spec.rb b/qa/qa/specs/features/api/3_create/merge_request/push_options_mwps_spec.rb
index 5c4fc8cef56..bf6efdc27f4 100644
--- a/qa/qa/specs/features/api/3_create/merge_request/push_options_mwps_spec.rb
+++ b/qa/qa/specs/features/api/3_create/merge_request/push_options_mwps_spec.rb
@@ -26,23 +26,18 @@ module QA
end
it 'sets merge when pipeline succeeds', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347843' do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content: <<~YAML
- no-op:
- tags:
- - "runner-for-#{project.name}"
- script: sleep 999 # Leave the pipeline pending
- YAML
- }
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ {
+ action: 'create',
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ no-op:
+ tags:
+ - "runner-for-#{project.name}"
+ script: sleep 999 # Leave the pipeline pending
+ YAML
+ }
+ ])
Resource::Repository::ProjectPush.fabricate! do |push|
push.project = project
@@ -77,23 +72,18 @@ module QA
issue: "https://gitlab.com/gitlab-org/gitlab/-/issues/346425"
}
) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content: <<~YAML
- no-op:
- tags:
- - "runner-for-#{project.name}"
- script: echo 'OK'
- YAML
- }
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ {
+ action: 'create',
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ no-op:
+ tags:
+ - "runner-for-#{project.name}"
+ script: echo 'OK'
+ YAML
+ }
+ ])
Resource::Repository::ProjectPush.fabricate! do |push|
push.project = project
diff --git a/qa/qa/specs/features/api/3_create/repository/commit_to_templated_project_spec.rb b/qa/qa/specs/features/api/3_create/repository/commit_to_templated_project_spec.rb
index 74d1c9e3e94..dba5b7826b4 100644
--- a/qa/qa/specs/features/api/3_create/repository/commit_to_templated_project_spec.rb
+++ b/qa/qa/specs/features/api/3_create/repository/commit_to_templated_project_spec.rb
@@ -7,25 +7,10 @@ module QA
it 'commits via the api', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/357234' do
expect do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.update_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content: 'script'
- }
- ]
- )
- commit.add_files(
- [
- {
- file_path: 'foo',
- content: 'bar'
- }
- ]
- )
- end
+ create(:commit, project: project, actions: [
+ { action: 'update', file_path: '.gitlab-ci.yml', content: 'script' },
+ { action: 'create', file_path: 'foo', content: 'bar' }
+ ])
end.not_to raise_exception
end
end
diff --git a/qa/qa/specs/features/api/3_create/repository/project_archive_compare_spec.rb b/qa/qa/specs/features/api/3_create/repository/project_archive_compare_spec.rb
index 614e2c4d306..9817915e9eb 100644
--- a/qa/qa/specs/features/api/3_create/repository/project_archive_compare_spec.rb
+++ b/qa/qa/specs/features/api/3_create/repository/project_archive_compare_spec.rb
@@ -48,12 +48,9 @@ module QA
def create_project(user, api_client, project_name)
project = create(:project, name: project_name, api_client: api_client, add_name_uuid: false, personal_namespace: user.username)
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.add_files([{ file_path: 'README.md', content: '# This is a test project' }])
- commit.commit_message = 'Add README.md'
- commit.api_client = api_client
- end
+ create(:commit, project: project, api_client: api_client, commit_message: 'Add README.md', actions: [
+ { action: 'create', file_path: 'README.md', content: '# This is a test project' }
+ ])
project
end
diff --git a/qa/qa/specs/features/api/4_verify/file_variable_downstream_pipeline_spec.rb b/qa/qa/specs/features/api/4_verify/file_variable_downstream_pipeline_spec.rb
index 3d409e40c1f..f784432a572 100644
--- a/qa/qa/specs/features/api/4_verify/file_variable_downstream_pipeline_spec.rb
+++ b/qa/qa/specs/features/api/4_verify/file_variable_downstream_pipeline_spec.rb
@@ -29,6 +29,7 @@ module QA
let(:upstream_project_files) do
[
{
+ action: 'create',
file_path: '.gitlab-ci.yml',
content: <<~YAML
default:
@@ -54,6 +55,7 @@ module QA
YAML
},
{
+ action: 'create',
file_path: 'child.yml',
content: <<~YAML
default:
@@ -78,6 +80,7 @@ module QA
let(:downstream_project_file) do
[
{
+ action: 'create',
file_path: '.gitlab-ci.yml',
content: <<~YAML
default:
@@ -175,11 +178,7 @@ module QA
end
def add_ci_file(project, files)
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add CI files to project'
- commit.add_files(files)
- end
+ create(:commit, project: project, commit_message: 'Add CI files to project', actions: files)
end
def wait_for_pipelines_to_finish
diff --git a/qa/qa/specs/features/api/4_verify/file_variable_spec.rb b/qa/qa/specs/features/api/4_verify/file_variable_spec.rb
index 1e859d2b5df..4dcff9d270e 100644
--- a/qa/qa/specs/features/api/4_verify/file_variable_spec.rb
+++ b/qa/qa/specs/features/api/4_verify/file_variable_spec.rb
@@ -15,39 +15,34 @@ module QA
end
let(:add_ci_file) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content: <<~YAML
- default:
- tags: [#{executor}]
-
- variables:
- EXTRA_ARGS: "-f $TEST_FILE"
- DOCKER_REMOTE_ARGS: --tlscacert="$DOCKER_CA_CERT"
- EXTRACTED_CRT_FILE: ${DOCKER_CA_CERT}.crt
- MY_FILE_VAR: $TEST_FILE
-
- job_echo:
- script:
- - echo "run something $EXTRA_ARGS"
- - echo "docker run $DOCKER_REMOTE_ARGS"
- - echo "run --output=$EXTRACTED_CRT_FILE"
- - echo "Will read private key from $MY_FILE_VAR"
-
- job_cat:
- script:
- - cat "$MY_FILE_VAR"
- - cat "$DOCKER_CA_CERT"
- YAML
- }
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ {
+ action: 'create',
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ default:
+ tags: [#{executor}]
+
+ variables:
+ EXTRA_ARGS: "-f $TEST_FILE"
+ DOCKER_REMOTE_ARGS: --tlscacert="$DOCKER_CA_CERT"
+ EXTRACTED_CRT_FILE: ${DOCKER_CA_CERT}.crt
+ MY_FILE_VAR: $TEST_FILE
+
+ job_echo:
+ script:
+ - echo "run something $EXTRA_ARGS"
+ - echo "docker run $DOCKER_REMOTE_ARGS"
+ - echo "run --output=$EXTRACTED_CRT_FILE"
+ - echo "Will read private key from $MY_FILE_VAR"
+
+ job_cat:
+ script:
+ - cat "$MY_FILE_VAR"
+ - cat "$DOCKER_CA_CERT"
+ YAML
+ }
+ ])
end
let(:add_file_variables) do
diff --git a/qa/qa/specs/features/api/5_package/container_registry/saas/container_registry_spec.rb b/qa/qa/specs/features/api/5_package/container_registry/saas/container_registry_spec.rb
index b9ff12b6dd7..8ce462ad59e 100644
--- a/qa/qa/specs/features/api/5_package/container_registry/saas/container_registry_spec.rb
+++ b/qa/qa/specs/features/api/5_package/container_registry/saas/container_registry_spec.rb
@@ -77,15 +77,9 @@ module QA
it 'pushes, pulls image to the registry and deletes tag',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348001' do
Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2, message: "Commit push") do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.api_client = api_client
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.project = project
- commit.add_files([{
- file_path: '.gitlab-ci.yml',
- content: gitlab_ci_yaml
- }])
- end
+ create(:commit, api_client: api_client, commit_message: 'Add .gitlab-ci.yml', project: project, actions: [
+ { action: 'create', file_path: '.gitlab-ci.yml', content: gitlab_ci_yaml }
+ ])
end
Support::Retrier.retry_until(
diff --git a/qa/qa/specs/features/api/9_data_stores/user_inherited_access_spec.rb b/qa/qa/specs/features/api/9_data_stores/user_inherited_access_spec.rb
index 6284f8b3869..37c29715715 100644
--- a/qa/qa/specs/features/api/9_data_stores/user_inherited_access_spec.rb
+++ b/qa/qa/specs/features/api/9_data_stores/user_inherited_access_spec.rb
@@ -69,14 +69,14 @@ module QA
# has been proposed in https://gitlab.com/gitlab-org/gitlab/-/issues/393369
QA::Support::Retrier.retry_on_exception(max_attempts: 5, sleep_interval: 2) do
expect do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.api_client = parent_group_user_api_client
- commit.project = sub_group_project
- commit.branch = "new_branch_#{SecureRandom.hex(8)}"
- commit.start_branch = sub_group_project.default_branch
- commit.commit_message = 'Add new file'
- commit.add_files([{ file_path: 'test.txt', content: 'new file' }])
- end
+ create(:commit,
+ api_client: parent_group_user_api_client,
+ project: sub_group_project,
+ branch: "new_branch_#{SecureRandom.hex(8)}",
+ start_branch: sub_group_project.default_branch,
+ commit_message: 'Add new file', actions: [
+ { action: 'create', file_path: 'test.txt', content: 'new file' }
+ ])
rescue StandardError => e
QA::Runtime::Logger.error("Full failure message: #{e.message}")
raise
@@ -139,14 +139,14 @@ module QA
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/363342'
) do
expect do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.api_client = sub_group_user_api_client
- commit.project = parent_group_project
- commit.branch = "new_branch_#{SecureRandom.hex(8)}"
- commit.start_branch = parent_group_project.default_branch
- commit.commit_message = 'Add new file'
- commit.add_files([{ file_path: 'test.txt', content: 'new file' }])
- end
+ create(:commit,
+ api_client: sub_group_user_api_client,
+ project: parent_group_project,
+ branch: "new_branch_#{SecureRandom.hex(8)}",
+ start_branch: parent_group_project.default_branch,
+ commit_message: 'Add new file', actions: [
+ { action: 'create', file_path: 'test.txt', content: 'new file' }
+ ])
end.to raise_error(Resource::ApiFabricator::ResourceFabricationFailedError,
/403 Forbidden - You are not allowed to push into this branch/)
end
diff --git a/qa/qa/specs/features/browser_ui/1_manage/integrations/pipeline_status_emails_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/integrations/pipeline_status_emails_spec.rb
index d678979ba1f..8874b6cde96 100644
--- a/qa/qa/specs/features/browser_ui/1_manage/integrations/pipeline_status_emails_spec.rb
+++ b/qa/qa/specs/features/browser_ui/1_manage/integrations/pipeline_status_emails_spec.rb
@@ -57,18 +57,9 @@ module QA
end
def push_commit(exit_code: 0)
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content: gitlab_ci_yaml(exit_code: exit_code)
- }
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ { action: 'create', file_path: '.gitlab-ci.yml', content: gitlab_ci_yaml(exit_code: exit_code) }
+ ])
end
def setup_pipeline_emails(emails)
diff --git a/qa/qa/specs/features/browser_ui/1_manage/user/user_access_termination_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/user/user_access_termination_spec.rb
index b67143276e8..ef81cb34a62 100644
--- a/qa/qa/specs/features/browser_ui/1_manage/user/user_access_termination_spec.rb
+++ b/qa/qa/specs/features/browser_ui/1_manage/user/user_access_termination_spec.rb
@@ -66,14 +66,15 @@ module QA
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347865' do
QA::Support::Retrier.retry_on_exception(max_attempts: 5, sleep_interval: 2) do
expect do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.api_client = @user_api_client
- commit.project = @project
- commit.branch = "new_branch_#{SecureRandom.hex(8)}"
- commit.start_branch = @project.default_branch
- commit.commit_message = 'Add new file'
- commit.add_files([{ file_path: 'test.txt', content: 'new file' }])
- end
+ create(:commit,
+ api_client: @user_api_client,
+ project: @project,
+ branch: "new_branch_#{SecureRandom.hex(8)}",
+ start_branch: @project.default_branch,
+ commit_message: 'Add new file',
+ actions: [
+ { action: 'create', file_path: 'test.txt', content: 'new file' }
+ ])
end.to raise_error(Resource::ApiFabricator::ResourceFabricationFailedError,
/403 Forbidden - You are not allowed to push into this branch/)
end
diff --git a/qa/qa/specs/features/browser_ui/2_plan/issue/custom_issue_template_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/issue/custom_issue_template_spec.rb
index c489a61ca2a..21eb6ee678c 100644
--- a/qa/qa/specs/features/browser_ui/2_plan/issue/custom_issue_template_spec.rb
+++ b/qa/qa/specs/features/browser_ui/2_plan/issue/custom_issue_template_spec.rb
@@ -13,17 +13,9 @@ module QA
before do
Flow::Login.sign_in
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = template_project
- commit.commit_message = 'Add custom issue template'
- commit.add_files(
- [
- {
- file_path: ".gitlab/issue_templates/#{template_name}.md",
- content: template_content
- }
- ])
- end
+ create(:commit, project: template_project, commit_message: 'Add custom issue template', actions: [
+ { action: 'create', file_path: ".gitlab/issue_templates/#{template_name}.md", content: template_content }
+ ])
end
it 'creates an issue via custom template', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347945' do
diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/cherry_pick/cherry_pick_commit_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/cherry_pick/cherry_pick_commit_spec.rb
index fa4a1293025..f186fa8ee83 100644
--- a/qa/qa/specs/features/browser_ui/3_create/merge_request/cherry_pick/cherry_pick_commit_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/cherry_pick/cherry_pick_commit_spec.rb
@@ -6,13 +6,13 @@ module QA
let(:file_name) { "secret_file.md" }
let(:project) { create(:project, :with_readme) }
let(:commit) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.branch = "development"
- commit.start_branch = project.default_branch
- commit.commit_message = 'Add new file'
- commit.add_files([{ file_path: file_name, content: 'pssst!' }])
- end
+ create(:commit,
+ project: project,
+ branch: 'development',
+ start_branch: project.default_branch,
+ commit_message: 'Add new file', actions: [
+ { action: 'create', file_path: file_name, content: 'pssst!' }
+ ])
end
before do
diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_from_push_notification_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_from_push_notification_spec.rb
index cabeab9e355..bf02633510b 100644
--- a/qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_from_push_notification_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_from_push_notification_spec.rb
@@ -37,12 +37,14 @@ module QA
'after a push via the API creates a merge request',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/360490'
) do
- commit = Resource::Repository::Commit.fabricate_via_api! do |resource|
- resource.project = project
- resource.add_files([{ 'file_path': "file-#{SecureRandom.hex(8)}.txt", 'content': 'MR init' }])
- resource.branch = branch_name
- resource.start_branch = project.default_branch
- end
+ commit = create(:commit,
+ project: project,
+ branch: branch_name,
+ start_branch: project.default_branch,
+ actions: [
+ { action: 'create', file_path: "file-#{SecureRandom.hex(8)}.txt", content: 'MR init' }
+ ])
+
project.wait_for_push(commit.commit_message)
project.visit!
diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_via_template_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_via_template_spec.rb
index 4072416374a..ef7467e2af2 100644
--- a/qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_via_template_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_via_template_spec.rb
@@ -11,17 +11,13 @@ module QA
before do
Flow::Login.sign_in
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = template_project
- commit.commit_message = 'Add custom merge request template'
- commit.add_files(
- [
- {
- file_path: ".gitlab/merge_request_templates/#{template_name}.md",
- content: template_content
- }
- ])
- end
+ create(:commit, project: template_project, commit_message: 'Add custom merge request template', actions: [
+ {
+ action: 'create',
+ file_path: ".gitlab/merge_request_templates/#{template_name}.md",
+ content: template_content
+ }
+ ])
end
it 'creates a merge request via custom template', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347722' do
diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/merge_when_pipeline_succeeds_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/merge_when_pipeline_succeeds_spec.rb
index cad50fc032b..895b49a7560 100644
--- a/qa/qa/specs/features/browser_ui/3_create/merge_request/merge_when_pipeline_succeeds_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/merge_when_pipeline_succeeds_spec.rb
@@ -15,24 +15,19 @@ module QA
end
let!(:ci_file) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content: <<~YAML
- test:
- tags: ["#{runner_name}"]
- script: sleep 15
- only:
- - merge_requests
- YAML
- }
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ {
+ action: 'create',
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ test:
+ tags: ["#{runner_name}"]
+ script: sleep 15
+ only:
+ - merge_requests
+ YAML
+ }
+ ])
end
before do
diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/rebase_merge_request_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/rebase_merge_request_spec.rb
index 349fa054ff0..8d67dca211d 100644
--- a/qa/qa/specs/features/browser_ui/3_create/merge_request/rebase_merge_request_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/rebase_merge_request_spec.rb
@@ -17,10 +17,9 @@ module QA
settings.enable_ff_only
end
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = merge_request.project
- commit.add_files([{ file_path: 'other.txt', content: 'New file added!' }])
- end
+ create(:commit, project: merge_request.project, actions: [
+ { action: 'create', file_path: 'other.txt', content: 'New file added!' }
+ ])
merge_request.visit!
diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/revert/revert_commit_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/revert/revert_commit_spec.rb
index 5e3260fb44f..2c2fa57582c 100644
--- a/qa/qa/specs/features/browser_ui/3_create/merge_request/revert/revert_commit_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/revert/revert_commit_spec.rb
@@ -6,11 +6,9 @@ module QA
let(:file_name) { "secret_file.md" }
let(:project) { create(:project, :with_readme) }
let(:commit) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add new file'
- commit.add_files([{ file_path: file_name, content: 'pssst!' }])
- end
+ create(:commit, project: project, commit_message: 'Add new file', actions: [
+ { action: 'create', file_path: file_name, content: 'pssst!' }
+ ])
end
before do
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/add_new_branch_rule_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/add_new_branch_rule_spec.rb
index 6e508ba5206..9a102fe0212 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/add_new_branch_rule_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/add_new_branch_rule_spec.rb
@@ -11,13 +11,12 @@ module QA
before do
Flow::Login.sign_in
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.branch = branch_name
- commit.start_branch = project.default_branch
- commit.commit_message = 'First commit'
- commit.add_files([{ file_path: 'new_file.rb', content: '# new content' }])
- end
+ create(:commit,
+ project: project, branch: branch_name,
+ start_branch: project.default_branch,
+ commit_message: 'First commit', actions: [
+ { action: 'create', file_path: 'new_file.rb', content: '# new content' }
+ ])
end
it 'adds a new branch rule', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/397587' do
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/branch_with_unusual_name_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/branch_with_unusual_name_spec.rb
index 368ac1f8cdb..30bccf0167b 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/branch_with_unusual_name_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/branch_with_unusual_name_spec.rb
@@ -12,13 +12,13 @@ module QA
context 'when branch name contains slash, hash, double dash, and capital letter' do
it 'renders repository file tree correctly', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347715' do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.branch = branch_name
- commit.start_branch = project.default_branch
- commit.commit_message = 'Add new file'
- commit.add_files([{ file_path: 'test-folder/test-file.md', content: 'new content' }])
- end
+ create(:commit,
+ project: project,
+ branch: branch_name,
+ start_branch: project.default_branch,
+ commit_message: 'Add new file', actions: [
+ { action: 'create', file_path: 'test-folder/test-file.md', content: 'new content' }
+ ])
project.visit!
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/license_detection_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/license_detection_spec.rb
index 24ef490b3de..7ef6903048d 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/license_detection_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/license_detection_spec.rb
@@ -12,10 +12,9 @@ module QA
shared_examples 'project license detection' do
it 'displays the name of the license on the repository' do
license_path = Runtime::Path.fixture('software_licenses', license_file_name)
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.add_files([{ file_path: 'LICENSE', content: File.read(license_path) }])
- end
+ create(:commit, project: project, actions: [
+ { action: 'create', file_path: 'LICENSE', content: File.read(license_path) }
+ ])
project.visit!
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 4172aa03a72..02e69544250 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
@@ -19,16 +19,10 @@ module QA
let(:directory_name) { 'first_directory' }
before do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.add_files(
- [
- {
- file_path: 'first_directory/test_file.txt',
- content: "Test file content"
- }
- ])
- end
+ create(:commit, project: project, actions: [
+ { action: 'create', file_path: 'first_directory/test_file.txt', content: 'Test file content' }
+ ])
+
project.visit!
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide_old/open_web_ide_from_diff_tab_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide_old/open_web_ide_from_diff_tab_spec.rb
index 10483a7cbee..297f5a486d7 100644
--- a/qa/qa/specs/features/browser_ui/3_create/web_ide_old/open_web_ide_from_diff_tab_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/web_ide_old/open_web_ide_from_diff_tab_spec.rb
@@ -10,28 +10,29 @@ module QA
describe 'Open Web IDE from Diff Tab' do
files = [
{
- file_path: 'file1',
- content: 'test1'
+ action: 'create',
+ file_path: 'file1',
+ content: 'test1'
},
{
- file_path: 'file2',
- content: 'test2'
+ action: 'create',
+ file_path: 'file2',
+ content: 'test2'
},
{
- file_path: 'file3',
- content: 'test3'
+ action: 'create',
+ file_path: 'file3',
+ content: 'test3'
}
]
let(:project) { create(:project, :with_readme) }
let(:source) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.branch = 'new-mr'
- commit.start_branch = project.default_branch
- commit.commit_message = 'Add new files'
- commit.add_files(files)
- end
+ create(:commit,
+ project: project,
+ branch: 'new-mr',
+ start_branch: project.default_branch,
+ commit_message: 'Add new files', actions: files)
end
let(:merge_request) do
diff --git a/qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_parent_child_pipelines_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_parent_child_pipelines_spec.rb
index c54d20ec027..bde817eccd3 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_parent_child_pipelines_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_parent_child_pipelines_spec.rb
@@ -245,16 +245,10 @@ module QA
def update_parent_child_ci_files(parent_job_name:, parent_script:, child_job_name:, child_script:)
original_pipeline_count = pipeline_count
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Update parent and child pipelines CI files.'
- commit.update_files(
- [
- parent_ci_file(parent_job_name, parent_script),
- child_ci_file(child_job_name, child_script)
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'Update parent and child pipelines CI files.', actions: [
+ { action: 'update', **parent_ci_file(parent_job_name, parent_script) },
+ { action: 'update', **child_ci_file(child_job_name, child_script) }
+ ])
wait_for_pipeline_creation(original_pipeline_count)
end
@@ -262,16 +256,10 @@ module QA
def add_parent_child_ci_files(parent_job_name:, parent_script:, child_job_name:, child_script:)
original_pipeline_count = pipeline_count
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add parent and child pipelines CI files.'
- commit.add_files(
- [
- parent_ci_file(parent_job_name, parent_script),
- child_ci_file(child_job_name, child_script)
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'Add parent and child pipelines CI files.', actions: [
+ { action: 'create', **parent_ci_file(parent_job_name, parent_script) },
+ { action: 'create', **child_ci_file(child_job_name, child_script) }
+ ])
wait_for_pipeline_creation(original_pipeline_count)
end
diff --git a/qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_pipelines_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_pipelines_spec.rb
index 1ed89e7936e..f9b8f7dcd1b 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_pipelines_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_pipelines_spec.rb
@@ -128,11 +128,9 @@ module QA
ci_file = ci_file_with_job_artifact(job_name, script)
original_pipeline_count = pipeline_count
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = "Set job #{job_name} script #{script}"
- commit.add_files([ci_file])
- end
+ create(:commit, project: project, commit_message: "Set job #{job_name} script #{script}", actions: [
+ { action: 'create', **ci_file }
+ ])
wait_for_new_pipeline(original_pipeline_count)
end
@@ -141,11 +139,9 @@ module QA
ci_file = ci_file_with_job_artifact(job_name, script)
original_pipeline_count = pipeline_count
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = "Set job #{job_name} script #{script}"
- commit.update_files([ci_file])
- end
+ create(:commit, project: project, commit_message: "Set job #{job_name} script #{script}", actions: [
+ { action: 'update', **ci_file }
+ ])
wait_for_new_pipeline(original_pipeline_count)
end
@@ -154,11 +150,9 @@ module QA
ci_file = ci_file_with_manual_job(job_name, script)
original_pipeline_count = pipeline_count
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = "Set job #{job_name} script #{script}"
- commit.update_files([ci_file])
- end
+ create(:commit, project: project, commit_message: "Set job #{job_name} script #{script}", actions: [
+ { action: 'update', **ci_file }
+ ])
wait_for_new_pipeline(original_pipeline_count)
end
diff --git a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/custom_variable_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/custom_variable_spec.rb
index 6680938ee67..db24cd8aaf1 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/custom_variable_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/custom_variable_spec.rb
@@ -16,27 +16,22 @@ module QA
end
let!(:commit) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content: <<~YAML
- variables:
- FOO:
- value: "Default Foo"
- description: "This is a description for the foo variable"
- #{pipeline_job_name}:
- tags:
- - #{executor}
- script: echo "$FOO"
- YAML
- }
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ {
+ action: 'create',
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ variables:
+ FOO:
+ value: "Default Foo"
+ description: "This is a description for the foo variable"
+ #{pipeline_job_name}:
+ tags:
+ - #{executor}
+ script: echo "$FOO"
+ YAML
+ }
+ ])
end
before do
diff --git a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/pipeline_with_protected_variable_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/pipeline_with_protected_variable_spec.rb
index ccf1a8fedf9..33a47f6e563 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/pipeline_with_protected_variable_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/pipeline_with_protected_variable_spec.rb
@@ -16,23 +16,18 @@ module QA
end
let!(:ci_file) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content: <<~YAML
- job:
- tags:
- - #{executor}
- script: echo $PROTECTED_VARIABLE
- YAML
- }
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ {
+ action: 'create',
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ job:
+ tags:
+ - #{executor}
+ script: echo $PROTECTED_VARIABLE
+ YAML
+ }
+ ])
end
let(:developer) do
@@ -94,20 +89,13 @@ module QA
end
def user_commit_to_protected_branch(api_client)
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.api_client = api_client
- commit.project = project
- commit.branch = 'protected-branch'
- commit.commit_message = Faker::Lorem.sentence
- commit.add_files(
- [
- {
- file_path: Faker::File.unique.file_name,
- content: Faker::Lorem.sentence
- }
- ]
- )
- end
+ create(:commit,
+ api_client: api_client,
+ project: project,
+ branch: 'protected-branch',
+ commit_message: Faker::Lorem.sentence, actions: [
+ { action: 'create', file_path: Faker::File.unique.file_name, content: Faker::Lorem.sentence }
+ ])
end
def create_merge_request(api_client)
diff --git a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/prefill_variables_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/prefill_variables_spec.rb
index 8d315f66034..31b95cb97ae 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/prefill_variables_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/prefill_variables_spec.rb
@@ -10,36 +10,31 @@ module QA
let(:prefill_variable_description5) { Faker::Lorem.sentence }
let(:project) { create(:project, name: 'project-with-prefill-variables') }
let!(:commit) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content: <<~YAML
- variables:
- TEST1:
- value: #{prefill_variable_value1}
- description: #{prefill_variable_description1}
- TEST2:
- description: #{prefill_variable_description2}
- TEST3:
- value: test 3 value
- TEST4: test 4 value
- TEST5:
- value: "FOO"
- options:
- - #{prefill_variable_value5}
- - "FOO"
- description: #{prefill_variable_description5}
- test:
- script: echo "$FOO"
- YAML
- }
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ {
+ action: 'create',
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ variables:
+ TEST1:
+ value: #{prefill_variable_value1}
+ description: #{prefill_variable_description1}
+ TEST2:
+ description: #{prefill_variable_description2}
+ TEST3:
+ value: test 3 value
+ TEST4: test 4 value
+ TEST5:
+ value: "FOO"
+ options:
+ - #{prefill_variable_value5}
+ - "FOO"
+ description: #{prefill_variable_description5}
+ test:
+ script: echo "$FOO"
+ YAML
+ }
+ ])
end
before do
diff --git a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/raw_variables_defined_in_yaml_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/raw_variables_defined_in_yaml_spec.rb
index 99220cf118e..e5e5852b5f2 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/raw_variables_defined_in_yaml_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/raw_variables_defined_in_yaml_spec.rb
@@ -16,53 +16,48 @@ module QA
end
let!(:commit_ci_file) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content: <<~YAML
- variables:
- VAR7:
- value: "value 7 $CI_PIPELINE_ID"
- expand: false
- VAR8:
- value: "value 8 $CI_PIPELINE_ID"
- expand: false
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ {
+ action: 'create',
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ variables:
+ VAR7:
+ value: "value 7 $CI_PIPELINE_ID"
+ expand: false
+ VAR8:
+ value: "value 8 $CI_PIPELINE_ID"
+ expand: false
- #{pipeline_job_name}:
- tags:
- - #{executor}
- script:
- - echo "VAR1 is $VAR1"
- - echo "VAR2 is $VAR2"
- - echo "VAR3 is $VAR3"
- - echo "VAR4 is $VAR4"
- - echo "VAR5 is $VAR5"
- - echo "VAR6 is $VAR6"
- - echo "VAR7 is $VAR7"
- - echo "VAR8 is $VAR8"
- variables:
- VAR1: "JOBID-$CI_JOB_ID"
- VAR2: "PIPELINEID-$CI_PIPELINE_ID and $VAR1"
- VAR3:
- value: "PIPELINEID-$CI_PIPELINE_ID and $VAR1"
- expand: false
- VAR4:
- value: "JOBID-$CI_JOB_ID"
- expand: false
- VAR5: "PIPELINEID-$CI_PIPELINE_ID and $VAR4"
- VAR6:
- value: "PIPELINEID-$CI_PIPELINE_ID and $VAR4"
- expand: false
- VAR7: "overridden value 7 $CI_PIPELINE_ID"
- YAML
- }
- ]
- )
- end
+ #{pipeline_job_name}:
+ tags:
+ - #{executor}
+ script:
+ - echo "VAR1 is $VAR1"
+ - echo "VAR2 is $VAR2"
+ - echo "VAR3 is $VAR3"
+ - echo "VAR4 is $VAR4"
+ - echo "VAR5 is $VAR5"
+ - echo "VAR6 is $VAR6"
+ - echo "VAR7 is $VAR7"
+ - echo "VAR8 is $VAR8"
+ variables:
+ VAR1: "JOBID-$CI_JOB_ID"
+ VAR2: "PIPELINEID-$CI_PIPELINE_ID and $VAR1"
+ VAR3:
+ value: "PIPELINEID-$CI_PIPELINE_ID and $VAR1"
+ expand: false
+ VAR4:
+ value: "JOBID-$CI_JOB_ID"
+ expand: false
+ VAR5: "PIPELINEID-$CI_PIPELINE_ID and $VAR4"
+ VAR6:
+ value: "PIPELINEID-$CI_PIPELINE_ID and $VAR4"
+ expand: false
+ VAR7: "overridden value 7 $CI_PIPELINE_ID"
+ YAML
+ }
+ ])
end
let(:pipeline_id) { project.pipelines.first[:id] }
diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/include_local_config_file_paths_with_wildcard_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/include_local_config_file_paths_with_wildcard_spec.rb
index 8cf923f543b..0a66403f728 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/include_local_config_file_paths_with_wildcard_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/include_local_config_file_paths_with_wildcard_spec.rb
@@ -29,15 +29,14 @@ module QA
private
def add_files_to_project
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add CI and local files'
- commit.add_files([build_config_file, test_config_file, non_detectable_file, main_ci_file])
- end
+ create(:commit, project: project, commit_message: 'Add CI and local files', actions: [
+ build_config_file, test_config_file, non_detectable_file, main_ci_file
+ ])
end
def main_ci_file
{
+ action: 'create',
file_path: '.gitlab-ci.yml',
content: <<~YAML
include: 'configs/*.yml'
@@ -47,6 +46,7 @@ module QA
def build_config_file
{
+ action: 'create',
file_path: 'configs/builds.yml',
content: <<~YAML
build:
@@ -58,6 +58,7 @@ module QA
def test_config_file
{
+ action: 'create',
file_path: 'configs/tests.yml',
content: <<~YAML
test:
@@ -69,6 +70,7 @@ module QA
def non_detectable_file
{
+ action: 'create',
file_path: 'configs/not_included.yaml', # we only include `*.yml` not `*.yaml`
content: <<~YAML
deploy:
diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/include_multiple_files_from_multiple_projects_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/include_multiple_files_from_multiple_projects_spec.rb
index 0b1445a89d9..699ff2465a8 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/include_multiple_files_from_multiple_projects_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/include_multiple_files_from_multiple_projects_spec.rb
@@ -7,13 +7,7 @@ module QA
let(:main_project) { create(:project, name: 'project-with-pipeline') }
let(:project1) { create(:project, name: 'external-project-1') }
let(:project2) { create(:project, name: 'external-project-2') }
- let!(:runner) do
- Resource::ProjectRunner.fabricate! do |runner|
- runner.project = main_project
- runner.name = executor
- runner.tags = [executor]
- end
- end
+ let!(:runner) { create(:project_runner, project: main_project, name: executor, tags: [executor]) }
before do
Flow::Login.sign_in
@@ -51,6 +45,7 @@ module QA
def add_included_files_for(project)
files = [
{
+ action: 'create',
file_path: 'file1.yml',
content: <<~YAML
test1_for_#{project.full_path}:
@@ -59,6 +54,7 @@ module QA
YAML
},
{
+ action: 'create',
file_path: 'file2.yml',
content: <<~YAML
test2_for_#{project.full_path}:
@@ -68,23 +64,16 @@ module QA
}
]
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add files'
- commit.add_files(files)
- end
+ create(:commit, project: project, commit_message: 'Add files', actions: files)
end
def add_main_ci_file(project)
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add config file'
- commit.add_files([main_ci_file])
- end
+ create(:commit, project: project, commit_message: 'Add config file', actions: [main_ci_file])
end
def main_ci_file
{
+ action: 'create',
file_path: '.gitlab-ci.yml',
content: <<~YAML
include:
diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/merge_mr_when_pipline_is_blocked_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/merge_mr_when_pipline_is_blocked_spec.rb
index 3e1e2bc5b5b..64bc4437e9b 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/merge_mr_when_pipline_is_blocked_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/merge_mr_when_pipline_is_blocked_spec.rb
@@ -18,33 +18,30 @@ module QA
end
let!(:ci_file) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- file_path: '.gitlab-ci.yml',
- content: <<~YAML
- test_blocked_pipeline:
- stage: build
- tags: [#{executor}]
- script: echo 'OK!'
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ {
+ action: 'create',
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ test_blocked_pipeline:
+ stage: build
+ tags: [#{executor}]
+ script: echo 'OK!'
- manual_job:
- stage: test
- needs: [test_blocked_pipeline]
- script: echo do not click me
- when: manual
- allow_failure: false
+ manual_job:
+ stage: test
+ needs: [test_blocked_pipeline]
+ script: echo do not click me
+ when: manual
+ allow_failure: false
- dummy_job:
- stage: deploy
- needs: [manual_job]
- script: echo nothing
- YAML
- ]
- )
- end
+ dummy_job:
+ stage: deploy
+ needs: [manual_job]
+ script: echo nothing
+ YAML
+ }
+ ])
end
let(:merge_request) do
diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_independent_relationship_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_independent_relationship_spec.rb
index e599f1929d5..7735181f748 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_independent_relationship_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_independent_relationship_spec.rb
@@ -44,6 +44,7 @@ module QA
def success_child_ci_file
{
+ action: 'create',
file_path: '.child-ci.yml',
content: <<~YAML
child_job:
@@ -57,6 +58,7 @@ module QA
def fail_child_ci_file
{
+ action: 'create',
file_path: '.child-ci.yml',
content: <<~YAML
child_job:
@@ -70,6 +72,7 @@ module QA
def parent_ci_file
{
+ action: 'create',
file_path: '.gitlab-ci.yml',
content: <<~YAML
stages:
@@ -91,16 +94,10 @@ module QA
end
def add_ci_files(child_ci_file)
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add parent and child pipelines CI files.'
- commit.add_files(
- [
- child_ci_file,
- parent_ci_file
- ]
- )
- end.project.visit!
+ create(:commit,
+ project: project,
+ commit_message: 'Add parent and child pipelines CI files.',
+ actions: [child_ci_file, parent_ci_file]).project.visit!
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/pass_dotenv_variables_to_downstream_via_bridge_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/pass_dotenv_variables_to_downstream_via_bridge_spec.rb
index a09575b0622..11b17294ac4 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/pass_dotenv_variables_to_downstream_via_bridge_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/pass_dotenv_variables_to_downstream_via_bridge_spec.rb
@@ -46,15 +46,12 @@ module QA
private
def add_ci_file(project, file)
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add config file'
- commit.add_files([file])
- end
+ create(:commit, project: project, commit_message: 'Add config file', actions: [file])
end
def upstream_ci_file
{
+ action: 'create',
file_path: '.gitlab-ci.yml',
content: <<~YAML
build:
@@ -77,6 +74,7 @@ module QA
def downstream_ci_file
{
+ action: 'create',
file_path: '.gitlab-ci.yml',
content: <<~YAML
downstream_test:
diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/pipeline_with_image_pull_policy_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/pipeline_with_image_pull_policy_spec.rb
index 3e21332c6ec..dd0fb26c87a 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/pipeline_with_image_pull_policy_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/pipeline_with_image_pull_policy_spec.rb
@@ -117,28 +117,23 @@ module QA
end
def add_ci_file
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content: <<~YAML
- default:
- image: ruby:2.6
- tags: [#{runner_name}]
-
- #{job_name}:
- script: echo "Using pull policies #{pull_policies}"
- image:
- name: ruby:2.6
- pull_policy: #{pull_policies}
- YAML
- }
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ {
+ action: 'create',
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ default:
+ image: ruby:2.6
+ tags: [#{runner_name}]
+
+ #{job_name}:
+ script: echo "Using pull policies #{pull_policies}"
+ image:
+ name: ruby:2.6
+ pull_policy: #{pull_policies}
+ YAML
+ }
+ ])
end
def visit_job
diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/run_pipeline_via_web_only_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/run_pipeline_via_web_only_spec.rb
index b96869658c9..da42c28cd48 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/run_pipeline_via_web_only_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/run_pipeline_via_web_only_spec.rb
@@ -7,26 +7,20 @@ module QA
let(:job_name) { 'test_job' }
let(:project) { create(:project, name: 'web-only-pipeline') }
let!(:ci_file) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content: <<~YAML
- #{job_name}:
- tags:
- - #{project.name}
- script: echo 'OK'
- only:
- - web
-
- YAML
- }
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ {
+ action: 'create',
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ #{job_name}:
+ tags:
+ - #{project.name}
+ script: echo 'OK'
+ only:
+ - web
+ YAML
+ }
+ ])
end
before do
diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/run_pipeline_with_manual_jobs_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/run_pipeline_with_manual_jobs_spec.rb
index 498b9da0aed..b5ebcb9e48a 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/run_pipeline_with_manual_jobs_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/run_pipeline_with_manual_jobs_spec.rb
@@ -18,48 +18,43 @@ module QA
end
let!(:ci_file) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content: <<~YAML
- default:
- tags: ["#{executor}"]
-
- stages:
- - Stage1
- - Stage2
- - Stage3
-
- Prep:
- stage: Stage1
- script: exit 0
- when: manual
-
- Build:
- stage: Stage2
- needs: ['Prep']
- script: exit 0
- parallel: 6
-
- Test:
- stage: Stage3
- needs: ['Build']
- script: exit 0
-
- Deploy:
- stage: Stage3
- needs: ['Test']
- script: exit 0
- parallel: 6
- YAML
- }
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ {
+ action: 'create',
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ default:
+ tags: ["#{executor}"]
+
+ stages:
+ - Stage1
+ - Stage2
+ - Stage3
+
+ Prep:
+ stage: Stage1
+ script: exit 0
+ when: manual
+
+ Build:
+ stage: Stage2
+ needs: ['Prep']
+ script: exit 0
+ parallel: 6
+
+ Test:
+ stage: Stage3
+ needs: ['Build']
+ script: exit 0
+
+ Deploy:
+ stage: Stage3
+ needs: ['Test']
+ script: exit 0
+ parallel: 6
+ YAML
+ }
+ ])
end
before do
diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/trigger_child_pipeline_with_manual_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/trigger_child_pipeline_with_manual_spec.rb
index b5b744cb7a1..a9413f036bb 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/trigger_child_pipeline_with_manual_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/trigger_child_pipeline_with_manual_spec.rb
@@ -39,20 +39,14 @@ module QA
private
def add_ci_files
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add parent and child pipelines CI files.'
- commit.add_files(
- [
- child_ci_file,
- parent_ci_file
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'Add parent and child pipelines CI files.', actions: [
+ child_ci_file, parent_ci_file
+ ])
end
def parent_ci_file
{
+ action: 'create',
file_path: '.gitlab-ci.yml',
content: <<~YAML
build:
@@ -76,6 +70,7 @@ module QA
def child_ci_file
{
+ action: 'create',
file_path: '.child-pipeline.yml',
content: <<~YAML
child_build:
diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/trigger_matrix_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/trigger_matrix_spec.rb
index 2cb8e5a163a..9aa4c7a0c34 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/trigger_matrix_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/trigger_matrix_spec.rb
@@ -53,20 +53,12 @@ module QA
private
def add_ci_files
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add parent and child pipelines CI files.'
- commit.add_files(
- [
- child_ci_file,
- parent_ci_file
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'todo', actions: [child_ci_file, parent_ci_file])
end
def parent_ci_file
{
+ action: 'create',
file_path: '.gitlab-ci.yml',
content: <<~YAML
test:
@@ -89,6 +81,7 @@ module QA
def child_ci_file
{
+ action: 'create',
file_path: 'child.yml',
content: <<~YAML
test_vars:
diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/update_ci_file_with_pipeline_editor_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/update_ci_file_with_pipeline_editor_spec.rb
index efd60b79ade..7c8567c7729 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/update_ci_file_with_pipeline_editor_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/update_ci_file_with_pipeline_editor_spec.rb
@@ -7,20 +7,15 @@ module QA
let(:project) { create(:project, name: 'pipeline-editor-project') }
let!(:commit) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content: <<~YAML
- 'This is to make pipeline fail immediately to save test execution time and resources.'
- YAML
- }
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ {
+ action: 'create',
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ 'This is to make pipeline fail immediately to save test execution time and resources.'
+ YAML
+ }
+ ])
end
let(:new_content) do
diff --git a/qa/qa/specs/features/browser_ui/5_package/container_registry/saas/container_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/container_registry/saas/container_registry_spec.rb
index 28d3ef60bbe..d97f343ca7c 100644
--- a/qa/qa/specs/features/browser_ui/5_package/container_registry/saas/container_registry_spec.rb
+++ b/qa/qa/specs/features/browser_ui/5_package/container_registry/saas/container_registry_spec.rb
@@ -52,14 +52,9 @@ module QA
project.visit!
Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files([{
- file_path: '.gitlab-ci.yml',
- content: gitlab_ci_yaml
- }])
- end
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ { action: 'create', file_path: '.gitlab-ci.yml', content: gitlab_ci_yaml }
+ ])
end
Flow::Pipeline.visit_latest_pipeline
diff --git a/qa/qa/specs/features/browser_ui/5_package/container_registry/self_managed/container_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/container_registry/self_managed/container_registry_spec.rb
index e4d6ba9c4db..065f86452bb 100644
--- a/qa/qa/specs/features/browser_ui/5_package/container_registry/self_managed/container_registry_spec.rb
+++ b/qa/qa/specs/features/browser_ui/5_package/container_registry/self_managed/container_registry_spec.rb
@@ -121,34 +121,28 @@ module QA
it "pushes image and deletes tag", :registry, testcase: params[:testcase] do
Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content:
- <<~YAML
- build:
- image: "#{docker_client_version}"
- stage: build
- services:
- - name: "#{docker_client_version}-dind"
- command: ["--insecure-registry=gitlab.test:5050"]
- variables:
- IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
- script:
- - docker login -u #{auth_user} -p #{auth_token} gitlab.test:5050
- - docker build -t $IMAGE_TAG .
- - docker push $IMAGE_TAG
- tags:
- - "runner-for-#{project.name}"
- YAML
- }
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ {
+ action: 'create',
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ build:
+ image: "#{docker_client_version}"
+ stage: build
+ services:
+ - name: "#{docker_client_version}-dind"
+ command: ["--insecure-registry=gitlab.test:5050"]
+ variables:
+ IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
+ script:
+ - docker login -u #{auth_user} -p #{auth_token} gitlab.test:5050
+ - docker build -t $IMAGE_TAG .
+ - docker push $IMAGE_TAG
+ tags:
+ - "runner-for-#{project.name}"
+ YAML
+ }
+ ])
end
Flow::Pipeline.visit_latest_pipeline
@@ -180,41 +174,35 @@ module QA
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347591'
) do
Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files(
- [
- {
- file_path: '.gitlab-ci.yml',
- content:
- <<~YAML
- build:
- image: docker:23.0.6
- stage: build
- services:
- - name: docker:23.0.6-dind
- command:
- - /bin/sh
- - -c
- - |
- apk add --no-cache openssl
- true | openssl s_client -showcerts -connect gitlab.test:5050 > /usr/local/share/ca-certificates/gitlab.test.crt
- update-ca-certificates
- dockerd-entrypoint.sh || exit
- variables:
- IMAGE_TAG: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
- script:
- - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD gitlab.test:5050
- - docker build -t $IMAGE_TAG .
- - docker push $IMAGE_TAG
- tags:
- - "runner-for-#{project.name}"
- YAML
- }
- ]
- )
- end
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ {
+ action: 'create',
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ build:
+ image: docker:23.0.6
+ stage: build
+ services:
+ - name: docker:23.0.6-dind
+ command:
+ - /bin/sh
+ - -c
+ - |
+ apk add --no-cache openssl
+ true | openssl s_client -showcerts -connect gitlab.test:5050 > /usr/local/share/ca-certificates/gitlab.test.crt
+ update-ca-certificates
+ dockerd-entrypoint.sh || exit
+ variables:
+ IMAGE_TAG: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
+ script:
+ - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD gitlab.test:5050
+ - docker build -t $IMAGE_TAG .
+ - docker push $IMAGE_TAG
+ tags:
+ - "runner-for-#{project.name}"
+ YAML
+ }
+ ])
end
Flow::Pipeline.visit_latest_pipeline
diff --git a/qa/qa/specs/features/browser_ui/5_package/dependency_proxy/dependency_proxy_spec.rb b/qa/qa/specs/features/browser_ui/5_package/dependency_proxy/dependency_proxy_spec.rb
index 6b698d089f6..b37d06e2223 100644
--- a/qa/qa/specs/features/browser_ui/5_package/dependency_proxy/dependency_proxy_spec.rb
+++ b/qa/qa/specs/features/browser_ui/5_package/dependency_proxy/dependency_proxy_spec.rb
@@ -101,32 +101,30 @@ module QA
it "pulls an image using the dependency proxy", testcase: params[:testcase] do
Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files([{
- file_path: '.gitlab-ci.yml',
- content:
- <<~YAML
- dependency-proxy-pull-test:
- image: "#{docker_client_version}"
- services:
- - name: "#{docker_client_version}-dind"
- command: ["--insecure-registry=gitlab.test:80"]
- before_script:
- - apk add curl jq grep
- - docker login -u #{auth_user} -p #{auth_token} gitlab.test:80
- script:
- - docker pull #{dependency_proxy_url}/#{image_sha}
- - TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq --raw-output .token)
- - 'curl --head --header "Authorization: Bearer $TOKEN" "https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest" 2>&1'
- - docker pull #{dependency_proxy_url}/#{image_sha}
- - 'curl --head --header "Authorization: Bearer $TOKEN" "https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest" 2>&1'
- tags:
- - "runner-for-#{project.name}"
- YAML
- }])
- end
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ {
+ action: 'create',
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ dependency-proxy-pull-test:
+ image: "#{docker_client_version}"
+ services:
+ - name: "#{docker_client_version}-dind"
+ command: ["--insecure-registry=gitlab.test:80"]
+ before_script:
+ - apk add curl jq grep
+ - docker login -u #{auth_user} -p #{auth_token} gitlab.test:80
+ script:
+ - docker pull #{dependency_proxy_url}/#{image_sha}
+ - TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq --raw-output .token)
+ - 'curl --head --header "Authorization: Bearer $TOKEN" "https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest" 2>&1'
+ - docker pull #{dependency_proxy_url}/#{image_sha}
+ - 'curl --head --header "Authorization: Bearer $TOKEN" "https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest" 2>&1'
+ tags:
+ - "runner-for-#{project.name}"
+ YAML
+ }
+ ])
end
project.visit!
diff --git a/qa/qa/specs/features/browser_ui/5_package/infrastructure_registry/terraform_module_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/infrastructure_registry/terraform_module_registry_spec.rb
index 05c6694e69a..e8c58fb161f 100644
--- a/qa/qa/specs/features/browser_ui/5_package/infrastructure_registry/terraform_module_registry_spec.rb
+++ b/qa/qa/specs/features/browser_ui/5_package/infrastructure_registry/terraform_module_registry_spec.rb
@@ -45,20 +45,13 @@ module QA
it 'publishes a module', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/371583' do
Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- terraform_module_yaml = ERB.new(
- read_fixture('package_managers/terraform', 'module_upload.yaml.erb')
- ).result(binding)
- commit.project = imported_project
- commit.commit_message = 'Add gitlab-ci.yaml file'
- commit.update_files([
- {
- file_path: '.gitlab-ci.yml',
- content: terraform_module_yaml
- }
- ]
- )
- end
+ terraform_module_yaml = ERB.new(
+ read_fixture('package_managers/terraform', 'module_upload.yaml.erb')
+ ).result(binding)
+
+ create(:commit, project: imported_project, commit_message: 'Add gitlab-ci.yaml file', actions: [
+ { action: 'update', file_path: '.gitlab-ci.yml', content: terraform_module_yaml }
+ ])
end
Resource::Tag.fabricate_via_api! do |tag|
diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/composer_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/composer_registry_spec.rb
index 6e52208004f..0d6f0faa8c1 100644
--- a/qa/qa/specs/features/browser_ui/5_package/package_registry/composer_registry_spec.rb
+++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/composer_registry_spec.rb
@@ -27,22 +27,13 @@ module QA
before do
Flow::Login.sign_in
Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- composer_yaml = ERB.new(read_fixture('package_managers/composer', 'composer_upload_package.yaml.erb')).result(binding)
- composer_json = ERB.new(read_fixture('package_managers/composer', 'composer.json.erb')).result(binding)
+ composer_yaml = ERB.new(read_fixture('package_managers/composer', 'composer_upload_package.yaml.erb')).result(binding)
+ composer_json = ERB.new(read_fixture('package_managers/composer', 'composer.json.erb')).result(binding)
- commit.project = project
- commit.commit_message = 'Add files'
- commit.add_files([{
- file_path: '.gitlab-ci.yml',
- content: composer_yaml
- },
- {
- file_path: 'composer.json',
- content: composer_json
- }]
- )
- end
+ create(:commit, project: project, commit_message: 'Add files', actions: [
+ { action: 'create', file_path: '.gitlab-ci.yml', content: composer_yaml },
+ { action: 'create', file_path: 'composer.json', content: composer_json }
+ ])
end
project.visit!
diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/conan_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/conan_repository_spec.rb
index f2e19068f18..7e70d73e339 100644
--- a/qa/qa/specs/features/browser_ui/5_package/package_registry/conan_repository_spec.rb
+++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/conan_repository_spec.rb
@@ -39,16 +39,11 @@ module QA
Flow::Login.sign_in
Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- conan_yaml = ERB.new(read_fixture('package_managers/conan', 'conan_upload_install_package.yaml.erb')).result(binding)
+ conan_yaml = ERB.new(read_fixture('package_managers/conan', 'conan_upload_install_package.yaml.erb')).result(binding)
- commit.project = project
- commit.commit_message = 'Add .gitlab-ci.yml'
- commit.add_files([{
- file_path: '.gitlab-ci.yml',
- content: conan_yaml
- }])
- end
+ create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [
+ { action: 'create', file_path: '.gitlab-ci.yml', content: conan_yaml }
+ ])
end
project.visit!
diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/generic_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/generic_repository_spec.rb
index 8ad82211f0d..1baa70a2a65 100644
--- a/qa/qa/specs/features/browser_ui/5_package/package_registry/generic_repository_spec.rb
+++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/generic_repository_spec.rb
@@ -32,21 +32,12 @@ module QA
Flow::Login.sign_in
Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- generic_packages_yaml = ERB.new(read_fixture('package_managers/generic', 'generic_upload_install_package.yaml.erb')).result(binding)
-
- commit.project = project
- commit.commit_message = 'Add files'
- commit.add_files([{
- file_path: '.gitlab-ci.yml',
- content: generic_packages_yaml
- },
- {
- file_path: 'file.txt',
- content: file_txt
- }]
- )
- end
+ generic_packages_yaml = ERB.new(read_fixture('package_managers/generic', 'generic_upload_install_package.yaml.erb')).result(binding)
+
+ create(:commit, project: project, commit_message: 'Add files', actions: [
+ { action: 'create', file_path: '.gitlab-ci.yml', content: generic_packages_yaml },
+ { action: 'create', file_path: 'file.txt', content: file_txt }
+ ])
end
project.visit!
diff --git a/scripts/changed-feature-flags b/scripts/changed-feature-flags
deleted file mode 100755
index 8c1b219e5a6..00000000000
--- a/scripts/changed-feature-flags
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/usr/bin/env ruby
-# frozen_string_literal: true
-
-require 'yaml'
-require 'optparse'
-require 'pathname'
-require_relative 'api/default_options'
-
-# This script returns the desired feature flag state as a comma-separated string for the feature flags in the specified files.
-# Each desired feature flag state is specified as 'feature-flag=state'. This allows us to run package-and-qa with the
-# feature flag set to the desired state.
-#
-# For example, if the specified files included `config/feature_flags/development/ci_awesome_feature.yml` and the desired
-# state as specified by the second argument was enabled, the value returned would be `ci_awesome_feature=enabled`
-
-class GetFeatureFlagsFromFiles
- def initialize(options)
- @files = options.delete(:files)
- @state = options.delete(:state)
-
- abort("ERROR: Please specify the directory containing MR diffs.") if @files.to_s.empty?
- end
-
- # Gets feature flags from definition files or diffs of deleted defition files
- #
- # @return [String] a comma-separated list of feature flags and their desired state
- def extracted_flags
- flags_list = diffs_dir.glob('**/*').each_with_object([]) do |file_path, flags|
- ff_yaml = ff_yaml_for_file(file_path)
- next if ff_yaml.nil?
- break [] if ff_yaml.empty?
-
- flags << ff_yaml['name']
- end
- flags_list = flags_list.map { |flag| "#{flag}=#{state}" } unless state.to_s.empty?
- flags_list.join(',')
- end
-
- # Loads the YAML feature flag definition based on a diff of the definition file. The definition is loaded from the
- # definition file itself, or from a diff of the deleted definition file.
- #
- # @param [Pathname] path the path to the diff
- # @return [Hash] a hash containing the YAML data for the feature flag definition
- def ff_yaml_for_file(path)
- return unless File.expand_path(path).to_s =~ %r{/feature_flags/(development|ops)/.*\.yml}
-
- if path.to_s.end_with?('yml.deleted.diff')
- # Ignore deleted feature flag definitions if we want to enable/disable existing flags.
- return if state != 'deleted'
-
- yaml_from_deleted_diff(path)
- else
- # If we want deleted definition files but find one that wasn't deleted, we return immediately to
- # because non-deleted flags are tested in separate jobs from deleted flags, so we don't need to run
- # a job with just deleted flags.
- return [] if state == 'deleted'
-
- yaml_from_file(path, diffs_dir)
- end
- end
-
- private
-
- attr_reader :files, :state
-
- # The absolute path to the directory of diffs
- #
- # @return [String]
- def diffs_dir
- @diffs_dir ||= Pathname.new(files).expand_path
- end
-
- # Loads the YAML feature flag definition from a file corresponding to a diff of the definition file.
- #
- # @param [Pathname] file_path the path to the diff
- # @param [Pathname] diffs_dir the path to the diffs directory
- # @return [Hash] a hash containing the YAML data from the feature flag definition file corresponding to the diff
- def yaml_from_file(file_path, diffs_dir)
- real_file_path = File.join(Dir.pwd, file_path.to_s.delete_prefix(diffs_dir.to_s)).delete_suffix('.diff')
- YAML.safe_load(File.read(real_file_path))
- end
-
- # Loads the YAML feature flag definition from a diff of the deleted feature flag definition file.
- #
- # @param [Pathname] file_path the path of the diff
- # @return [Hash] a hash containing the YAML data for the feature flag definition from the diff
- def yaml_from_deleted_diff(file_path)
- cleaned_diff = File.read(file_path).gsub(/^[^a-z]+/, '')
- YAML.safe_load(cleaned_diff)
- end
-end
-
-if $PROGRAM_NAME == __FILE__
- options = API::DEFAULT_OPTIONS.dup
-
- OptionParser.new do |opts|
- opts.on("-f", "--files FILES", String, "A directory containing diffs including feature flag definition change diffs") do |value|
- options[:files] = value
- end
-
- opts.on("-s", "--state STATE", String,
- "The desired state of the feature flags (enabled or disabled). If not specified the output will only list the feature flags."
- ) do |value|
- options[:state] = value
- end
-
- opts.on("-h", "--help", "Prints this help") do
- puts opts
- exit
- end
- end.parse!
-
- puts GetFeatureFlagsFromFiles.new(options).extracted_flags
-end
diff --git a/scripts/used-feature-flags b/scripts/feature_flags/used-feature-flags
index 74180d02a91..7bfe4a89634 100755
--- a/scripts/used-feature-flags
+++ b/scripts/feature_flags/used-feature-flags
@@ -3,7 +3,9 @@
require 'set'
require 'fileutils'
-require_relative '../lib/gitlab_edition'
+require_relative '../../lib/gitlab_edition'
+
+ADDITIONAL_EDITIONS = %w[ee jh].freeze
class String
def red
@@ -23,18 +25,19 @@ class String
end
end
-flags_paths = [
- 'config/feature_flags/**/*.yml'
-]
+def add_definition_path!(edition, flag_def_paths)
+ return unless GitlabEdition.public_send(:"#{edition}?") # rubocop:disable GitlabSecurity/PublicSend
-# For EE additionally process `ee/` feature flags
-if GitlabEdition.ee?
- flags_paths << 'ee/config/feature_flags/**/*.yml'
+ flag_def_paths << "#{edition}/config/feature_flags/**/*.yml"
+end
+
+def mark_replicator_flags_as_used(edition)
+ return unless GitlabEdition.public_send(:"#{edition}?") # rubocop:disable GitlabSecurity/PublicSend
# Geo feature flags are constructed dynamically and there's no explicit checks in the codebase so we mark all
# the replicators' derived feature flags as used.
# See https://gitlab.com/gitlab-org/gitlab/-/blob/54e802e8fe76b6f93656d75ef9b566bf57b60f41/ee/lib/gitlab/geo/replicator.rb#L183-185
- Dir.glob('ee/app/replicators/geo/*_replicator.rb').each_with_object(Set.new) do |path, memo|
+ Dir.glob("#{edition}/app/replicators/geo/*_replicator.rb").each do |path|
replicator_name = File.basename(path, '.rb')
feature_flag_name = "geo_#{replicator_name.delete_suffix('_replicator')}_replication"
@@ -42,16 +45,13 @@ if GitlabEdition.ee?
end
end
-# For JH additionally process `jh/` feature flags
-if GitlabEdition.jh?
- flags_paths << 'jh/config/feature_flags/**/*.yml'
-
- Dir.glob('jh/app/replicators/geo/*_replicator.rb').each_with_object(Set.new) do |path, memo|
- replicator_name = File.basename(path, '.rb')
- feature_flag_name = "geo_#{replicator_name.delete_suffix('_replicator')}_replication"
+flag_definition_paths = [
+ 'config/feature_flags/**/*.yml'
+]
- FileUtils.touch(File.join('tmp', 'feature_flags', "#{feature_flag_name}.used"))
- end
+ADDITIONAL_EDITIONS.each do |edition|
+ add_definition_path!(edition, flag_definition_paths)
+ mark_replicator_flags_as_used(edition)
end
all_flags = {}
@@ -59,19 +59,16 @@ additional_flags = Set.new
# Iterate all defined feature flags
# to discover which were used
-flags_paths.each do |flags_path|
- puts flags_path
- Dir.glob(flags_path).each do |path|
- feature_flag_name = File.basename(path, '.yml')
-
- # TODO: we need a better way of tracking use of Gitaly FF across Gitaly and GitLab
- if feature_flag_name.start_with?('gitaly_')
- puts "Skipping the #{feature_flag_name} feature flag since it starts with 'gitaly_'."
- next
- end
-
- all_flags[feature_flag_name] = File.exist?(File.join('tmp', 'feature_flags', feature_flag_name + '.used'))
+Dir.glob(flag_definition_paths).each do |flag_definition_path|
+ feature_flag_name = File.basename(flag_definition_path, '.yml')
+
+ # TODO: we need a better way of tracking use of Gitaly FF across Gitaly and GitLab
+ if feature_flag_name.start_with?('gitaly_')
+ puts "Skipping the #{feature_flag_name} feature flag since it starts with 'gitaly_'."
+ next
end
+
+ all_flags[feature_flag_name] = File.exist?(File.join('tmp', 'feature_flags', "#{feature_flag_name}.used"))
end
# Iterate all used feature flags
@@ -82,8 +79,8 @@ Dir.glob('tmp/feature_flags/*.used').each do |path|
additional_flags.add(feature_flag_name) unless all_flags[feature_flag_name]
end
-used_flags = all_flags.select { |name, used| used }
-unused_flags = all_flags.reject { |name, used| used }
+used_flags = all_flags.select { |_name, used| used }
+unused_flags = all_flags.reject { |_name, used| used }
puts "=========================================".green.bold
puts "Feature Flags usage summary:".green.bold
diff --git a/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb b/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb
index f0058e75e52..89f6e41bec0 100644
--- a/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb
+++ b/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb
@@ -55,10 +55,50 @@ RSpec.describe 'Blob button line permalinks (BlobLinePermalinkUpdater)', :js, fe
end
describe 'Click "Blame" button' do
+ context 'when redirect_with_ref_type is disabled' do
+ before do
+ stub_feature_flags(redirect_with_ref_type: false)
+ end
+
+ it 'works with no initial line number fragment hash' do
+ visit_blob
+
+ expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path))))
+ end
+
+ it 'maintains intitial fragment hash' do
+ fragment = "L3"
+
+ visit_blob(fragment)
+
+ expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: fragment)))
+ end
+
+ it 'changes fragment hash if line number clicked' do
+ visit_blob
+
+ find('#L3').click
+ find("#L5").click
+
+ expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: "L5")))
+ end
+
+ it 'with initial fragment hash, changes fragment hash if line number clicked' do
+ fragment = "L1"
+
+ visit_blob(fragment)
+
+ find('#L3').click
+ find("#L5").click
+
+ expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: "L5")))
+ end
+ end
+
it 'works with no initial line number fragment hash' do
visit_blob
- expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path))))
+ expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), ref_type: 'heads')))
end
it 'maintains intitial fragment hash' do
@@ -66,7 +106,7 @@ RSpec.describe 'Blob button line permalinks (BlobLinePermalinkUpdater)', :js, fe
visit_blob(fragment)
- expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: fragment)))
+ expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), ref_type: 'heads', anchor: fragment)))
end
it 'changes fragment hash if line number clicked' do
@@ -75,7 +115,7 @@ RSpec.describe 'Blob button line permalinks (BlobLinePermalinkUpdater)', :js, fe
find('#L3').click
find("#L5").click
- expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: "L5")))
+ expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), ref_type: 'heads', anchor: "L5")))
end
it 'with initial fragment hash, changes fragment hash if line number clicked' do
@@ -86,7 +126,7 @@ RSpec.describe 'Blob button line permalinks (BlobLinePermalinkUpdater)', :js, fe
find('#L3').click
find("#L5").click
- expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: "L5")))
+ expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), ref_type: 'heads', anchor: "L5")))
end
end
end
diff --git a/spec/frontend/ci/runner/admin_runners/admin_runners_app_spec.js b/spec/frontend/ci/runner/admin_runners/admin_runners_app_spec.js
index 1bbcb991619..bc28147db27 100644
--- a/spec/frontend/ci/runner/admin_runners/admin_runners_app_spec.js
+++ b/spec/frontend/ci/runner/admin_runners/admin_runners_app_spec.js
@@ -156,9 +156,7 @@ describe('AdminRunnersApp', () => {
await createComponent({ mountFn: mountExtended });
});
- // quarantine: https://gitlab.com/gitlab-org/gitlab/-/issues/414975
- // eslint-disable-next-line jest/no-disabled-tests
- it.skip('fetches counts', () => {
+ it('fetches counts', () => {
expect(mockRunnersCountHandler).toHaveBeenCalledTimes(COUNT_QUERIES);
});
diff --git a/spec/helpers/access_tokens_helper_spec.rb b/spec/helpers/access_tokens_helper_spec.rb
index a466b2a0d3b..9b47f23f514 100644
--- a/spec/helpers/access_tokens_helper_spec.rb
+++ b/spec/helpers/access_tokens_helper_spec.rb
@@ -9,6 +9,7 @@ RSpec.describe AccessTokensHelper do
where(:prefix, :description_location) do
:personal_access_token | [:doorkeeper, :scope_desc]
:project_access_token | [:doorkeeper, :project_access_token_scope_desc]
+ :group_access_token | [:doorkeeper, :group_access_token_scope_desc]
end
with_them do
diff --git a/spec/models/integrations/chat_message/alert_message_spec.rb b/spec/models/integrations/chat_message/alert_message_spec.rb
index 162df1a774c..a9db9e14883 100644
--- a/spec/models/integrations/chat_message/alert_message_spec.rb
+++ b/spec/models/integrations/chat_message/alert_message_spec.rb
@@ -57,4 +57,10 @@ RSpec.describe Integrations::ChatMessage::AlertMessage do
expect(time_item[:value]).to eq(expected_time)
end
end
+
+ describe '#attachment_color' do
+ it 'returns the correct color' do
+ expect(subject.attachment_color).to eq('#C95823')
+ end
+ end
end
diff --git a/spec/models/integrations/chat_message/deployment_message_spec.rb b/spec/models/integrations/chat_message/deployment_message_spec.rb
index 630ae902331..afbf1d1c0d1 100644
--- a/spec/models/integrations/chat_message/deployment_message_spec.rb
+++ b/spec/models/integrations/chat_message/deployment_message_spec.rb
@@ -19,6 +19,29 @@ RSpec.describe Integrations::ChatMessage::DeploymentMessage, feature_category: :
it_behaves_like Integrations::ChatMessage
+ def deployment_data(params)
+ {
+ object_kind: "deployment",
+ status: "success",
+ deployable_id: 3,
+ deployable_url: "deployable_url",
+ environment: "sandbox",
+ project: {
+ name: "greatproject",
+ web_url: "project_web_url",
+ path_with_namespace: "project_path_with_namespace"
+ },
+ user: {
+ name: "Jane Person",
+ username: "jane"
+ },
+ user_url: "user_url",
+ short_sha: "12345678",
+ commit_url: "commit_url",
+ commit_title: "commit title text"
+ }.merge(params)
+ end
+
describe '#pretext' do
it 'returns a message with the data returned by the deployment data builder' do
expect(subject.pretext).to eq("Deploy to myenvironment succeeded")
@@ -80,29 +103,6 @@ RSpec.describe Integrations::ChatMessage::DeploymentMessage, feature_category: :
end
describe '#attachments' do
- def deployment_data(params)
- {
- object_kind: "deployment",
- status: "success",
- deployable_id: 3,
- deployable_url: "deployable_url",
- environment: "sandbox",
- project: {
- name: "greatproject",
- web_url: "project_web_url",
- path_with_namespace: "project_path_with_namespace"
- },
- user: {
- name: "Jane Person",
- username: "jane"
- },
- user_url: "user_url",
- short_sha: "12345678",
- commit_url: "commit_url",
- commit_title: "commit title text"
- }.merge(params)
- end
-
context 'without markdown' do
it 'returns attachments with the data returned by the deployment data builder' do
job_url = Gitlab::Routing.url_helpers.project_job_url(project, ci_build)
@@ -165,4 +165,23 @@ RSpec.describe Integrations::ChatMessage::DeploymentMessage, feature_category: :
}])
end
end
+
+ describe '#attachment_color' do
+ using RSpec::Parameterized::TableSyntax
+ where(:status, :expected_color) do
+ 'success' | 'good'
+ 'canceled' | 'warning'
+ 'failed' | 'danger'
+ 'blub' | '#334455'
+ end
+
+ with_them do
+ it 'returns the correct color' do
+ data = deployment_data(status: status)
+ message = described_class.new(data)
+
+ expect(message.attachment_color).to eq(expected_color)
+ end
+ end
+ end
end
diff --git a/spec/models/integrations/chat_message/issue_message_spec.rb b/spec/models/integrations/chat_message/issue_message_spec.rb
index 14451427a5a..7b09b5d08b0 100644
--- a/spec/models/integrations/chat_message/issue_message_spec.rb
+++ b/spec/models/integrations/chat_message/issue_message_spec.rb
@@ -125,4 +125,10 @@ RSpec.describe Integrations::ChatMessage::IssueMessage, feature_category: :integ
end
end
end
+
+ describe '#attachment_color' do
+ it 'returns the correct color' do
+ expect(subject.attachment_color).to eq('#C95823')
+ end
+ end
end
diff --git a/spec/models/integrations/chat_message/pipeline_message_spec.rb b/spec/models/integrations/chat_message/pipeline_message_spec.rb
index 4d371ca0899..5eb3915018e 100644
--- a/spec/models/integrations/chat_message/pipeline_message_spec.rb
+++ b/spec/models/integrations/chat_message/pipeline_message_spec.rb
@@ -388,4 +388,31 @@ RSpec.describe Integrations::ChatMessage::PipelineMessage do
)
end
end
+
+ describe '#attachment_color' do
+ context 'when success' do
+ before do
+ args[:object_attributes][:status] = 'success'
+ end
+
+ it { expect(subject.attachment_color).to eq('good') }
+ end
+
+ context 'when passed with warnings' do
+ before do
+ args[:object_attributes][:status] = 'success'
+ args[:object_attributes][:detailed_status] = 'passed with warnings'
+ end
+
+ it { expect(subject.attachment_color).to eq('warning') }
+ end
+
+ context 'when failed' do
+ before do
+ args[:object_attributes][:status] = 'failed'
+ end
+
+ it { expect(subject.attachment_color).to eq('danger') }
+ end
+ end
end
diff --git a/spec/models/integrations/chat_message/push_message_spec.rb b/spec/models/integrations/chat_message/push_message_spec.rb
index 5c9c5c64d7e..a9d0f801406 100644
--- a/spec/models/integrations/chat_message/push_message_spec.rb
+++ b/spec/models/integrations/chat_message/push_message_spec.rb
@@ -214,4 +214,10 @@ RSpec.describe Integrations::ChatMessage::PushMessage do
end
end
end
+
+ describe '#attachment_color' do
+ it 'returns the correct color' do
+ expect(subject.attachment_color).to eq('#345')
+ end
+ end
end
diff --git a/spec/models/integrations/discord_spec.rb b/spec/models/integrations/discord_spec.rb
index 7ab7308ac1c..76b5e89d04f 100644
--- a/spec/models/integrations/discord_spec.rb
+++ b/spec/models/integrations/discord_spec.rb
@@ -77,7 +77,7 @@ RSpec.describe Integrations::Discord, feature_category: :integrations do
icon_url: start_with('https://www.gravatar.com/avatar/'),
name: user.name
),
- color: 16543014,
+ color: 3359829,
timestamp: Time.now.utc.iso8601
)
end
diff --git a/spec/presenters/blob_presenter_spec.rb b/spec/presenters/blob_presenter_spec.rb
index a249597e900..eed39c7a404 100644
--- a/spec/presenters/blob_presenter_spec.rb
+++ b/spec/presenters/blob_presenter_spec.rb
@@ -56,31 +56,43 @@ RSpec.describe BlobPresenter do
end
context 'when blob has ref_type' do
- before do
- blob.ref_type = 'heads'
- end
+ %w[heads tags].each do |ref_type|
+ context "when ref_type is #{ref_type}" do
+ before do
+ blob.ref_type = ref_type
+ end
- describe '#web_url' do
- it { expect(presenter.web_url).to eq("http://localhost/#{project.full_path}/-/blob/#{ref}/#{path}?ref_type=heads") }
- end
+ describe '#web_url' do
+ it { expect(presenter.web_url).to eq("http://localhost/#{project.full_path}/-/blob/#{ref}/#{path}?ref_type=#{ref_type}") }
+ end
- describe '#web_path' do
- it { expect(presenter.web_path).to eq("/#{project.full_path}/-/blob/#{ref}/#{path}?ref_type=heads") }
- end
+ describe '#web_path' do
+ it { expect(presenter.web_path).to eq("/#{project.full_path}/-/blob/#{ref}/#{path}?ref_type=#{ref_type}") }
+ end
- describe '#edit_blob_path' do
- it { expect(presenter.edit_blob_path).to eq("/#{project.full_path}/-/edit/#{ref}/#{path}?ref_type=heads") }
- end
+ describe '#edit_blob_path' do
+ it { expect(presenter.edit_blob_path).to eq("/#{project.full_path}/-/edit/#{ref}/#{path}?ref_type=#{ref_type}") }
+ end
- describe '#raw_path' do
- it { expect(presenter.raw_path).to eq("/#{project.full_path}/-/raw/#{ref}/#{path}?ref_type=heads") }
- end
+ describe '#raw_path' do
+ it { expect(presenter.raw_path).to eq("/#{project.full_path}/-/raw/#{ref}/#{path}?ref_type=#{ref_type}") }
+ end
- describe '#replace_path' do
- it { expect(presenter.replace_path).to eq("/#{project.full_path}/-/update/#{ref}/#{path}?ref_type=heads") }
- end
+ describe '#replace_path' do
+ it { expect(presenter.replace_path).to eq("/#{project.full_path}/-/update/#{ref}/#{path}?ref_type=#{ref_type}") }
+ end
- it_behaves_like '#can_current_user_push_to_branch?'
+ describe '#history_path' do
+ it { expect(presenter.history_path).to eq("/#{project.full_path}/-/commits/#{ref}/#{path}?ref_type=#{ref_type}") }
+ end
+
+ describe '#blame_path' do
+ it { expect(presenter.blame_path).to eq("/#{project.full_path}/-/blame/#{ref}/#{path}?ref_type=#{ref_type}") }
+ end
+
+ it_behaves_like '#can_current_user_push_to_branch?'
+ end
+ end
end
describe '#can_modify_blob?' do
diff --git a/spec/requests/oauth/tokens_controller_spec.rb b/spec/requests/oauth/tokens_controller_spec.rb
index bde0e7517cf..aaacfce0ce8 100644
--- a/spec/requests/oauth/tokens_controller_spec.rb
+++ b/spec/requests/oauth/tokens_controller_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe Oauth::TokensController, feature_category: :system_access do
describe 'POST /oauth/token' do
- context 'for resource owner password credential flow' do
+ context 'for resource owner password credential flow', :aggregate_failures do
let_it_be(:password) { User.random_password }
def authenticate(with_password)
@@ -43,6 +43,19 @@ RSpec.describe Oauth::TokensController, feature_category: :system_access do
expect(user.reload.failed_attempts).to eq(0)
end
end
+
+ context "when the user's password is automatically set" do
+ let_it_be(:user) { create(:user, password_automatically_set: true) }
+
+ it 'fails to authenticate and does not call GitLab::Auth even when using the correct password' do
+ expect(::Gitlab::Auth).not_to receive(:find_with_user_password)
+
+ authenticate(password)
+
+ expect(response).to have_gitlab_http_status(:bad_request)
+ expect(user.reload.failed_attempts).to eq(0)
+ end
+ end
end
end
diff --git a/spec/scripts/changed-feature-flags_spec.rb b/spec/scripts/changed-feature-flags_spec.rb
deleted file mode 100644
index f1e381b0656..00000000000
--- a/spec/scripts/changed-feature-flags_spec.rb
+++ /dev/null
@@ -1,168 +0,0 @@
-# frozen_string_literal: true
-
-require 'fast_spec_helper'
-require 'tmpdir'
-
-load File.expand_path('../../scripts/changed-feature-flags', __dir__)
-
-RSpec.describe 'scripts/changed-feature-flags' do
- describe GetFeatureFlagsFromFiles do
- let!(:feature_flag_definition1) do
- file = File.open(File.join(ff_dir, "#{file_name1}.yml"), 'w+')
- file.write(<<~YAML)
- ---
- name: foo_flag
- default_enabled: true
- YAML
- file.rewind
- file
- end
-
- let!(:feature_flag_definition2) do
- file = File.open(File.join(ff_dir, "#{file_name2}.yml"), 'w+')
- file.write(<<~YAML)
- ---
- name: bar_flag
- default_enabled: false
- YAML
- file.rewind
- file
- end
-
- let!(:feature_flag_diff1) do
- FileUtils.mkdir_p(File.join(diffs_dir, ff_sub_dir))
- file = File.open(File.join(diffs_dir, ff_sub_dir, "#{file_name1}.yml.diff"), 'w+')
- file.write(<<~YAML)
- @@ -5,4 +5,4 @@
- name: foo_flag
- -default_enabled: false
- +default_enabled: true
- YAML
- file.rewind
- file
- end
-
- let!(:feature_flag_diff2) do
- FileUtils.mkdir_p(File.join(diffs_dir, ff_sub_dir))
- file = File.open(File.join(diffs_dir, ff_sub_dir, "#{file_name2}.yml.diff"), 'w+')
- file.write(<<~YAML)
- @@ -0,0 +0,0 @@
- name: bar_flag
- -default_enabled: true
- +default_enabled: false
- YAML
- file.rewind
- file
- end
-
- let!(:deleted_feature_flag_diff) do
- FileUtils.mkdir_p(File.join(diffs_dir, ff_sub_dir))
- file = File.open(File.join(diffs_dir, ff_sub_dir, "foobar_ff_#{SecureRandom.hex(8)}.yml.deleted.diff"), 'w+')
- file.write(<<~YAML)
- @@ -0,0 +0,0 @@
- -name: foobar_flag
- -default_enabled: true
- YAML
- file.rewind
- file
- end
-
- before do
- allow(Dir).to receive(:pwd).and_return(Dir.tmpdir)
- end
-
- after do
- feature_flag_definition1.close
- feature_flag_definition2.close
- feature_flag_diff1.close
- feature_flag_diff2.close
- deleted_feature_flag_diff.close
- FileUtils.rm_r(ff_dir)
- FileUtils.rm_r(diffs_dir)
- end
-
- describe '.extracted_flags' do
- let(:file_name1) { "foo_ff_#{SecureRandom.hex(8)}" }
- let(:file_name2) { "bar_ff_#{SecureRandom.hex(8)}" }
- let(:ff_dir) { FileUtils.mkdir_p(File.join(Dir.tmpdir, ff_sub_dir)) }
- let(:diffs_dir) { FileUtils.mkdir_p(File.join(Dir.tmpdir, 'diffs')).first }
-
- shared_examples 'extract feature flags' do
- it 'returns feature flags on their own' do
- subject = described_class.new({ files: diffs_dir })
-
- expect(subject.extracted_flags.split(',')).to include('foo_flag', 'bar_flag')
- end
-
- it 'returns feature flags and their state as enabled' do
- subject = described_class.new({ files: diffs_dir, state: 'enabled' })
-
- expect(subject.extracted_flags.split(',')).to include('foo_flag=enabled', 'bar_flag=enabled')
- end
-
- it 'returns feature flags and their state as disabled' do
- subject = described_class.new({ files: diffs_dir, state: 'disabled' })
-
- expect(subject.extracted_flags.split(',')).to include('foo_flag=disabled', 'bar_flag=disabled')
- end
-
- it 'does not return feature flags when there are mixed deleted and non-deleted definition files' do
- subject = described_class.new({ files: diffs_dir, state: 'deleted' })
-
- expect(subject.extracted_flags).to eq('')
- end
- end
-
- context 'with definition files in the development directory' do
- let(:ff_sub_dir) { %w[feature_flags development] }
-
- it_behaves_like 'extract feature flags'
- end
-
- context 'with definition files in the ops directory' do
- let(:ff_sub_dir) { %w[feature_flags ops] }
-
- it_behaves_like 'extract feature flags'
- end
-
- context 'with definition files in the experiment directory' do
- let(:ff_sub_dir) { %w[feature_flags experiment] }
-
- it 'ignores the files' do
- subject = described_class.new({ files: diffs_dir })
-
- expect(subject.extracted_flags).to eq('')
- end
- end
-
- context 'with only deleted definition files' do
- let(:ff_sub_dir) { %w[feature_flags development] }
-
- before do
- feature_flag_diff1.close
- feature_flag_diff2.close
- FileUtils.rm_r(feature_flag_diff1)
- FileUtils.rm_r(feature_flag_diff2)
- end
-
- it 'returns feature flags and their state as deleted' do
- subject = described_class.new({ files: diffs_dir, state: 'deleted' })
-
- expect(subject.extracted_flags).to eq('foobar_flag=deleted')
- end
-
- it 'does not return feature flags when the desired state is enabled' do
- subject = described_class.new({ files: diffs_dir, state: 'enabled' })
-
- expect(subject.extracted_flags).to eq('')
- end
-
- it 'does not return feature flags when the desired state is disabled' do
- subject = described_class.new({ files: diffs_dir, state: 'disabled' })
-
- expect(subject.extracted_flags).to eq('')
- end
- end
- end
- end
-end