File: qa.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (123 lines) | stat: -rw-r--r-- 3,735 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# frozen_string_literal: true

Encoding.default_external = 'UTF-8'

require 'gitlab/utils/all'

require_relative '../lib/gitlab_edition'
require_relative '../config/initializers/0_inject_enterprise_edition_module'

require_relative '../config/bundler_setup'
Bundler.require(:default)

require 'securerandom'
require 'pathname'
require 'rainbow/refinement'
require 'active_support/core_ext/hash'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/module/delegation'
require 'active_support/parameter_filter'
module QA
  root = "#{__dir__}/qa"

  loader = Zeitwerk::Loader.new

  # require jh/qa/qa.rb first, to load JH module make prepend module works
  require '../jh/qa/qa' if GitlabEdition.jh?

  loader.push_dir(root, namespace: QA)

  loader.ignore("#{root}/factories")
  loader.ignore("#{root}/specs/features")
  loader.ignore("#{root}/specs/spec_helper.rb")

  # we need to eager load scenario classes
  # zeitwerk does not have option to configure what to eager load, so all exceptions have to be defined
  loader.do_not_eager_load("#{root}/ce")
  loader.do_not_eager_load("#{root}/ee")
  loader.do_not_eager_load("#{root}/flow")
  loader.do_not_eager_load("#{root}/git")
  loader.do_not_eager_load("#{root}/mobile")
  loader.do_not_eager_load("#{root}/page")
  loader.do_not_eager_load("#{root}/resource")
  loader.do_not_eager_load("#{root}/runtime")
  loader.do_not_eager_load("#{root}/service")
  loader.do_not_eager_load("#{root}/specs")
  loader.do_not_eager_load("#{root}/support")
  loader.do_not_eager_load("#{root}/tools")
  loader.do_not_eager_load("#{root}/vendor")

  loader.inflector.inflect(
    "ce" => "CE",
    "ee" => "EE",
    "api" => "API",
    "ssh" => "SSH",
    "ssh_key" => "SSHKey",
    "ssh_keys" => "SSHKeys",
    "ecdsa" => "ECDSA",
    "ed25519" => "ED25519",
    "graphql" => "GraphQL",
    "rsa" => "RSA",
    "ldap" => "LDAP",
    "ldap_tls" => "LDAPTLS",
    "ldap_no_tls" => "LDAPNoTLS",
    "ldap_no_server" => "LDAPNoServer",
    "rspec" => "RSpec",
    "web_ide" => "WebIDE",
    "ci_cd" => "CiCd",
    "project_imported_from_url" => "ProjectImportedFromURL",
    "repo_by_url" => "RepoByURL",
    "oauth" => "OAuth",
    "saml_sso_sign_in" => "SamlSSOSignIn",
    "group_saml" => "GroupSAML",
    "instance_saml" => "InstanceSAML",
    "saml_sso" => "SamlSSO",
    "ldap_sync" => "LDAPSync",
    "ip_address" => "IPAddress",
    "gpg" => "GPG",
    "user_gpg" => "UserGPG",
    "smtp" => "SMTP",
    "otp" => "OTP",
    "jira_api" => "JiraAPI",
    "registry_tls" => "RegistryTLS",
    "jetbrains" => "JetBrains",
    "vscode" => "VSCode",
    "registry_with_cdn" => "RegistryWithCDN",
    "fips" => "FIPS",
    "ci_cd_settings" => "CICDSettings",
    "cli" => "CLI"
  )

  loader.setup
  loader.eager_load
end

# Custom warning processing
Warning.process do |warning|
  QA::Runtime::Logger.warn(warning.strip)
end

# ignore faraday-multipart warning produced by octokit as it is only required for functionality we don't use
# see: https://github.com/octokit/octokit.rb/issues/1701
Warning.ignore(/To use multipart middleware with Faraday v2\.0/)
require "octokit"

# TODO: Temporary monkeypatch for broadcast logging
# Remove once activesupport is upgraded to 7.1
module Gitlab
  module QA
    class TestLogger
      # Combined logger instance
      #
      # @param [<Symbol, String>] level
      # @param [String] source
      # @return [ActiveSupport::Logger]
      def self.logger(level: :info, source: 'Gitlab QA', path: 'tmp')
        console_log = console_logger(level: level, source: source)
        file_log = file_logger(source: source, path: path)

        console_log.extend(ActiveSupport::Logger.broadcast(file_log))
      end
    end
  end
end