Module: GitlabQuality::TestTooling::Runtime::Env
Constant Summary collapse
- ENV_VARIABLES =
{ 'CI_COMMIT_REF_NAME' => :ci_commit_ref_name, 'CI_JOB_ID' => :ci_job_id, 'CI_JOB_NAME' => :ci_job_name, 'CI_JOB_URL' => :ci_job_url, 'CI_JOB_STATUS' => :ci_job_status, 'CI_PIPELINE_ID' => :ci_pipeline_id, 'CI_PIPELINE_NAME' => :ci_pipeline_name, 'CI_PIPELINE_URL' => :ci_pipeline_url, 'CI_PROJECT_ID' => :ci_project_id, 'CI_PROJECT_NAME' => :ci_project_name, 'CI_PROJECT_PATH' => :ci_project_path, 'CI_PIPELINE_CREATED_AT' => :ci_pipeline_created_at, 'DEPLOY_VERSION' => :deploy_version, 'GITLAB_QA_ISSUE_URL' => :qa_issue_url, 'QA_GITLAB_CI_TOKEN' => :gitlab_ci_token }.freeze
Instance Method Summary collapse
- #ci_api_v4_url ⇒ Object
- #colorized_logs? ⇒ Boolean
- #default_branch ⇒ Object
- #deploy_environment ⇒ Object
- #gitlab_api_base ⇒ Object
- #gitlab_bot_username ⇒ Object
- #gitlab_graphql_api_base ⇒ Object
- #host_artifacts_dir ⇒ Object
- #log_level ⇒ Object
- #log_path ⇒ Object
- #pipeline_from_project_name ⇒ Object
- #qa_run_type ⇒ Object
- #run_id ⇒ Object
- #slack_alerts_channel ⇒ Object
Instance Method Details
#ci_api_v4_url ⇒ Object
53 54 55 |
# File 'lib/gitlab_quality/test_tooling/runtime/env.rb', line 53 def ci_api_v4_url env_var_value_if_defined('CI_API_V4_URL') || 'https://gitlab.com/api/v4' end |
#colorized_logs? ⇒ Boolean
77 78 79 |
# File 'lib/gitlab_quality/test_tooling/runtime/env.rb', line 77 def colorized_logs? enabled?(ENV.fetch('COLORIZED_LOGS', nil), default: false) end |
#default_branch ⇒ Object
49 50 51 |
# File 'lib/gitlab_quality/test_tooling/runtime/env.rb', line 49 def default_branch 'master' end |
#deploy_environment ⇒ Object
81 82 83 |
# File 'lib/gitlab_quality/test_tooling/runtime/env.rb', line 81 def deploy_environment env_var_value_if_defined('DEPLOY_ENVIRONMENT') || pipeline_from_project_name end |
#gitlab_api_base ⇒ Object
57 58 59 |
# File 'lib/gitlab_quality/test_tooling/runtime/env.rb', line 57 def gitlab_api_base env_var_value_if_defined('GITLAB_API_BASE') || ci_api_v4_url end |
#gitlab_bot_username ⇒ Object
41 42 43 |
# File 'lib/gitlab_quality/test_tooling/runtime/env.rb', line 41 def gitlab_bot_username env_var_value_if_defined('GITLAB_BOT_USERNAME') || 'gitlab-bot' end |
#gitlab_graphql_api_base ⇒ Object
61 62 63 |
# File 'lib/gitlab_quality/test_tooling/runtime/env.rb', line 61 def gitlab_graphql_api_base env_var_value_if_defined('GITLAB_GRAPHQL_API_BASE') end |
#host_artifacts_dir ⇒ Object
85 86 87 88 89 |
# File 'lib/gitlab_quality/test_tooling/runtime/env.rb', line 85 def host_artifacts_dir @host_artifacts_dir ||= File.join( env_var_value_if_defined('QA_ARTIFACTS_DIR') || '/tmp/gitlab-qa', Runtime::Env.run_id ) end |
#log_level ⇒ Object
37 38 39 |
# File 'lib/gitlab_quality/test_tooling/runtime/env.rb', line 37 def log_level env_var_value_if_defined('QA_LOG_LEVEL')&.upcase || 'INFO' end |
#log_path ⇒ Object
45 46 47 |
# File 'lib/gitlab_quality/test_tooling/runtime/env.rb', line 45 def log_path env_var_value_if_defined('QA_LOG_PATH') || host_artifacts_dir end |
#pipeline_from_project_name ⇒ Object
69 70 71 |
# File 'lib/gitlab_quality/test_tooling/runtime/env.rb', line 69 def pipeline_from_project_name %w[gitlab gitaly].any? { |str| ci_project_name.to_s.start_with?(str) } ? default_branch : ci_project_name end |
#qa_run_type ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/gitlab_quality/test_tooling/runtime/env.rb', line 91 def qa_run_type return env_var_value_if_defined('QA_RUN_TYPE') if env_var_value_valid?('QA_RUN_TYPE') live_envs = %w[staging staging-canary staging-ref canary preprod production] return unless live_envs.include?(ci_project_name) test_subset = if env_var_value_if_defined('SMOKE_ONLY') == 'true' 'sanity' else 'full' end "#{ci_project_name}-#{test_subset}" end |
#run_id ⇒ Object
73 74 75 |
# File 'lib/gitlab_quality/test_tooling/runtime/env.rb', line 73 def run_id @run_id ||= "gitlab-qa-run-#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}-#{SecureRandom.hex(4)}" end |
#slack_alerts_channel ⇒ Object
65 66 67 |
# File 'lib/gitlab_quality/test_tooling/runtime/env.rb', line 65 def slack_alerts_channel env_var_value_if_defined('SLACK_ALERTS_CHANNEL') || 'C09HQ5BN07J' # test-tooling-alerts channel ID end |