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
Show 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
...
@@ -31,9 +31,7 @@ class Projects::BlobController < Projects::ApplicationController
before_action
:editor_variables
,
except:
[
:show
,
:preview
,
:diff
]
before_action
:editor_variables
,
except:
[
:show
,
:preview
,
:diff
]
before_action
:validate_diff_params
,
only: :diff
before_action
:validate_diff_params
,
only: :diff
before_action
:set_last_commit_sha
,
only:
[
:edit
,
:update
]
before_action
:set_last_commit_sha
,
only:
[
:edit
,
:update
]
before_action
only: :new
do
before_action
:record_experiment
,
only: :new
record_experiment_user
(
:ci_syntax_templates
,
namespace_id:
@project
.
namespace_id
)
if
params
[
:file_name
]
==
@project
.
ci_config_path_or_default
end
track_redis_hll_event
:create
,
:update
,
name:
'g_edit_by_sfe'
,
feature: :track_editor_edit_actions
,
feature_default_enabled:
true
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
...
@@ -263,4 +261,10 @@ class Projects::BlobController < Projects::ApplicationController
def
visitor_id
def
visitor_id
current_user
&
.
id
current_user
&
.
id
end
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
end
app/models/namespace.rb
View file @
adca842a
...
@@ -453,6 +453,10 @@ class Namespace < ApplicationRecord
...
@@ -453,6 +453,10 @@ class Namespace < ApplicationRecord
!
has_parent?
!
has_parent?
end
end
def
recent?
created_at
>=
90
.
days
.
ago
end
private
private
def
all_projects_with_pages
def
all_projects_with_pages
...
...
app/services/ci/create_pipeline_service.rb
View file @
adca842a
...
@@ -122,7 +122,9 @@ module Ci
...
@@ -122,7 +122,9 @@ module Ci
end
end
def
record_conversion_event
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
end
def
create_namespace_onboarding_action
def
create_namespace_onboarding_action
...
...
app/views/projects/blob/_template_selectors.html.haml
View file @
adca842a
...
@@ -11,7 +11,7 @@
...
@@ -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
)
}
}
)
=
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
#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
)
}
}
)
=
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
.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
)
}
}
)
=
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
.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
name
:
ci_syntax_templates_
b_
experiment_percentage
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/
48141
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/
53479
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/
281057
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/
300993
milestone
:
'
13.8'
milestone
:
"
13.9"
type
:
experiment
type
:
experiment
group
:
group::activation
group
:
group::activation
default_enabled
:
false
default_enabled
:
false
lib/gitlab/experimentation.rb
View file @
adca842a
...
@@ -88,7 +88,7 @@ module Gitlab
...
@@ -88,7 +88,7 @@ module Gitlab
trial_during_signup:
{
trial_during_signup:
{
tracking_category:
'Growth::Conversion::Experiment::TrialDuringSignup'
tracking_category:
'Growth::Conversion::Experiment::TrialDuringSignup'
},
},
ci_syntax_templates:
{
ci_syntax_templates
_b
:
{
tracking_category:
'Growth::Activation::Experiment::CiSyntaxTemplates'
,
tracking_category:
'Growth::Activation::Experiment::CiSyntaxTemplates'
,
rollout_strategy: :user
rollout_strategy: :user
},
},
...
...
spec/controllers/projects/blob_controller_spec.rb
View file @
adca842a
...
@@ -20,8 +20,8 @@ RSpec.describe Projects::BlobController do
...
@@ -20,8 +20,8 @@ RSpec.describe Projects::BlobController do
project
.
add_maintainer
(
user
)
project
.
add_maintainer
(
user
)
sign_in
(
user
)
sign_in
(
user
)
stub_experiment
(
ci_syntax_templates:
experiment_active
)
stub_experiment
(
ci_syntax_templates
_b
:
experiment_active
)
stub_experiment_for_subject
(
ci_syntax_templates:
in_experiment_group
)
stub_experiment_for_subject
(
ci_syntax_templates
_b
:
in_experiment_group
)
end
end
context
'when the experiment is not active'
do
context
'when the experiment is not active'
do
...
@@ -35,25 +35,26 @@ RSpec.describe Projects::BlobController do
...
@@ -35,25 +35,26 @@ RSpec.describe Projects::BlobController do
end
end
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
(
:experiment_active
)
{
true
}
context
'when the user is in the control group'
do
let
(
:in_experiment_group
)
{
false
}
let
(
:in_experiment_group
)
{
false
}
it
'records the experiment user in the control group'
do
it
'records the experiment user in the control group'
do
expect
(
Experiment
).
to
receive
(
:add_user
)
expect
(
Experiment
).
to
receive
(
:add_user
)
.
with
(
:ci_syntax_templates
,
:control
,
user
,
namespace_id:
project
.
namespace_id
)
.
with
(
:ci_syntax_templates_b
,
:control
,
user
,
namespace_id:
project
.
namespace_id
)
request
request
end
end
end
end
context
'when the experiment is active and the user is in the experimental group'
do
context
'when the user is in the experimental group'
do
let
(
:experiment_active
)
{
true
}
let
(
:in_experiment_group
)
{
true
}
let
(
:in_experiment_group
)
{
true
}
it
'records the experiment user in the experimental group'
do
it
'records the experiment user in the experimental group'
do
expect
(
Experiment
).
to
receive
(
:add_user
)
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
request
end
end
...
@@ -64,7 +65,7 @@ RSpec.describe Projects::BlobController do
...
@@ -64,7 +65,7 @@ RSpec.describe Projects::BlobController do
it
'records the experiment user in the experimental group'
do
it
'records the experiment user in the experimental group'
do
expect
(
Experiment
).
to
receive
(
:add_user
)
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
request
end
end
...
@@ -79,6 +80,19 @@ RSpec.describe Projects::BlobController do
...
@@ -79,6 +80,19 @@ RSpec.describe Projects::BlobController do
request
request
end
end
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
end
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'
...
@@ -5,11 +5,13 @@ require 'spec_helper'
RSpec
.
describe
'Projects > Files > User wants to add a .gitlab-ci.yml file'
do
RSpec
.
describe
'Projects > Files > User wants to add a .gitlab-ci.yml file'
do
include
Spec
::
Support
::
Helpers
::
Features
::
EditorLiteSpecHelpers
include
Spec
::
Support
::
Helpers
::
Features
::
EditorLiteSpecHelpers
let_it_be
(
:namespace
)
{
create
(
:namespace
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
namespace:
namespace
)
}
before
do
before
do
project
=
create
(
:project
,
:repository
)
sign_in
project
.
owner
sign_in
project
.
owner
stub_experiment
(
ci_syntax_templates:
experiment_active
)
stub_experiment
(
ci_syntax_templates
_b
:
experiment_active
)
stub_experiment_for_subject
(
ci_syntax_templates:
in_experiment_group
)
stub_experiment_for_subject
(
ci_syntax_templates
_b
:
in_experiment_group
)
visit
project_new_blob_path
(
project
,
'master'
,
file_name:
'.gitlab-ci.yml'
)
visit
project_new_blob_path
(
project
,
'master'
,
file_name:
'.gitlab-ci.yml'
)
end
end
...
@@ -23,8 +25,10 @@ RSpec.describe 'Projects > Files > User wants to add a .gitlab-ci.yml file' do
...
@@ -23,8 +25,10 @@ RSpec.describe 'Projects > Files > User wants to add a .gitlab-ci.yml file' do
end
end
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
(
:experiment_active
)
{
true
}
context
'when the user is in the control group'
do
let
(
:in_experiment_group
)
{
false
}
let
(
:in_experiment_group
)
{
false
}
it
'does not show the "Learn CI/CD syntax" template dropdown'
do
it
'does not show the "Learn CI/CD syntax" template dropdown'
do
...
@@ -32,8 +36,7 @@ RSpec.describe 'Projects > Files > User wants to add a .gitlab-ci.yml file' do
...
@@ -32,8 +36,7 @@ RSpec.describe 'Projects > Files > User wants to add a .gitlab-ci.yml file' do
end
end
end
end
context
'when experiment is active and the user is in the experimental group'
do
context
'when the user is in the experimental group'
do
let
(
:experiment_active
)
{
true
}
let
(
:in_experiment_group
)
{
true
}
let
(
:in_experiment_group
)
{
true
}
it
'allows the user to pick a "Learn CI/CD syntax" template from the dropdown'
,
:js
do
it
'allows the user to pick a "Learn CI/CD syntax" template from the dropdown'
,
:js
do
...
@@ -53,5 +56,14 @@ RSpec.describe 'Projects > Files > User wants to add a .gitlab-ci.yml file' do
...
@@ -53,5 +56,14 @@ RSpec.describe 'Projects > Files > User wants to add a .gitlab-ci.yml file' do
expect
(
page
).
to
have_css
(
'.gitlab-ci-syntax-yml-selector .dropdown-toggle-text'
,
text:
'Learn CI/CD syntax'
)
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.'
)
expect
(
editor_get_value
).
to
have_content
(
'You can use artifacts to pass data to jobs in later stages.'
)
end
end
context
'when the group is created longer than 90 days ago'
do
let
(
:namespace
)
{
create
(
:namespace
,
created_at:
91
.
days
.
ago
)
}
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
end
end
spec/models/namespace_spec.rb
View file @
adca842a
...
@@ -1521,4 +1521,24 @@ RSpec.describe Namespace do
...
@@ -1521,4 +1521,24 @@ RSpec.describe Namespace do
end
end
end
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
end
spec/services/ci/create_pipeline_service_spec.rb
View file @
adca842a
...
@@ -101,7 +101,7 @@ RSpec.describe Ci::CreatePipelineService do
...
@@ -101,7 +101,7 @@ RSpec.describe Ci::CreatePipelineService do
describe
'recording a conversion event'
do
describe
'recording a conversion event'
do
it
'schedules a record conversion event worker'
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
pipeline
end
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