Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
adca842a
Commit
adca842a
authored
Feb 05, 2021
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ci_syntax_templates_b experiment
to replace ci_syntax_templates experiment
parent
f1df59c6
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
117 additions
and
61 deletions
+117
-61
app/controllers/projects/blob_controller.rb
app/controllers/projects/blob_controller.rb
+7
-3
app/models/namespace.rb
app/models/namespace.rb
+4
-0
app/services/ci/create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+3
-1
app/views/projects/blob/_template_selectors.html.haml
app/views/projects/blob/_template_selectors.html.haml
+1
-1
config/feature_flags/experiment/ci_syntax_templates_b_experiment_percentage.yml
...xperiment/ci_syntax_templates_b_experiment_percentage.yml
+4
-4
lib/gitlab/experimentation.rb
lib/gitlab/experimentation.rb
+1
-1
spec/controllers/projects/blob_controller_spec.rb
spec/controllers/projects/blob_controller_spec.rb
+43
-29
spec/features/projects/files/gitlab_ci_syntax_yml_dropdown_spec.rb
...ures/projects/files/gitlab_ci_syntax_yml_dropdown_spec.rb
+33
-21
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+20
-0
spec/services/ci/create_pipeline_service_spec.rb
spec/services/ci/create_pipeline_service_spec.rb
+1
-1
No files found.
app/controllers/projects/blob_controller.rb
View file @
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'
,
feature: :track_editor_edit_actions
,
feature_default_enabled:
true
...
...
@@ -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
app/models/namespace.rb
View file @
adca842a
...
...
@@ -453,6 +453,10 @@ class Namespace < ApplicationRecord
!
has_parent?
end
def
recent?
created_at
>=
90
.
days
.
ago
end
private
def
all_projects_with_pages
...
...
app/services/ci/create_pipeline_service.rb
View file @
adca842a
...
...
@@ -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
...
...
app/views/projects/blob/_template_selectors.html.haml
View file @
adca842a
...
...
@@ -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
...
...
config/feature_flags/experiment/ci_syntax_templates_experiment_percentage.yml
→
config/feature_flags/experiment/ci_syntax_templates_
b_
experiment_percentage.yml
View file @
adca842a
---
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
lib/gitlab/experimentation.rb
View file @
adca842a
...
...
@@ -88,7 +88,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
},
...
...
spec/controllers/projects/blob_controller_spec.rb
View file @
adca842a
...
...
@@ -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
...
...
spec/features/projects/files/gitlab_ci_syntax_yml_dropdown_spec.rb
View file @
adca842a
...
...
@@ -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
spec/models/namespace_spec.rb
View file @
adca842a
...
...
@@ -1521,4 +1521,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
spec/services/ci/create_pipeline_service_spec.rb
View file @
adca842a
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment