allure-report-publisher 1.1.0 → 1.2.0

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: fc21e0f3488c76bf88a227a59a470d1959f5aadb813fc86986f7a7a175793efc
4
- data.tar.gz: 641b2e9a9e6587a3246bdcdbf4e34cc3b952f56c46773e495473db9749e68e80
3
+ metadata.gz: 1809950b5cb79015f9d4568c28eea62fea2ff4abb581ee762303684aa86859a2
4
+ data.tar.gz: e22f93a0a820aded1cd74bef9b3836867e6c25a0a454acd57343159ba19c780f
5
5
  SHA512:
6
- metadata.gz: 2ef72a1f8869b175110a7377418bc3a4b369bbb44329965b2b76184c905dc38293b845cf0d661dbe1ff6eb66c2b87804d6fdc74b06eefa58d30826b863c6f0f9
7
- data.tar.gz: d15121ee77d77a467a7e9f6a28b447218711aacc3aa63586f2a0cac424e1abdd129ac2aa7aaba654ddce25f8cf4aec0049d39d4b6cf8be8348515cac6f1854de
6
+ metadata.gz: 7695a8fab036e58f775d1d6372ddcc054cd791212e278c840fb2642e4c4c29fb35409fe5cf9e30475217be471f564e68c231362305e89f3815bdb31c53f05ec1
7
+ data.tar.gz: c9a64aaf86756c14c2e735a9632a1024d178ea1b8e9e97a43d65ad2afd05ff4adaa38094a9f12e083a70d145006269defdb1252ef64991e6412913cd47e6ea5e
@@ -70,7 +70,7 @@ module Publisher
70
70
  @args = args
71
71
 
72
72
  validate_args
73
- validate_result_files
73
+ scan_results_paths
74
74
 
75
75
  generate_report
76
76
  upload_report
@@ -91,8 +91,8 @@ module Publisher
91
91
  def uploader
92
92
  @uploader ||= uploaders(args[:type]).new(
93
93
  summary_type: args[:summary],
94
+ result_paths: @result_paths,
94
95
  **args.slice(
95
- :results_glob,
96
96
  :bucket,
97
97
  :prefix,
98
98
  :copy_latest,
@@ -122,16 +122,18 @@ module Publisher
122
122
  error("Missing argument --bucket!") unless args[:bucket]
123
123
  end
124
124
 
125
- # Check if allure results present
125
+ # Scan for allure results paths
126
126
  #
127
127
  # @param [String] results_glob
128
128
  # @return [void]
129
- def validate_result_files
129
+ def scan_results_paths
130
130
  results_glob = args[:results_glob]
131
131
  ignore = args[:ignore_missing_results]
132
- return unless Dir.glob(results_glob).empty?
132
+ @result_paths = Dir.glob(results_glob)
133
+ log_debug("Glob '#{results_glob}' found #{@result_paths.size} paths")
134
+ return unless @result_paths.empty?
133
135
 
134
- log("Glob '#{results_glob}' did not match any files!", ignore ? :yellow : :red)
136
+ log("Glob '#{results_glob}' did not match any paths!", ignore ? :yellow : :red)
135
137
  exit(ignore ? 0 : 1)
136
138
  end
137
139
 
@@ -48,22 +48,43 @@ module Publisher
48
48
  @valid
49
49
  end
50
50
 
51
- # Perform batch copy operation
51
+ # Perform copy operation within a single bucket
52
52
  #
53
53
  # @param [String] source_dir
54
54
  # @param [String] destination_dir
55
55
  # @param [String] bucket
56
- # @param [String] cache_control
56
+ # @param [Integer] cache_control
57
57
  # @return [void]
58
58
  def batch_copy(source_dir:, destination_dir:, bucket:, cache_control: 3600)
59
+ batch_upload(
60
+ source_dir: "gs://#{bucket}/#{source_dir}",
61
+ destination_dir: destination_dir,
62
+ bucket: bucket,
63
+ cache_control: cache_control
64
+ )
65
+ end
66
+
67
+ # Perform batch upload operation
68
+ #
69
+ # @param [String] source_dir
70
+ # @param [String] destination_dir
71
+ # @param [String] bucket
72
+ # @param [String] cache_control
73
+ # @return [void]
74
+ def batch_upload(source_dir:, destination_dir:, bucket:, cache_control: 3600)
59
75
  raise(Uninitialised, "gsutil has not been properly set up!") unless valid?
60
76
 
61
- log_debug("Uploading '#{source_dir}' using gsutil to bucket '#{bucket}' with destination '#{destination_dir}'")
77
+ action = source_dir.start_with?("gs://") ? "Copying" : "Uploading"
78
+ destination = "gs://#{bucket}/#{destination_dir}"
79
+
80
+ log_debug("#{action} '#{source_dir}' to '#{destination}'")
62
81
  with_credentials do |key_file|
63
82
  execute_shell([
64
83
  base_cmd(key_file),
65
84
  "-h 'Cache-Control:private, max-age=#{cache_control}'",
66
- "rsync -r #{source_dir} gs://#{bucket}/#{destination_dir}"
85
+ "rsync",
86
+ "-j json,csv,txt,js,css",
87
+ "-r #{source_dir} #{destination}"
67
88
  ].join(" "))
68
89
  end
69
90
  log_debug("Finished upload successfully")
@@ -10,8 +10,8 @@ module Publisher
10
10
  class ReportGenerator
11
11
  include Helpers
12
12
 
13
- def initialize(results_glob)
14
- @results_glob = results_glob
13
+ def initialize(result_paths)
14
+ @result_paths = result_paths.join(" ")
15
15
  end
16
16
 
17
17
  # Generate allure report
@@ -42,25 +42,14 @@ module Publisher
42
42
 
43
43
  private
44
44
 
45
- attr_reader :results_glob
46
-
47
- # Return all allure results paths from glob
48
- #
49
- # @return [String]
50
- def result_paths
51
- @result_paths ||= begin
52
- paths = Dir.glob(results_glob)
53
- raise(NoAllureResultsError, "Missing allure results") if paths.empty?
54
-
55
- paths.join(" ")
56
- end
57
- end
45
+ # @return [String] result paths string
46
+ attr_reader :result_paths
58
47
 
59
48
  # Generate allure report
60
49
  #
61
50
  # @return [void]
62
51
  def generate_report
63
- log_debug("Generating allure report from following paths: #{result_paths}")
52
+ log_debug("Generating allure report")
64
53
  cmd = "allure generate --clean --output #{report_path} #{common_info_path} #{result_paths}"
65
54
  out = execute_shell(cmd)
66
55
  log_debug("Generated allure report. #{out}")
@@ -23,7 +23,7 @@ module Publisher
23
23
  # Uploader instance
24
24
  #
25
25
  # @param [Hash] args
26
- # @option args [String] :results_glob
26
+ # @option args [Array] :result_paths
27
27
  # @option args [String] :bucket
28
28
  # @option args [String] :prefix
29
29
  # @option args [Boolean] :update_pr
@@ -32,7 +32,7 @@ module Publisher
32
32
  # @option args [Boolean] :collapse_summary
33
33
  # @option args [String] :copy_latest
34
34
  def initialize(**args)
35
- @results_glob = args[:results_glob]
35
+ @result_paths = args[:result_paths]
36
36
  @bucket_name = args[:bucket]
37
37
  @prefix = args[:prefix]
38
38
  @update_pr = args[:update_pr]
@@ -97,7 +97,7 @@ module Publisher
97
97
 
98
98
  private
99
99
 
100
- attr_reader :results_glob,
100
+ attr_reader :result_paths,
101
101
  :bucket_name,
102
102
  :prefix,
103
103
  :update_pr,
@@ -164,7 +164,7 @@ module Publisher
164
164
  #
165
165
  # @return [Publisher::ReportGenerator]
166
166
  def report_generator
167
- @report_generator ||= ReportGenerator.new(results_glob)
167
+ @report_generator ||= ReportGenerator.new(result_paths)
168
168
  end
169
169
 
170
170
  # Report path prefix
@@ -62,7 +62,7 @@ module Publisher
62
62
  # @return [void]
63
63
  def upload_history
64
64
  log_debug("Uploading report history")
65
- upload_to_gcs(report_files.select { |file| file.fnmatch?("*/history/*") }, prefix)
65
+ file_upload(report_files.select { |file| file.fnmatch?("*/history/*") }, prefix)
66
66
  end
67
67
 
68
68
  # Upload allure report
@@ -70,9 +70,9 @@ module Publisher
70
70
  # @return [void]
71
71
  def upload_report
72
72
  log_debug("Uploading report files")
73
- return batch_upload_to_gcs(report_path, full_prefix) if gsutil.valid?
73
+ return batch_upload(report_path, full_prefix) if gsutil.valid?
74
74
 
75
- upload_to_gcs(report_files, full_prefix)
75
+ file_upload(report_files, full_prefix)
76
76
  end
77
77
 
78
78
  # Upload copy of latest run
@@ -80,9 +80,9 @@ module Publisher
80
80
  # @return [void]
81
81
  def upload_latest_copy
82
82
  log_debug("Uploading report copy as latest report")
83
- return batch_upload_to_gcs(report_path, prefix, cache_control: 60) if gsutil.valid?
83
+ return batch_copy(full_prefix, prefix, cache_control: 60) if gsutil.valid?
84
84
 
85
- upload_to_gcs(report_files, prefix, cache_control: 60)
85
+ file_upload(report_files, prefix, cache_control: 60)
86
86
  end
87
87
 
88
88
  # Upload files to gcs
@@ -91,7 +91,7 @@ module Publisher
91
91
  # @param [String] key_prefix
92
92
  # @param [Hash] params
93
93
  # @return [void]
94
- def upload_to_gcs(files, key_prefix, cache_control: 3600)
94
+ def file_upload(files, key_prefix, cache_control: 3600)
95
95
  threads = 8
96
96
  args = files.map do |file|
97
97
  {
@@ -108,12 +108,27 @@ module Publisher
108
108
  log_debug("Finished upload successfully")
109
109
  end
110
110
 
111
- # Batch upload whole directory
111
+ # Upload directory recursively
112
112
  #
113
113
  # @param [String] source_dir
114
114
  # @param [String] destination_dir
115
115
  # @return [void]
116
- def batch_upload_to_gcs(source_dir, destination_dir, cache_control: 3600)
116
+ def batch_upload(source_dir, destination_dir, cache_control: 3600)
117
+ gsutil.batch_upload(
118
+ source_dir: source_dir,
119
+ destination_dir: destination_dir,
120
+ bucket: bucket_name,
121
+ cache_control: cache_control
122
+ )
123
+ end
124
+
125
+ # Copy directory within the bucket
126
+ #
127
+ # @param [String] source_dir
128
+ # @param [String] destination_dir
129
+ # @param [String] cache_control
130
+ # @return [void]
131
+ def batch_copy(source_dir, destination_dir, cache_control: 3600)
117
132
  gsutil.batch_copy(
118
133
  source_dir: source_dir,
119
134
  destination_dir: destination_dir,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Publisher
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allure-report-publisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrejs Cunskis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-17 00:00:00.000000000 Z
11
+ date: 2022-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 1.93.1
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 1.115.0
22
+ version: 1.116.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 1.93.1
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 1.115.0
32
+ version: 1.116.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: dry-cli
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -121,7 +121,7 @@ dependencies:
121
121
  version: '4.21'
122
122
  - - "<"
123
123
  - !ruby/object:Gem::Version
124
- version: '6.0'
124
+ version: '7.0'
125
125
  type: :runtime
126
126
  prerelease: false
127
127
  version_requirements: !ruby/object:Gem::Requirement
@@ -131,7 +131,7 @@ dependencies:
131
131
  version: '4.21'
132
132
  - - "<"
133
133
  - !ruby/object:Gem::Version
134
- version: '6.0'
134
+ version: '7.0'
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: parallel
137
137
  requirement: !ruby/object:Gem::Requirement
@@ -248,6 +248,9 @@ dependencies:
248
248
  name: debug
249
249
  requirement: !ruby/object:Gem::Requirement
250
250
  requirements:
251
+ - - "~>"
252
+ - !ruby/object:Gem::Version
253
+ version: '1.0'
251
254
  - - ">="
252
255
  - !ruby/object:Gem::Version
253
256
  version: 1.0.0
@@ -255,6 +258,9 @@ dependencies:
255
258
  prerelease: false
256
259
  version_requirements: !ruby/object:Gem::Requirement
257
260
  requirements:
261
+ - - "~>"
262
+ - !ruby/object:Gem::Version
263
+ version: '1.0'
258
264
  - - ">="
259
265
  - !ruby/object:Gem::Version
260
266
  version: 1.0.0