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>2021-07-20 12:55:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 12:55:51 +0300
commite8d2c2579383897a1dd7f9debd359abe8ae8373d (patch)
treec42be41678c2586d49a75cabce89322082698334 /app/experiments
parentfc845b37ec3a90aaa719975f607740c22ba6a113 (diff)
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'app/experiments')
-rw-r--r--app/experiments/application_experiment.rb53
-rw-r--r--app/experiments/new_project_readme_content_experiment.rb30
-rw-r--r--app/experiments/templates/new_project_readme_content/readme_advanced.md.tt90
-rw-r--r--app/experiments/templates/new_project_readme_content/readme_basic.md.tt3
4 files changed, 147 insertions, 29 deletions
diff --git a/app/experiments/application_experiment.rb b/app/experiments/application_experiment.rb
index 53ea8ea2d3a..4ebf4a80498 100644
--- a/app/experiments/application_experiment.rb
+++ b/app/experiments/application_experiment.rb
@@ -10,45 +10,49 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp
end
def publish(_result = nil)
- return unless should_track? # don't track events for excluded contexts
+ super
- record_experiment if @record # record the subject in the database if the context contains a namespace, group, project, actor or user
-
- track(:assignment) # track that we've assigned a variant for this context
-
- push_to_client
+ publish_to_client if should_track? # publish the experiment data to the client
+ publish_to_database if @record # publish the experiment context to the database
end
- # push the experiment data to the client
- def push_to_client
+ def publish_to_client
Gon.push({ experiment: { name => signature } }, true)
rescue NoMethodError
# means we're not in the request cycle, and can't add to Gon. Log a warning maybe?
end
- def track(action, **event_args)
- return unless should_track? # don't track events for excluded contexts
+ def publish_to_database
+ # if the context contains a namespace, group, project, user, or actor
+ value = context.value
+ subject = value[:namespace] || value[:group] || value[:project] || value[:user] || value[:actor]
+ return unless ExperimentSubject.valid_subject?(subject)
- # track the event, and mix in the experiment signature data
- Gitlab::Tracking.event(name, action.to_s, **event_args.merge(
- context: (event_args[:context] || []) << SnowplowTracker::SelfDescribingJson.new(
- 'iglu:com.gitlab/gitlab_experiment/jsonschema/1-0-0', signature
- )
- ))
+ variant = :experimental if @variant_name != :control
+ Experiment.add_subject(name, variant: variant || :control, subject: subject)
end
def record!
@record = true
end
- def exclude!
- @excluded = true
- end
-
def control_behavior
# define a default nil control behavior so we can omit it when not needed
end
+ # TODO: remove
+ # This is deprecated logic as of v0.6.0 and should eventually be removed, but
+ # needs to stay intact for actively running experiments. The new strategy
+ # utilizes Digest::SHA2, a secret seed, and generates a 64-byte string.
+ def key_for(source, seed = name)
+ source = source.keys + source.values if source.is_a?(Hash)
+
+ ingredients = Array(source).map { |v| identify(v) }
+ ingredients.unshift(seed)
+
+ Digest::MD5.hexdigest(ingredients.join('|'))
+ end
+
private
def feature_flag_name
@@ -58,13 +62,4 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp
def experiment_group?
Feature.enabled?(feature_flag_name, self, type: :experiment, default_enabled: :yaml)
end
-
- def record_experiment
- subject = context.value[:namespace] || context.value[:group] || context.value[:project] || context.value[:user] || context.value[:actor]
- return unless ExperimentSubject.valid_subject?(subject)
-
- variant = :experimental if @variant_name != :control
-
- Experiment.add_subject(name, variant: variant || :control, subject: subject)
- end
end
diff --git a/app/experiments/new_project_readme_content_experiment.rb b/app/experiments/new_project_readme_content_experiment.rb
new file mode 100644
index 00000000000..f86803db093
--- /dev/null
+++ b/app/experiments/new_project_readme_content_experiment.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+class NewProjectReadmeContentExperiment < ApplicationExperiment # rubocop:disable Gitlab/NamespacedClass
+ TEMPLATE_PATH = Rails.root.join('app', 'experiments', 'templates', 'new_project_readme_content')
+ include Rails.application.routes.url_helpers
+
+ def run_with(project, variant: nil)
+ @project = project
+ record!
+ run(variant)
+ end
+
+ def control_behavior
+ template('readme_basic.md')
+ end
+
+ def advanced_behavior
+ template('readme_advanced.md')
+ end
+
+ def redirect(to_url)
+ experiment_redirect_url(self, to_url)
+ end
+
+ private
+
+ def template(name)
+ ERB.new(File.read(TEMPLATE_PATH.join("#{name}.tt")), trim_mode: '<>').result(binding)
+ end
+end
diff --git a/app/experiments/templates/new_project_readme_content/readme_advanced.md.tt b/app/experiments/templates/new_project_readme_content/readme_advanced.md.tt
new file mode 100644
index 00000000000..70a32ba6f03
--- /dev/null
+++ b/app/experiments/templates/new_project_readme_content/readme_advanced.md.tt
@@ -0,0 +1,90 @@
+# <%= @project.name %>
+
+<%= @project.description %>
+
+
+## Getting started
+
+To make it easy for you to get started with GitLab, here's a list of recommended next steps.
+
+Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
+
+## Add your files
+
+- [ ] [Create](<%= redirect("https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file") %>) or [upload](<%= redirect("https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file") %>) files
+- [ ] [Add files using the command line](<%= redirect("https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line") %>) or push an existing Git repository with the following command:
+
+```
+cd existing_repo
+git remote add origin <%= @project.http_url_to_repo %>
+git branch -M <%= @project.default_branch_or_main %>
+git push -uf origin <%= @project.default_branch_or_main %>
+```
+
+## Integrate with your tools
+
+- [ ] [Set up project integrations](<%= redirect("https://docs.gitlab.com/ee/user/project/integrations/") %>)
+
+## Collaborate with your team
+
+- [ ] [Invite team members and collaborators](<%= redirect("https://docs.gitlab.com/ee/user/project/members/") %>)
+- [ ] [Create a new merge request](<%= redirect("https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html") %>)
+- [ ] [Automatically close issues from merge requests](<%= redirect("https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically") %>)
+- [ ] [Automatically merge when pipeline succeeds](<%= redirect("https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html") %>)
+
+## Test and Deploy
+
+Use the built-in continuous integration in GitLab.
+
+- [ ] [Get started with GitLab CI/CD](<%= redirect("https://docs.gitlab.com/ee/ci/quick_start/index.html") %>)
+- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](<%= redirect("https://docs.gitlab.com/ee/user/application_security/sast/") %>)
+
+***
+
+# Editing this README
+
+When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](<%= redirect("https://www.makeareadme.com/") %>) for this template.
+
+## Suggestions for a good README
+Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
+
+## Name
+Choose a self-explaining name for your project.
+
+## Description
+Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
+
+## Badges
+On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
+
+## Visuals
+Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
+
+## Installation
+Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
+
+## Usage
+Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
+
+## Support
+Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
+
+## Roadmap
+If you have ideas for releases in the future, it is a good idea to list them in the README.
+
+## Contributing
+State if you are open to contributions and what your requirements are for accepting them.
+
+For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
+
+You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
+
+## Authors and acknowledgment
+Show your appreciation to those who have contributed to the project.
+
+## License
+For open source projects, say how it is licensed.
+
+## Project status
+If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
+
diff --git a/app/experiments/templates/new_project_readme_content/readme_basic.md.tt b/app/experiments/templates/new_project_readme_content/readme_basic.md.tt
new file mode 100644
index 00000000000..1e68eaf2f05
--- /dev/null
+++ b/app/experiments/templates/new_project_readme_content/readme_basic.md.tt
@@ -0,0 +1,3 @@
+# <%= @project.name %>
+
+<%= @project.description %>