gitlab-qa 8.4.2 → 8.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,77 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'open3'
4
- require 'active_support/core_ext/string/filters'
5
-
6
- module Gitlab
7
- module QA
8
- module Docker
9
- class Shellout
10
- using Rainbow
11
-
12
- StatusError = Class.new(StandardError)
13
-
14
- def initialize(command)
15
- @command = command
16
- @output = []
17
- @logger = Runtime::Logger.logger
18
- end
19
-
20
- attr_reader :command, :output
21
-
22
- def execute! # rubocop:disable Metrics/AbcSize
23
- raise StatusError, 'Command already executed' if output.any?
24
-
25
- logger.info("Docker shell command: `#{command.mask_secrets.cyan}`")
26
-
27
- Open3.popen2e(@command.to_s) do |_in, out, wait|
28
- out.each do |line|
29
- output.push(line)
30
-
31
- if stream_progress
32
- print "."
33
- elsif command.stream_output
34
- puts line
35
- end
36
-
37
- yield line, wait if block_given?
38
- end
39
- puts if stream_progress && !output.empty?
40
-
41
- fail! if wait.value.exited? && wait.value.exitstatus.nonzero?
42
-
43
- logger.debug("Docker shell command output:\n#{string_output}") unless command.stream_output || output.empty?
44
- end
45
-
46
- string_output
47
- end
48
-
49
- private
50
-
51
- attr_reader :logger
52
-
53
- # Raise error and print output to error log level
54
- #
55
- # @return [void]
56
- def fail!
57
- logger.error("Docker shell command output:\n#{string_output}") unless command.stream_output
58
- raise StatusError, "Docker command `#{command.mask_secrets.truncate(100)}` failed! " + "✘".red
59
- end
60
-
61
- # Stream only command execution progress and log output when command finished
62
- #
63
- # @return [Boolean]
64
- def stream_progress
65
- !(Runtime::Env.ci || command.stream_output)
66
- end
67
-
68
- # Stringified command output
69
- #
70
- # @return [String]
71
- def string_output
72
- output.join.chomp
73
- end
74
- end
75
- end
76
- end
77
- end
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'json'
4
- require 'uri'
5
-
6
- module Gitlab
7
- module QA
8
- module Support
9
- class DevEEQAImage
10
- attr_reader :base_url
11
-
12
- DEV_ADDRESS = 'https://dev.gitlab.org'
13
- GITLAB_EE_QA_REPOSITORY_ID = 55
14
- QAImageNotFoundError = Class.new(StandardError)
15
-
16
- def initialize
17
- @base_url = "#{DEV_ADDRESS}/api/v4/projects/gitlab%2Fomnibus-gitlab/registry/repositories/#{GITLAB_EE_QA_REPOSITORY_ID}/tags?per_page=100"
18
-
19
- Runtime::Env.require_qa_dev_access_token!
20
- end
21
-
22
- def retrieve_image_from_container_registry!(revision)
23
- request_url = base_url
24
-
25
- begin
26
- response = api_get!(URI.parse(request_url))
27
- tags = JSON.parse(response.body)
28
-
29
- matching_qa_image_tag = find_matching_qa_image_tag(tags, revision)
30
- return matching_qa_image_tag['location'] if matching_qa_image_tag
31
-
32
- request_url = next_page_url_from_response(response)
33
- end while request_url
34
-
35
- raise QAImageNotFoundError, "No `gitlab-ee-qa` image could be found for the revision `#{revision}`."
36
- end
37
-
38
- private
39
-
40
- def api_get!(uri)
41
- Support::GetRequest.new(uri, Runtime::Env.qa_dev_access_token).execute!
42
- end
43
-
44
- def next_page_url_from_response(response)
45
- response['x-next-page'].to_s != '' ? "#{base_url}&page=#{response['x-next-page']}" : nil
46
- end
47
-
48
- def find_matching_qa_image_tag(tags, revision)
49
- tags.find { |tag| tag['name'].end_with?(revision) }
50
- end
51
- end
52
- end
53
- end
54
- end