Dataset Viewer
Auto-converted to Parquet Duplicate
language
stringclasses
4 values
type
stringclasses
9 values
first_line
stringlengths
5
589k
contents
stringlengths
7
2.5M
filename
stringlengths
8
162
.js
function_declaration
function findSnapshotTestsFromDir(dir, results = []) {
function findSnapshotTestsFromDir(dir, results = []) { fs.readdirSync(dir).forEach((file) => { const fullPath = path.join(dir, file); if (fs.lstatSync(fullPath).isDirectory()) { findSnapshotTestsFromDir(fullPath, results); } else { const fileContent = fs.readFileSync(fullPath, 'utf8'); i...
jest.config.snapshots.js
.js
function_declaration
function saveArrayToFile(array, fileName) {
function saveArrayToFile(array, fileName) { fs.writeFile(fileName, JSON.stringify(array, null, 2), (err) => { if (err) { console.error(`Error writing Array data to ${fileName}:`, err); } }); }
jest.config.snapshots.js
.rb
module
module Tooling
module Tooling class MergeRequest GITLAB_API_URL_TEMPLATE = 'https://gitlab.com/api/v4/projects/%{project_path}/merge_requests' def self.for(branch:, project_path:) url = format(GITLAB_API_URL_TEMPLATE, { project_path: URI.encode_www_form_component(project_path) }) conn = Faraday.new(url) do |co...
tooling/merge_request.rb
.rb
class
class MergeRequest
class MergeRequest GITLAB_API_URL_TEMPLATE = 'https://gitlab.com/api/v4/projects/%{project_path}/merge_requests' def self.for(branch:, project_path:) url = format(GITLAB_API_URL_TEMPLATE, { project_path: URI.encode_www_form_component(project_path) }) conn = Faraday.new(url) do |conn| conn....
tooling/merge_request.rb
.rb
method
def initialize(merge_request)
def initialize(merge_request) @merge_request = merge_request end
tooling/merge_request.rb
.rb
method
def iid
def iid merge_request['iid'] end
tooling/merge_request.rb
.rb
module
module Tooling
module Tooling class MergeRequestRspecFailureRakeTask < RSpec::Core::RakeTask PROJECT_PATH = 'gitlab-org/gitlab' def run_task(_verbose) if pattern.empty? puts "No rspec failures in the merge request." return end super end def rspec_failures_on_merge_request t...
tooling/merge_request_rspec_failure_rake_task.rb
.rb
class
class MergeRequestRspecFailureRakeTask < RSpec::Core::RakeTask
class MergeRequestRspecFailureRakeTask < RSpec::Core::RakeTask PROJECT_PATH = 'gitlab-org/gitlab' def run_task(_verbose) if pattern.empty? puts "No rspec failures in the merge request." return end super end def rspec_failures_on_merge_request test_file_finder =...
tooling/merge_request_rspec_failure_rake_task.rb
.rb
method
def run_task(_verbose)
def run_task(_verbose) if pattern.empty? puts "No rspec failures in the merge request." return end super end
tooling/merge_request_rspec_failure_rake_task.rb
.rb
method
def rspec_failures_on_merge_request
def rspec_failures_on_merge_request test_file_finder = TestFileFinder::FileFinder.new test_file_finder.use TestFileFinder::MappingStrategies::GitlabMergeRequestRspecFailure.new(project_path: PROJECT_PATH, merge_request_iid: merge_request.iid) test_file_finder.test_files rescue TestFileFinder::Test...
tooling/merge_request_rspec_failure_rake_task.rb
.rb
method
def merge_request
def merge_request @merge_request ||= Tooling::MergeRequest.for(branch: current_branch, project_path: PROJECT_PATH) end
tooling/merge_request_rspec_failure_rake_task.rb
.rb
method
def current_branch
def current_branch @current_branch ||= `git branch --show-current`.strip end
tooling/merge_request_rspec_failure_rake_task.rb
.rb
module
module Quality
module Quality class TestLevel UnknownTestLevelError = Class.new(StandardError) TEST_LEVEL_FOLDERS = { migration: %w[ migrations ], background_migration: %w[ lib/gitlab/background_migration lib/ee/gitlab/background_migration ], frontend_fixture: %w[ ...
tooling/quality/test_level.rb
.rb
class
class TestLevel
class TestLevel UnknownTestLevelError = Class.new(StandardError) TEST_LEVEL_FOLDERS = { migration: %w[ migrations ], background_migration: %w[ lib/gitlab/background_migration lib/ee/gitlab/background_migration ], frontend_fixture: %w[ frontend/fixtu...
tooling/quality/test_level.rb
.rb
method
def initialize(prefixes = nil)
def initialize(prefixes = nil) @prefixes = Array(prefixes) @patterns = {} @regexps = {} end
tooling/quality/test_level.rb
.rb
method
def pattern(level)
def pattern(level) @patterns[level] ||= "#{prefixes_for_pattern}spec/#{folders_pattern(level)}{,/**/}*#{suffix(level)}".freeze # rubocop:disable Style/RedundantFreeze end
tooling/quality/test_level.rb
.rb
method
def regexp(level, start_with = false)
def regexp(level, start_with = false) @regexps[level] ||= Regexp.new("#{'^' if start_with}#{prefixes_for_regex}spec/#{folders_regex(level)}").freeze end
tooling/quality/test_level.rb
.rb
method
def level_for(file_path)
def level_for(file_path) case file_path # Detect background migration first since some are under # spec/lib/gitlab/background_migration # and tests under spec/lib are unit by default when regexp(:background_migration) :background_migration when regexp(:migration) ...
tooling/quality/test_level.rb
.rb
method
def prefixes_for_pattern
def prefixes_for_pattern return '' if prefixes.empty? "{#{prefixes.join(',')}}" end
tooling/quality/test_level.rb
.rb
method
def prefixes_for_regex
def prefixes_for_regex return '' if prefixes.empty? regex_prefix = prefixes.map { |prefix| Regexp.escape(prefix) }.join('|') "(#{regex_prefix})" end
tooling/quality/test_level.rb
.rb
method
def suffix(level)
def suffix(level) case level when :frontend_fixture ".rb" else "_spec.rb" end end
tooling/quality/test_level.rb
.rb
method
def folders_pattern(level)
def folders_pattern(level) case level when :all '**' else "{#{TEST_LEVEL_FOLDERS.fetch(level).join(',')}}" end end
tooling/quality/test_level.rb
.rb
method
def folders_regex(level)
def folders_regex(level) case level when :all '' else "(#{TEST_LEVEL_FOLDERS.fetch(level).join('|')})/" end end
tooling/quality/test_level.rb
.rb
module
module Docs
module Docs class DeprecationHandling def initialize(type) @type = type @yaml_glob_path = Rails.root.join("data/#{type.pluralize}/**/*.yml") @template_path = Rails.root.join("data/#{type.pluralize}/templates/_#{type}_template.md.erb") @milestone_key_name = "removal_milestone" end ...
tooling/docs/deprecation_handling.rb
.rb
class
class DeprecationHandling
class DeprecationHandling def initialize(type) @type = type @yaml_glob_path = Rails.root.join("data/#{type.pluralize}/**/*.yml") @template_path = Rails.root.join("data/#{type.pluralize}/templates/_#{type}_template.md.erb") @milestone_key_name = "removal_milestone" end def render ...
tooling/docs/deprecation_handling.rb
.rb
method
def initialize(type)
def initialize(type) @type = type @yaml_glob_path = Rails.root.join("data/#{type.pluralize}/**/*.yml") @template_path = Rails.root.join("data/#{type.pluralize}/templates/_#{type}_template.md.erb") @milestone_key_name = "removal_milestone" end
tooling/docs/deprecation_handling.rb
.rb
method
def render
def render source_file_paths = Rake::FileList.new(yaml_glob_path) do |fl| fl.exclude(/example\.yml$/) end entries = source_file_paths.flat_map do |file| YAML.safe_load_file(file, permitted_classes: [Date]) end entries = entries.sort_by { |d| d["title"] } milestones ...
tooling/docs/deprecation_handling.rb
.rb
method
def load_template(filename)
def load_template(filename) ERB.new(File.read(filename), trim_mode: '-') end
tooling/docs/deprecation_handling.rb
.rb
module
module Tooling
module Tooling module Graphql module Docs # We assume a few things about the schema. We use the graphql-ruby gem, which enforces: # - All mutations have a single input field named 'input' # - All mutations have a payload type, named after themselves # - All mutations have an input type, na...
tooling/graphql/docs/helper.rb
.rb
module
module Graphql
module Graphql module Docs # We assume a few things about the schema. We use the graphql-ruby gem, which enforces: # - All mutations have a single input field named 'input' # - All mutations have a payload type, named after themselves # - All mutations have an input type, named after themsel...
tooling/graphql/docs/helper.rb
.rb
module
module Docs
module Docs # We assume a few things about the schema. We use the graphql-ruby gem, which enforces: # - All mutations have a single input field named 'input' # - All mutations have a payload type, named after themselves # - All mutations have an input type, named after themselves # If thes...
tooling/graphql/docs/helper.rb
.rb
module
module Helper
module Helper include GraphQLDocs::Helpers include Gitlab::Utils::StrongMemoize def auto_generated_comment <<-MD.strip_heredoc --- stage: Manage group: Import and Integrate info: To determine the technical writer assigned to the Stage/Gr...
tooling/graphql/docs/helper.rb
.rb
module
module Tooling
module Tooling module Graphql module Docs # Gitlab renderer for graphql-docs. # Uses HAML templates to parse markdown and generate .md files. # It uses graphql-docs helpers and schema parser, more information in https://github.com/gjtorikian/graphql-docs. # # Arguments: # sch...
tooling/graphql/docs/renderer.rb
.rb
module
module Graphql
module Graphql module Docs # Gitlab renderer for graphql-docs. # Uses HAML templates to parse markdown and generate .md files. # It uses graphql-docs helpers and schema parser, more information in https://github.com/gjtorikian/graphql-docs. # # Arguments: # schema - the GraphQL...
tooling/graphql/docs/renderer.rb
.rb
module
module Docs
module Docs # Gitlab renderer for graphql-docs. # Uses HAML templates to parse markdown and generate .md files. # It uses graphql-docs helpers and schema parser, more information in https://github.com/gjtorikian/graphql-docs. # # Arguments: # schema - the GraphQL schema definition....
tooling/graphql/docs/renderer.rb
.rb
class
class Renderer
class Renderer include Tooling::Graphql::Docs::Helper attr_reader :schema def initialize(schema, output_dir:, template:) @output_dir = output_dir @template = template @layout = Haml::Engine.new(File.read(template)) @parsed_schema = GraphQLDocs::Parser.ne...
tooling/graphql/docs/renderer.rb
.rb
module
module Tooling
module Tooling module Image # Determine the tolerance till when we run pngquant in a loop TOLERANCE = 10000 def self.check_executables unless system('pngquant --version', out: File::NULL) warn( 'Error: pngquant executable was not detected in the system.', 'Download pngqu...
tooling/lib/tooling/image.rb
.rb
module
module Image
module Image # Determine the tolerance till when we run pngquant in a loop TOLERANCE = 10000 def self.check_executables unless system('pngquant --version', out: File::NULL) warn( 'Error: pngquant executable was not detected in the system.', 'Download pngquant at https://pn...
tooling/lib/tooling/image.rb
.rb
module
module Tooling
module Tooling class FindFilesUsingFeatureFlags include Helpers::PredictiveTestsHelper def initialize(changed_files_pathname:, feature_flags_base_folder: 'config/feature_flags') @changed_files_pathname = changed_files_pathname @changed_files = read_array_from_file(changed_files_p...
tooling/lib/tooling/find_files_using_feature_flags.rb
.rb
class
class FindFilesUsingFeatureFlags
class FindFilesUsingFeatureFlags include Helpers::PredictiveTestsHelper def initialize(changed_files_pathname:, feature_flags_base_folder: 'config/feature_flags') @changed_files_pathname = changed_files_pathname @changed_files = read_array_from_file(changed_files_pathname) @f...
tooling/lib/tooling/find_files_using_feature_flags.rb
.rb
method
def initialize(changed_files_pathname:, feature_flags_base_folder: 'config/feature_flags')
def initialize(changed_files_pathname:, feature_flags_base_folder: 'config/feature_flags') @changed_files_pathname = changed_files_pathname @changed_files = read_array_from_file(changed_files_pathname) @feature_flags_base_folders = folders_for_available_editions(feature_flags_base_fol...
tooling/lib/tooling/find_files_using_feature_flags.rb
.rb
method
def execute
def execute ff_union_regexp = Regexp.union(feature_flag_filenames) files_using_modified_feature_flags = ruby_files.select do |ruby_file| ruby_file if ff_union_regexp.match?(File.read(ruby_file)) end write_array_to_file(changed_files_pathname, files_using_modified_feature_flags.uniq) ...
tooling/lib/tooling/find_files_using_feature_flags.rb
.rb
method
def filter_files
def filter_files @_filter_files ||= changed_files.select do |filename| filename.start_with?(*feature_flags_base_folders) && File.basename(filename).end_with?('.yml') && File.exist?(filename) end end
tooling/lib/tooling/find_files_using_feature_flags.rb
.rb
method
def feature_flag_filenames
def feature_flag_filenames filter_files.map do |feature_flag_pathname| File.basename(feature_flag_pathname).delete_suffix('.yml') end end
tooling/lib/tooling/find_files_using_feature_flags.rb
.rb
method
def ruby_files
def ruby_files Dir["**/*.rb"].reject { |pathname| pathname.start_with?('vendor') } end
tooling/lib/tooling/find_files_using_feature_flags.rb
.rb
module
module Tooling
module Tooling class FindCodeowners def execute load_definitions.each do |section, group_defintions| puts section group_defintions.each do |group, list| print_entries(group, list[:entries]) if list[:entries] print_expanded_entries(group, list) if list[:allow] ...
tooling/lib/tooling/find_codeowners.rb
.rb
class
class FindCodeowners
class FindCodeowners def execute load_definitions.each do |section, group_defintions| puts section group_defintions.each do |group, list| print_entries(group, list[:entries]) if list[:entries] print_expanded_entries(group, list) if list[:allow] puts end ...
tooling/lib/tooling/find_codeowners.rb
.rb
method
def execute
def execute load_definitions.each do |section, group_defintions| puts section group_defintions.each do |group, list| print_entries(group, list[:entries]) if list[:entries] print_expanded_entries(group, list) if list[:allow] puts end end end
tooling/lib/tooling/find_codeowners.rb
.rb
method
def load_definitions
def load_definitions result = load_config result.each do |section, group_defintions| group_defintions.each do |group, definitions| definitions.transform_values! do |rules| case rules when Hash case rules[:keywords] when Array ...
tooling/lib/tooling/find_codeowners.rb
.rb
method
def load_config
def load_config config_path = "#{__dir__}/../../config/CODEOWNERS.yml" YAML.safe_load_file(config_path, symbolize_names: true) end
tooling/lib/tooling/find_codeowners.rb
.rb
method
def path_matches?(pattern, path)
def path_matches?(pattern, path) # `FNM_DOTMATCH` makes sure we also match files starting with a `.` # `FNM_PATHNAME` makes sure ** matches path separators flags = ::File::FNM_DOTMATCH | ::File::FNM_PATHNAME # BEGIN extension flags |= ::File::FNM_EXTGLOB # END extension ::Fil...
tooling/lib/tooling/find_codeowners.rb
.rb
method
def normalize_pattern(pattern)
def normalize_pattern(pattern) # Remove `\` when escaping `\#` pattern = pattern.sub(/\A\\#/, '#') # Replace all whitespace preceded by a \ with a regular whitespace pattern = pattern.gsub(/\\\s+/, ' ') return '/**/*' if pattern == '*' unless pattern.start_with?('/') patter...
tooling/lib/tooling/find_codeowners.rb
.rb
method
def consolidate_paths(matched_files)
def consolidate_paths(matched_files) matched_files.group_by { |file| File.dirname(file) }.flat_map do |dir, files| # First line is the dir itself if find_dir_maxdepth_1(dir).lines.drop(1).sort == files.sort "#{dir}\n" else files end end.sort end
tooling/lib/tooling/find_codeowners.rb
.rb
method
def print_entries(group, entries)
def print_entries(group, entries) entries.each do |entry| puts "#{entry} #{group}" end end
tooling/lib/tooling/find_codeowners.rb
.rb
method
def print_expanded_entries(group, list)
def print_expanded_entries(group, list) matched_files = git_ls_files.each_line.select do |line| list[:allow].find do |pattern| path = "/#{line.chomp}" path_matches?(pattern, path) && ( list[:deny].nil? || list[:deny].none? { |pattern| path_match...
tooling/lib/tooling/find_codeowners.rb
.rb
method
def find_dir_maxdepth_1(dir)
def find_dir_maxdepth_1(dir) `find #{dir} -maxdepth 1` end
tooling/lib/tooling/find_codeowners.rb
.rb
method
def git_ls_files
def git_ls_files @git_ls_files ||= `git ls-files` end
tooling/lib/tooling/find_codeowners.rb
.rb
module
module Tooling
module Tooling class TestMapGenerator def initialize @mapping = Hash.new { |h, k| h[k] = Set.new } end def parse(yaml_files) Array(yaml_files).each do |yaml_file| data = File.read(yaml_file) metadata, example_groups = data.split("---\n").reject(&:empty?).map do |yml| ...
tooling/lib/tooling/test_map_generator.rb
.rb
class
class TestMapGenerator
class TestMapGenerator def initialize @mapping = Hash.new { |h, k| h[k] = Set.new } end def parse(yaml_files) Array(yaml_files).each do |yaml_file| data = File.read(yaml_file) metadata, example_groups = data.split("---\n").reject(&:empty?).map do |yml| YAML.safe_load(y...
tooling/lib/tooling/test_map_generator.rb
.rb
method
def initialize
def initialize @mapping = Hash.new { |h, k| h[k] = Set.new } end
tooling/lib/tooling/test_map_generator.rb
.rb
method
def parse(yaml_files)
def parse(yaml_files) Array(yaml_files).each do |yaml_file| data = File.read(yaml_file) metadata, example_groups = data.split("---\n").reject(&:empty?).map do |yml| YAML.safe_load(yml, permitted_classes: [Symbol]) end if example_groups.nil? puts "No examples in...
tooling/lib/tooling/test_map_generator.rb
.rb
method
def mapping
def mapping @mapping.transform_values { |set| set.to_a } end
tooling/lib/tooling/test_map_generator.rb
.rb
method
def strip_example_uid(example_id)
def strip_example_uid(example_id) example_id.gsub(/\[.+\]/, '') end
tooling/lib/tooling/test_map_generator.rb
.rb
module
module Tooling
module Tooling class KubernetesClient K8S_ALLOWED_NAMESPACES_REGEX = /^review-(?!apps).+/ CommandFailedError = Class.new(StandardError) def cleanup_namespaces_by_created_at(created_before:) stale_namespaces = namespaces_created_before(created_before: created_before) # `kubectl` doe...
tooling/lib/tooling/kubernetes_client.rb
.rb
class
class KubernetesClient
class KubernetesClient K8S_ALLOWED_NAMESPACES_REGEX = /^review-(?!apps).+/ CommandFailedError = Class.new(StandardError) def cleanup_namespaces_by_created_at(created_before:) stale_namespaces = namespaces_created_before(created_before: created_before) # `kubectl` doesn't allow us to ...
tooling/lib/tooling/kubernetes_client.rb
.rb
method
def cleanup_namespaces_by_created_at(created_before:)
def cleanup_namespaces_by_created_at(created_before:) stale_namespaces = namespaces_created_before(created_before: created_before) # `kubectl` doesn't allow us to filter namespaces with a regexp. We therefore do the filtering in Ruby. review_apps_stale_namespaces = stale_namespaces.select { |ns| K8S_...
tooling/lib/tooling/kubernetes_client.rb
.rb
method
def delete_namespaces(namespaces)
def delete_namespaces(namespaces) return if namespaces.any? { |ns| !K8S_ALLOWED_NAMESPACES_REGEX.match?(ns) } run_command("kubectl delete namespace --now --ignore-not-found #{namespaces.join(' ')}") end
tooling/lib/tooling/kubernetes_client.rb
.rb
method
def delete_namespaces_by_exact_names(resource_names:, wait:)
def delete_namespaces_by_exact_names(resource_names:, wait:) command = [ 'delete', 'namespace', '--now', '--ignore-not-found', %(--wait=#{wait}), resource_names.join(' ') ] run_command(command) end
tooling/lib/tooling/kubernetes_client.rb
.rb
method
def namespaces_created_before(created_before:)
def namespaces_created_before(created_before:) response = run_command("kubectl get namespace --all-namespaces --sort-by='{.metadata.creationTimestamp}' -o json") items = JSON.parse(response)['items'] # rubocop:disable Gitlab/Json items.filter_map do |item| item_created_at = Time.parse(item.di...
tooling/lib/tooling/kubernetes_client.rb
.rb
method
def run_command(command)
def run_command(command) puts "Running command: `#{command}`" result = Gitlab::Popen.popen_with_detail([command]) if result.status.success? result.stdout.chomp.freeze else raise CommandFailedError, "The `#{command}` command failed (status: #{result.status}) with the following e...
tooling/lib/tooling/kubernetes_client.rb
.rb
module
module Knapsack
module Knapsack module Distributors class BaseDistributor # Refine https://github.com/KnapsackPro/knapsack/blob/v1.21.1/lib/knapsack/distributors/base_distributor.rb # to take in account the additional filtering we do for predictive jobs. module BaseDistributorWithTestFiltering attr_read...
tooling/lib/tooling/parallel_rspec_runner.rb
.rb
module
module Distributors
module Distributors class BaseDistributor # Refine https://github.com/KnapsackPro/knapsack/blob/v1.21.1/lib/knapsack/distributors/base_distributor.rb # to take in account the additional filtering we do for predictive jobs. module BaseDistributorWithTestFiltering attr_reader :filter_tests ...
tooling/lib/tooling/parallel_rspec_runner.rb
.rb
class
class BaseDistributor
class BaseDistributor # Refine https://github.com/KnapsackPro/knapsack/blob/v1.21.1/lib/knapsack/distributors/base_distributor.rb # to take in account the additional filtering we do for predictive jobs. module BaseDistributorWithTestFiltering attr_reader :filter_tests def initialize(a...
tooling/lib/tooling/parallel_rspec_runner.rb
.rb
module
module BaseDistributorWithTestFiltering
module BaseDistributorWithTestFiltering attr_reader :filter_tests def initialize(args = {}) super @filter_tests = args[:filter_tests] end def all_tests @all_tests ||= begin pattern_tests = Dir.glob(test_file_pattern).uniq if filte...
tooling/lib/tooling/parallel_rspec_runner.rb
.rb
class
class AllocatorBuilder
class AllocatorBuilder # Refine https://github.com/KnapsackPro/knapsack/blob/v1.21.1/lib/knapsack/allocator_builder.rb # to take in account the additional filtering we do for predictive jobs. module AllocatorBuilderWithTestFiltering attr_accessor :filter_tests def allocator Knapsack::Al...
tooling/lib/tooling/parallel_rspec_runner.rb
.rb
module
module AllocatorBuilderWithTestFiltering
module AllocatorBuilderWithTestFiltering attr_accessor :filter_tests def allocator Knapsack::Allocator.new({ report: Knapsack.report.open, test_file_pattern: test_file_pattern, ci_node_total: Knapsack::Config::Env.ci_node_total, ci_node_index: Knapsack::Confi...
tooling/lib/tooling/parallel_rspec_runner.rb
.rb
method
def allocator
def allocator Knapsack::Allocator.new({ report: Knapsack.report.open, test_file_pattern: test_file_pattern, ci_node_total: Knapsack::Config::Env.ci_node_total, ci_node_index: Knapsack::Config::Env.ci_node_index, # Additional argument filter_tests: filt...
tooling/lib/tooling/parallel_rspec_runner.rb
.rb
module
module Tooling
module Tooling class ParallelRSpecRunner include Tooling::Helpers::DurationFormatter # rubocop:disable Gitlab/Json -- standard JSON is sufficient def self.run(rspec_args: nil, filter_tests_file: nil) new(rspec_args: rspec_args, filter_tests_file: filter_tests_file).run end def initialize(f...
tooling/lib/tooling/parallel_rspec_runner.rb
.rb
class
class ParallelRSpecRunner
class ParallelRSpecRunner include Tooling::Helpers::DurationFormatter # rubocop:disable Gitlab/Json -- standard JSON is sufficient def self.run(rspec_args: nil, filter_tests_file: nil) new(rspec_args: rspec_args, filter_tests_file: filter_tests_file).run end def initialize(filter_tests_file:...
tooling/lib/tooling/parallel_rspec_runner.rb
.rb
method
def initialize(filter_tests_file: nil, rspec_args: nil)
def initialize(filter_tests_file: nil, rspec_args: nil) @filter_tests_file = filter_tests_file @rspec_args = rspec_args&.split(' ') || [] end
tooling/lib/tooling/parallel_rspec_runner.rb
.rb
method
def run
def run if ENV['GITLAB_CI'] && ENV['KNAPSACK_RSPEC_SUITE_REPORT_PATH'] expected_duration_report = parse_expected_duration_from_master_report knapsack_dir = File.dirname(ENV['KNAPSACK_RSPEC_SUITE_REPORT_PATH']) FileUtils.mkdir_p(knapsack_dir) File.write(File.join(knapsack_dir, 'node...
tooling/lib/tooling/parallel_rspec_runner.rb
.rb
method
def parse_expected_duration_from_master_report
def parse_expected_duration_from_master_report master_report = JSON.parse(File.read(ENV['KNAPSACK_RSPEC_SUITE_REPORT_PATH'])) return unless master_report Knapsack.logger.info "Parsing expected rspec suite duration..." duration_total = 0 expected_duration_report = {} node_tests.eac...
tooling/lib/tooling/parallel_rspec_runner.rb
.rb
method
def rspec_command
def rspec_command %w[bundle exec rspec].tap do |cmd| cmd.push(*rspec_args) cmd.push('--') cmd.push(*node_tests) end end
tooling/lib/tooling/parallel_rspec_runner.rb
.rb
method
def node_tests
def node_tests allocator.node_tests end
tooling/lib/tooling/parallel_rspec_runner.rb
.rb
method
def filter_tests
def filter_tests @filter_tests ||= filter_tests_file ? tests_from_file(filter_tests_file) : [] end
tooling/lib/tooling/parallel_rspec_runner.rb
.rb
method
def tests_from_file(filter_tests_file)
def tests_from_file(filter_tests_file) return [] unless File.exist?(filter_tests_file) File.read(filter_tests_file).split(' ') end
tooling/lib/tooling/parallel_rspec_runner.rb
.rb
method
def allocator
def allocator @allocator ||= Knapsack::AllocatorBuilder.new(Knapsack::Adapters::RSpecAdapter).tap do |builder| builder.filter_tests = filter_tests end.allocator end
tooling/lib/tooling/parallel_rspec_runner.rb
.rb
module
module Tooling
module Tooling module Debug class << self attr_accessor :debug end def print(*args) return unless Tooling::Debug.debug super(*args) end def puts(*args) return unless Tooling::Debug.debug super(*args) end end end
tooling/lib/tooling/debug.rb
.rb
module
module Debug
module Debug class << self attr_accessor :debug end def print(*args) return unless Tooling::Debug.debug super(*args) end def puts(*args) return unless Tooling::Debug.debug super(*args) end end
tooling/lib/tooling/debug.rb
.rb
method
def print(*args)
def print(*args) return unless Tooling::Debug.debug super(*args) end
tooling/lib/tooling/debug.rb
.rb
method
def puts(*args)
def puts(*args) return unless Tooling::Debug.debug super(*args) end
tooling/lib/tooling/debug.rb
.rb
module
module Tooling
module Tooling class JobMetrics attr_reader :metrics_file_path # @return [String] bucket for storing all CI job metrics INFLUX_CI_JOB_METRICS_BUCKET = "ci-job-metrics" ALLOWED_TYPES = %i[tag field].freeze def initialize(metrics_file_path: nil) metrics_file_path ||= ENV['JOB_METRICS_FILE_PA...
tooling/lib/tooling/job_metrics.rb
.rb
class
class JobMetrics
class JobMetrics attr_reader :metrics_file_path # @return [String] bucket for storing all CI job metrics INFLUX_CI_JOB_METRICS_BUCKET = "ci-job-metrics" ALLOWED_TYPES = %i[tag field].freeze def initialize(metrics_file_path: nil) metrics_file_path ||= ENV['JOB_METRICS_FILE_PATH'] raise ...
tooling/lib/tooling/job_metrics.rb
.rb
method
def initialize(metrics_file_path: nil)
def initialize(metrics_file_path: nil) metrics_file_path ||= ENV['JOB_METRICS_FILE_PATH'] raise "Please specify a path for the job metrics file." unless metrics_file_path @metrics_file_path = metrics_file_path end
tooling/lib/tooling/job_metrics.rb
.rb
method
def create_metrics_file
def create_metrics_file if valid_metrics_file? warn "A valid job metrics file already exists. We're not going to overwrite it." return end # We always first create tag metrics file with the default values persist_metrics_file(default_metrics) end
tooling/lib/tooling/job_metrics.rb
.rb
method
def update_field(name, value)
def update_field(name, value) name = name&.to_sym unless default_fields.key?(name) warn "[job-metrics] ERROR: Could not update field #{name}, as it is not part of the allowed fields." return end update_file(name, value, type: :field) end
tooling/lib/tooling/job_metrics.rb
.rb
method
def update_tag(name, value)
def update_tag(name, value) name = name&.to_sym unless default_tags.key?(name) warn "[job-metrics] ERROR: Could not update tag #{name}, as it is not part of the allowed tags." return end update_file(name, value, type: :tag) end
tooling/lib/tooling/job_metrics.rb
.rb
method
def update_file(name, value, type:)
def update_file(name, value, type:) unless valid_metrics_file? warn "[job-metrics] ERROR: Invalid job metrics file." return end metrics = load_metrics_file metrics[:"#{type}s"][name] = value persist_metrics_file(metrics) end
tooling/lib/tooling/job_metrics.rb
.rb
method
def push_metrics
def push_metrics unless valid_metrics_file? warn "[job-metrics] ERROR: Invalid job metrics file. We will not push the metrics to InfluxDB" return end update_field(:job_duration_seconds, (Time.now - job_start_time).to_i) metrics = load_metrics_file ALLOWED_TYPES.each do |t...
tooling/lib/tooling/job_metrics.rb
.rb
method
def load_metrics_file
def load_metrics_file return unless File.exist?(metrics_file_path) metrics_hash = JSON.parse(File.read(metrics_file_path), symbolize_names: true) # rubocop:disable Gitlab/Json # Inflate the timestamp from string to Time object metrics_hash[:time] = Time.parse(metrics_hash[:time]) if metrics_ha...
tooling/lib/tooling/job_metrics.rb
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
6