<commit_before>##
# This is a debug script to reproduce specific scenarios for scheduled jobs (https://gitlab.com/gitlab-org/gitlab-ce/issues/51352)
# By using this script, you don't need to setup GitLab runner.
# This script is specifically made for FE/UX engineers. They can quickly check how scheduled jobs behave.
#
# *** THIS IS NOT TO BE MERGED ***
#
# ### How to use ###
#
# ### Prerequisite
# 1. Create a project
# 1. Create a .gitlab-ci.yml with the following content
#
# ```
# stages:
# - build
# - test
# - production
# - rollout 10%
# - rollout 50%
# - rollout 100%
# - cleanup
# 
# build:
# stage: build
# script: sleep 1s
# 
# test:
# stage: test
# script: sleep 3s
# 
# rollout 10%:
# stage: rollout 10%
# script: date
# when: delayed
# start_in: 10 seconds
# allow_failure: false
# 
# rollout 50%:
# stage: rollout 50%
# script: date
# when: delayed
# start_in: 10 seconds
# allow_failure: false
# 
# rollout 100%:
# stage: rollout 100%
# script: date
# when: delayed
# start_in: 10 seconds
# allow_failure: false
# 
# cleanup:
# stage: cleanup
# script: date
# ```
#
# ### How to load this script
#
# ```
# bundle exec rails console                    # Login to rails console
# require '/path/to/scheduled_job_fixture.rb'  # Load this script
# ```
#
# ### Reproduce the scenario A) ~ Succeccfull timed incremantal rollout ~
#
# ````
# ScheduledJobFixture.new(29, 1).create_pipeline('master')
# ScheduledJobFixture.new(29, 1).finish_stage_until('test')  # Succeed 'build' and 'test' jobs. 'rollout 10%' job will be scheduled. See the pipeline page
# ScheduledJobFixture.new(29, 1).finish_stage_until('rollout 10%')  # Succeed `rollout 10%` job. 'rollout 50%' job will be scheduled.
# ScheduledJobFixture.new(29, 1).finish_stage_until('rollout 50%')  # Succeed `rollout 50%` job. 'rollout 100%' job will be scheduled.
# ScheduledJobFixture.new(29, 1).finish_stage_until('rollout 100%')  # Succeed `rollout 100%` job. 'cleanup' job will be scheduled.
# ScheduledJobFixture.new(29, 1).finish_stage_until('cleanup')  # Succeed `cleanup` job. The pipeline becomes green.
# ```
class ScheduledJobFixture
  attr_reader :project<commit_msg>Add placeholders to debug script example<commit_after>##
# This is a debug script to reproduce specific scenarios for scheduled jobs (https://gitlab.com/gitlab-org/gitlab-ce/issues/51352)
# By using this script, you don't need to setup GitLab runner.
# This script is specifically made for FE/UX engineers. They can quickly check how scheduled jobs behave.
#
# *** THIS IS NOT TO BE MERGED ***
#
# ### How to use ###
#
# ### Prerequisite
# 1. Create a project (for example with path `incremental-rollout`)
# 1. Create a .gitlab-ci.yml with the following content
#
=begin
stages:
- build
- test
- production
- rollout 10%
- rollout 50%
- rollout 100%
- cleanup

build:
  stage: build
  script: sleep 1s

test:
  stage: test
  script: sleep 3s

rollout 10%:
  stage: rollout 10%
  script: date
  when: delayed
  start_in: 10 seconds
  allow_failure: false

rollout 50%:
  stage: rollout 50%
  script: date
  when: delayed
  start_in: 10 seconds
  allow_failure: false

rollout 100%:
  stage: rollout 100%
  script: date
  when: delayed
  start_in: 10 seconds
  allow_failure: false

cleanup:
  stage: cleanup
  script: date
=end
#
# ### How to load this script
#
# ```
# bundle exec rails console                    # Login to rails console
# require '/path/to/scheduled_job_fixture.rb'  # Load this script
# ```
#
# ### Reproduce the scenario A) ~ Succeccfull timed incremantal rollout ~
#
# ````
# project = Project.find_by(path: 'incremental-rollout')
# user = User.find_by(username: 'root')
# fixture = ScheduledJobFixture.new(project.id, user.id)
#
# fixture.create_pipeline('master')
# fixture.finish_stage_until('test')  # Succeed 'build' and 'test' jobs. 'rollout 10%' job will be scheduled. See the pipeline page
# fixture.finish_stage_until('rollout 10%')  # Succeed `rollout 10%` job. 'rollout 50%' job will be scheduled.
# fixture.finish_stage_until('rollout 50%')  # Succeed `rollout 50%` job. 'rollout 100%' job will be scheduled.
# fixture.finish_stage_until('rollout 100%')  # Succeed `rollout 100%` job. 'cleanup' job will be scheduled.
# fixture.finish_stage_until('cleanup')  # Succeed `cleanup` job. The pipeline becomes green.
# ```
class ScheduledJobFixture
  attr_reader :project
{'fraction_non_alphanumeric': 0.12646585421936077, 'fraction_numerical': 0.030351805012646584, 'mean_word_length': 4.123674911660777, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4977549', 'n_tokens_mistral': 1584, 'n_tokens_neox': 1461, 'n_words': 472}