Commit b9e9bab8 authored by David Fernandez's avatar David Fernandez

Merge branch...

Merge branch '300993-engineering-empty-versatile-template-for-ci-ci_syntax_templates_b' into 'master'

Empty versatile template for CI - ci_syntax_templates_b

See merge request gitlab-org/gitlab!53479
parents 952f1c12 adca842a
......@@ -31,9 +31,7 @@ class Projects::BlobController < Projects::ApplicationController
before_action :editor_variables, except: [:show, :preview, :diff]
before_action :validate_diff_params, only: :diff
before_action :set_last_commit_sha, only: [:edit, :update]
before_action only: :new do
record_experiment_user(:ci_syntax_templates, namespace_id: @project.namespace_id) if params[:file_name] == @project.ci_config_path_or_default
end
before_action :record_experiment, only: :new
track_redis_hll_event :create, :update, name: 'g_edit_by_sfe'
......@@ -263,4 +261,10 @@ class Projects::BlobController < Projects::ApplicationController
def visitor_id
current_user&.id
end
def record_experiment
return unless params[:file_name] == @project.ci_config_path_or_default && @project.namespace.recent?
record_experiment_user(:ci_syntax_templates_b, namespace_id: @project.namespace_id)
end
end
......@@ -400,6 +400,10 @@ class Namespace < ApplicationRecord
!has_parent?
end
def recent?
created_at >= 90.days.ago
end
private
def all_projects_with_pages
......
......@@ -122,7 +122,9 @@ module Ci
end
def record_conversion_event
Experiments::RecordConversionEventWorker.perform_async(:ci_syntax_templates, current_user.id)
return unless project.namespace.recent?
Experiments::RecordConversionEventWorker.perform_async(:ci_syntax_templates_b, current_user.id)
end
def create_namespace_onboarding_action
......
......@@ -11,7 +11,7 @@
= dropdown_tag(_("Apply a template"), options: { toggle_class: 'js-metrics-dashboard-selector qa-metrics-dashboard-dropdown', dropdown_class: 'dropdown-menu-selectable', filter: true, placeholder: "Filter", data: { data: metrics_dashboard_ymls(@project) } } )
#gitlab-ci-yml-selector.gitlab-ci-yml-selector.js-gitlab-ci-yml-selector-wrap.js-template-selector-wrap.hidden
= dropdown_tag(_("Apply a template"), options: { toggle_class: 'js-gitlab-ci-yml-selector qa-gitlab-ci-yml-dropdown', dropdown_class: 'dropdown-menu-selectable', filter: true, placeholder: "Filter", data: { data: gitlab_ci_ymls(@project) } } )
- if experiment_enabled?(:ci_syntax_templates, subject: current_user)
- if experiment_enabled?(:ci_syntax_templates_b, subject: current_user) && @project.namespace.recent?
.gitlab-ci-syntax-yml-selector.js-gitlab-ci-syntax-yml-selector-wrap.js-template-selector-wrap.hidden
= dropdown_tag(_("Learn CI/CD syntax"), options: { toggle_class: 'js-gitlab-ci-syntax-yml-selector qa-gitlab-ci-syntax-yml-dropdown', dropdown_class: 'dropdown-menu-selectable', filter: true, placeholder: "Filter", data: { data: gitlab_ci_syntax_ymls(@project) } } )
.dockerfile-selector.js-dockerfile-selector-wrap.js-template-selector-wrap.hidden
......
---
name: ci_syntax_templates_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/48141
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/281057
milestone: '13.8'
name: ci_syntax_templates_b_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/53479
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/300993
milestone: "13.9"
type: experiment
group: group::activation
default_enabled: false
......@@ -81,7 +81,7 @@ module Gitlab
trial_during_signup: {
tracking_category: 'Growth::Conversion::Experiment::TrialDuringSignup'
},
ci_syntax_templates: {
ci_syntax_templates_b: {
tracking_category: 'Growth::Activation::Experiment::CiSyntaxTemplates',
rollout_strategy: :user
},
......
......@@ -20,8 +20,8 @@ RSpec.describe Projects::BlobController do
project.add_maintainer(user)
sign_in(user)
stub_experiment(ci_syntax_templates: experiment_active)
stub_experiment_for_subject(ci_syntax_templates: in_experiment_group)
stub_experiment(ci_syntax_templates_b: experiment_active)
stub_experiment_for_subject(ci_syntax_templates_b: in_experiment_group)
end
context 'when the experiment is not active' do
......@@ -35,48 +35,62 @@ RSpec.describe Projects::BlobController do
end
end
context 'when the experiment is active and the user is in the control group' do
context 'when the experiment is active' do
let(:experiment_active) { true }
let(:in_experiment_group) { false }
it 'records the experiment user in the control group' do
expect(Experiment).to receive(:add_user)
.with(:ci_syntax_templates, :control, user, namespace_id: project.namespace_id)
request
end
end
context 'when the user is in the control group' do
let(:in_experiment_group) { false }
context 'when the experiment is active and the user is in the experimental group' do
let(:experiment_active) { true }
let(:in_experiment_group) { true }
it 'records the experiment user in the experimental group' do
expect(Experiment).to receive(:add_user)
.with(:ci_syntax_templates, :experimental, user, namespace_id: project.namespace_id)
it 'records the experiment user in the control group' do
expect(Experiment).to receive(:add_user)
.with(:ci_syntax_templates_b, :control, user, namespace_id: project.namespace_id)
request
request
end
end
context 'when requesting a non default config file type' do
let(:file_name) { '.non_default_ci_config' }
let(:project) { create(:project, :public, :repository, ci_config_path: file_name) }
context 'when the user is in the experimental group' do
let(:in_experiment_group) { true }
it 'records the experiment user in the experimental group' do
expect(Experiment).to receive(:add_user)
.with(:ci_syntax_templates, :experimental, user, namespace_id: project.namespace_id)
.with(:ci_syntax_templates_b, :experimental, user, namespace_id: project.namespace_id)
request
end
end
context 'when requesting a different file type' do
let(:file_name) { '.gitignore' }
context 'when requesting a non default config file type' do
let(:file_name) { '.non_default_ci_config' }
let(:project) { create(:project, :public, :repository, ci_config_path: file_name) }
it 'does not record the experiment user' do
expect(Experiment).not_to receive(:add_user)
it 'records the experiment user in the experimental group' do
expect(Experiment).to receive(:add_user)
.with(:ci_syntax_templates_b, :experimental, user, namespace_id: project.namespace_id)
request
request
end
end
context 'when requesting a different file type' do
let(:file_name) { '.gitignore' }
it 'does not record the experiment user' do
expect(Experiment).not_to receive(:add_user)
request
end
end
context 'when the group is created longer than 90 days ago' do
before do
project.namespace.update_attribute(:created_at, 91.days.ago)
end
it 'does not record the experiment user' do
expect(Experiment).not_to receive(:add_user)
request
end
end
end
end
......
......@@ -5,11 +5,13 @@ require 'spec_helper'
RSpec.describe 'Projects > Files > User wants to add a .gitlab-ci.yml file' do
include Spec::Support::Helpers::Features::EditorLiteSpecHelpers
let_it_be(:namespace) { create(:namespace) }
let(:project) { create(:project, :repository, namespace: namespace) }
before do
project = create(:project, :repository)
sign_in project.owner
stub_experiment(ci_syntax_templates: experiment_active)
stub_experiment_for_subject(ci_syntax_templates: in_experiment_group)
stub_experiment(ci_syntax_templates_b: experiment_active)
stub_experiment_for_subject(ci_syntax_templates_b: in_experiment_group)
visit project_new_blob_path(project, 'master', file_name: '.gitlab-ci.yml')
end
......@@ -23,35 +25,45 @@ RSpec.describe 'Projects > Files > User wants to add a .gitlab-ci.yml file' do
end
end
context 'when experiment is active and the user is in the control group' do
context 'when experiment is active' do
let(:experiment_active) { true }
let(:in_experiment_group) { false }
it 'does not show the "Learn CI/CD syntax" template dropdown' do
expect(page).not_to have_css('.gitlab-ci-syntax-yml-selector')
context 'when the user is in the control group' do
let(:in_experiment_group) { false }
it 'does not show the "Learn CI/CD syntax" template dropdown' do
expect(page).not_to have_css('.gitlab-ci-syntax-yml-selector')
end
end
end
context 'when experiment is active and the user is in the experimental group' do
let(:experiment_active) { true }
let(:in_experiment_group) { true }
context 'when the user is in the experimental group' do
let(:in_experiment_group) { true }
it 'allows the user to pick a "Learn CI/CD syntax" template from the dropdown', :js do
expect(page).to have_css('.gitlab-ci-syntax-yml-selector')
it 'allows the user to pick a "Learn CI/CD syntax" template from the dropdown', :js do
expect(page).to have_css('.gitlab-ci-syntax-yml-selector')
find('.js-gitlab-ci-syntax-yml-selector').click
find('.js-gitlab-ci-syntax-yml-selector').click
wait_for_requests
wait_for_requests
within '.gitlab-ci-syntax-yml-selector' do
find('.dropdown-input-field').set('Artifacts example')
find('.dropdown-content .is-focused', text: 'Artifacts example').click
end
within '.gitlab-ci-syntax-yml-selector' do
find('.dropdown-input-field').set('Artifacts example')
find('.dropdown-content .is-focused', text: 'Artifacts example').click
wait_for_requests
expect(page).to have_css('.gitlab-ci-syntax-yml-selector .dropdown-toggle-text', text: 'Learn CI/CD syntax')
expect(editor_get_value).to have_content('You can use artifacts to pass data to jobs in later stages.')
end
wait_for_requests
context 'when the group is created longer than 90 days ago' do
let(:namespace) { create(:namespace, created_at: 91.days.ago) }
expect(page).to have_css('.gitlab-ci-syntax-yml-selector .dropdown-toggle-text', text: 'Learn CI/CD syntax')
expect(editor_get_value).to have_content('You can use artifacts to pass data to jobs in later stages.')
it 'does not show the "Learn CI/CD syntax" template dropdown' do
expect(page).not_to have_css('.gitlab-ci-syntax-yml-selector')
end
end
end
end
end
......@@ -1449,4 +1449,24 @@ RSpec.describe Namespace do
end
end
end
describe '#recent?' do
subject { namespace.recent? }
context 'when created more than 90 days ago' do
before do
namespace.update_attribute(:created_at, 91.days.ago)
end
it { is_expected.to be(false) }
end
context 'when created less than 90 days ago' do
before do
namespace.update_attribute(:created_at, 89.days.ago)
end
it { is_expected.to be(true) }
end
end
end
......@@ -101,7 +101,7 @@ RSpec.describe Ci::CreatePipelineService do
describe 'recording a conversion event' do
it 'schedules a record conversion event worker' do
expect(Experiments::RecordConversionEventWorker).to receive(:perform_async).with(:ci_syntax_templates, user.id)
expect(Experiments::RecordConversionEventWorker).to receive(:perform_async).with(:ci_syntax_templates_b, user.id)
pipeline
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment