gitlab_quality-test_tooling 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc873ad79077521f3fc428ee0c71eceb10b6f03b14b002f4cb2519e974492902
4
- data.tar.gz: 4ff2af5013269670822407cc3300bca290920a38902d70410883dcca25d2d462
3
+ metadata.gz: d201b5e75d11490d7b8a3f7b3abdc883442487d07d19f9c5c7cf02577a867116
4
+ data.tar.gz: 0b50d503726912d587bb2b3d4bd1e1c2194b8f0773d2a37905afa0c66dfbbaee
5
5
  SHA512:
6
- metadata.gz: 19c0969b35e7c9d429d7a2bb0a46a514868e4947a29ce05c72492184f97e844afe54a7bcb2a4461b349993c593fffc21c9e6da45877c13498e1b71f3fd47d941
7
- data.tar.gz: e653c176e564bc51853f3e58cbe87ef599d14bb3a58bece011e0099201e212e3a55a9313cbb4f682748a6ea84faf4663fa7dee0c20efd510ad3137b8070f129a
6
+ metadata.gz: e5b8c615d62f29710c55a3d39373efb71cf1b7895d3b7ca08d6a4e0077e47b7a0c109f111716d49d7d5adcac4b3ffc8668c20fcb95fc01bfb2244c38bfafba62
7
+ data.tar.gz: 30b05b1eac9f9b6400e089b1de4e229fcd5769aae2a41066bc43e79e08f6a6c37db8e4b7cbbfd46933021eabafa098be601a546c5cc05d7a93fa4c01d5c14021
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab_quality-test_tooling (0.8.1)
4
+ gitlab_quality-test_tooling (0.8.2)
5
5
  activesupport (>= 6.1, < 7.1)
6
6
  gitlab (~> 4.19)
7
7
  http (~> 5.0)
@@ -12,18 +12,12 @@ module GitlabQuality
12
12
  @input_files = input_files
13
13
  end
14
14
 
15
- REGEX = %r{(?<gitlab_qa_run>gitlab-qa-run-.*?(?=/))/(?<gitlab_ce_ee_qa>gitlab-(?:ee|ce)-qa-.*?(?=/))}
16
15
  CONTAINER_PATH = File.join('/home', 'gitlab', 'qa', 'tmp').freeze
17
16
 
18
17
  def invoke!
19
18
  Dir.glob(input_files).each do |input_file|
20
- match_data = input_file.match(REGEX)
21
- next unless match_data
22
-
23
- host_relative_path = "#{match_data[:gitlab_qa_run]}/#{match_data[:gitlab_ce_ee_qa]}"
24
-
25
- rewrite_schreenshot_paths_in_junit_file(input_file, host_relative_path)
26
- rewrite_schreenshot_paths_in_json_file(input_file.gsub('.xml', '.json'), host_relative_path)
19
+ rewrite_schreenshot_paths_in_junit_file(input_file)
20
+ rewrite_schreenshot_paths_in_json_file(input_file.gsub('.xml', '.json'))
27
21
  end
28
22
  end
29
23
 
@@ -31,35 +25,35 @@ module GitlabQuality
31
25
 
32
26
  attr_reader :input_files
33
27
 
34
- def rewrite_schreenshot_paths_in_junit_file(junit_file, host_relative_path)
28
+ def rewrite_schreenshot_paths_in_junit_file(junit_file)
35
29
  File.write(
36
30
  junit_file,
37
- rewrite_each_junit_screenshot_path(junit_file, host_relative_path).to_s
31
+ rewrite_each_junit_screenshot_path(junit_file).to_s
38
32
  )
39
33
 
40
34
  puts "Saved #{junit_file}"
41
35
  end
42
36
 
43
- def rewrite_schreenshot_paths_in_json_file(json_file, host_relative_path)
37
+ def rewrite_schreenshot_paths_in_json_file(json_file)
44
38
  File.write(
45
39
  json_file,
46
40
  JSON.pretty_generate(
47
- rewrite_each_json_screenshot_path(json_file, host_relative_path)
41
+ rewrite_each_json_screenshot_path(json_file)
48
42
  )
49
43
  )
50
44
 
51
45
  puts "Saved #{json_file}"
52
46
  end
53
47
 
54
- def rewrite_each_junit_screenshot_path(junit_file, host_relative_path)
48
+ def rewrite_each_junit_screenshot_path(junit_file)
55
49
  Nokogiri::XML(File.open(junit_file)).tap do |report|
56
50
  report.xpath('//system-out').each do |system_out|
57
- system_out.content = remove_container_absolute_path_prefix(system_out.content, host_relative_path)
51
+ system_out.content = remove_container_absolute_path_prefix(system_out.content, test_artifacts_directory(junit_file))
58
52
  end
59
53
  end
60
54
  end
61
55
 
62
- def rewrite_each_json_screenshot_path(json_file, host_relative_path)
56
+ def rewrite_each_json_screenshot_path(json_file)
63
57
  JSON.parse(File.read(json_file)).tap do |report|
64
58
  examples = report['examples']
65
59
 
@@ -67,13 +61,17 @@ module GitlabQuality
67
61
  next unless example['screenshot'].present?
68
62
 
69
63
  example['screenshot']['image'] =
70
- remove_container_absolute_path_prefix(example.dig('screenshot', 'image'), host_relative_path)
64
+ remove_container_absolute_path_prefix(example.dig('screenshot', 'image'), test_artifacts_directory(json_file))
71
65
  end
72
66
  end
73
67
  end
74
68
 
75
- def remove_container_absolute_path_prefix(image_container_absolute_path, host_relative_path)
76
- image_container_absolute_path.gsub(CONTAINER_PATH, host_relative_path)
69
+ def remove_container_absolute_path_prefix(image_container_absolute_path, test_artifacts_dir)
70
+ image_container_absolute_path.gsub(CONTAINER_PATH, test_artifacts_dir)
71
+ end
72
+
73
+ def test_artifacts_directory(filepath)
74
+ File.dirname(filepath)
77
75
  end
78
76
  end
79
77
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GitlabQuality
4
4
  module TestTooling
5
- VERSION = "0.8.1"
5
+ VERSION = "0.8.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab_quality-test_tooling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab Quality
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-13 00:00:00.000000000 Z
11
+ date: 2023-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: climate_control