allure-report-publisher 0.10.0 → 1.0.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: 7722c37f99dfb77c35ecc2d813ab65430855d30fa84ebb8836b48e8819e32c56
4
- data.tar.gz: 2f992f399433095c273d05b41b15a76958730aeb574b025f1ab804ea993eb290
3
+ metadata.gz: cbc236368c7b0893b5de931e7ecd37836c72bc540a5909efcf319fd74348541a
4
+ data.tar.gz: bf74a63cf06f76bc27d52cdf16fce99006a82076c12fce25de89375a27a932c0
5
5
  SHA512:
6
- metadata.gz: 1c5b08dba58c1d367c6481d21481ebe62044fbec30765d0d0a0ab2f270d7b241e070b4cbb2c6d6773c08888e313b690089a4ff2faa928a4a9f68d5befed8d5c5
7
- data.tar.gz: c0cab48cf344df067e70660ec347ca8c11e2b4d7d2517b4364434c576355653067ef3d8a2e8db334d4b1d028b4d1b4ecd338512aad0c72474ed51cb80ba6d83c
6
+ metadata.gz: 51104eb7d7073e3495804534aaa0f415cec9f9300dd1c0fa8e1338b065acae290f91fd758c61e0af45f34165f1710923bd6a6e0f2b6d1a9c4d295d409fa89909
7
+ data.tar.gz: 5aec20910db4609549224a161a09502a390be539a77873b2d1de556b73d307b23d93d0d0f6c8404897569c7fc84e4a7c366bb33cfb6dc40406c530f1874cd2c6
data/README.md CHANGED
@@ -43,7 +43,7 @@ Arguments:
43
43
  TYPE # REQUIRED Cloud storage type: (s3/gcs)
44
44
 
45
45
  Options:
46
- --results-glob=VALUE # Allure results files glob. Required: true
46
+ --results-glob=VALUE # Glob pattern to return allure results directories. Required: true
47
47
  --bucket=VALUE # Bucket name. Required: true
48
48
  --prefix=VALUE # Optional prefix for report path. Required: false
49
49
  --update-pr=VALUE # Add report url to PR via comment or description update. Required: false: (comment/description/actions)
@@ -56,8 +56,8 @@ Options:
56
56
  --help, -h # Print this help
57
57
 
58
58
  Examples:
59
- allure-report-publisher upload s3 --results-glob='path/to/allure-result/**/*' --bucket=my-bucket
60
- allure-report-publisher upload gcs --results-glob='path/to/allure-result/**/*' --bucket=my-bucket --prefix=my-project/prs
59
+ allure-report-publisher upload s3 --results-glob='path/to/allure-results' --bucket=my-bucket
60
+ allure-report-publisher upload gcs --results-glob='paths/to/**/allure-results' --bucket=my-bucket --prefix=my-project/prs
61
61
  ```
62
62
 
63
63
  # Storage providers
@@ -14,7 +14,7 @@ module Publisher
14
14
  desc: "Cloud storage type"
15
15
 
16
16
  option :results_glob,
17
- desc: "Allure results files glob. Required: true"
17
+ desc: "Glob pattern to return allure results directories. Required: true"
18
18
  option :bucket,
19
19
  desc: "Bucket name. Required: true"
20
20
  option :prefix,
@@ -57,8 +57,8 @@ module Publisher
57
57
  desc: "Ignore missing allure results"
58
58
 
59
59
  example [
60
- "s3 --results-glob='path/to/allure-result/**/*' --bucket=my-bucket",
61
- "gcs --results-glob='path/to/allure-result/**/*' --bucket=my-bucket --prefix=my-project/prs"
60
+ "s3 --results-glob='path/to/allure-results' --bucket=my-bucket",
61
+ "gcs --results-glob='paths/to/**/allure-results' --bucket=my-bucket --prefix=my-project/prs"
62
62
  ]
63
63
 
64
64
  def call(**args)
@@ -18,15 +18,14 @@ module Publisher
18
18
  #
19
19
  # @return [void]
20
20
  def generate
21
- aggregate_results
22
21
  generate_report
23
22
  end
24
23
 
25
- # Aggregated results directory
24
+ # Common path for history and executor info
26
25
  #
27
26
  # @return [String]
28
- def results_path
29
- @results_path ||= Dir.mktmpdir("allure-results")
27
+ def common_info_path
28
+ @common_info_path ||= Dir.mktmpdir("allure-results")
30
29
  end
31
30
 
32
31
  # Allure report directory
@@ -40,14 +39,16 @@ module Publisher
40
39
 
41
40
  attr_reader :results_glob
42
41
 
43
- # Copy all results files to results directory
42
+ # Return all allure results paths from glob
44
43
  #
45
- # @return [void]
46
- def aggregate_results
47
- results = Dir.glob(results_glob)
48
- raise(NoAllureResultsError, "Missing allure results") if results.empty?
44
+ # @return [String]
45
+ def result_paths
46
+ @result_paths ||= begin
47
+ paths = Dir.glob(results_glob)
48
+ raise(NoAllureResultsError, "Missing allure results") if paths.empty?
49
49
 
50
- FileUtils.cp(results, results_path)
50
+ paths.join(" ")
51
+ end
51
52
  end
52
53
 
53
54
  # Generate allure report
@@ -55,7 +56,7 @@ module Publisher
55
56
  # @return [void]
56
57
  def generate_report
57
58
  out, _err, status = Open3.capture3(
58
- "allure generate --clean --output #{report_path} #{results_path}"
59
+ "allure generate --clean --output #{report_path} #{common_info_path} #{result_paths}"
59
60
  )
60
61
  raise(AllureError, out) unless status.success?
61
62
  end
@@ -104,7 +104,7 @@ module Publisher
104
104
  :collapse_summary,
105
105
  :summary_table_type
106
106
 
107
- def_delegators :report_generator, :results_path, :report_path
107
+ def_delegators :report_generator, :common_info_path, :report_path
108
108
 
109
109
  # :nocov:
110
110
 
@@ -224,7 +224,7 @@ module Publisher
224
224
  def add_executor_info
225
225
  return unless ci_provider
226
226
 
227
- File.write("#{results_path}/#{EXECUTOR_JSON}", ci_provider.executor_info.to_json)
227
+ File.write("#{common_info_path}/#{EXECUTOR_JSON}", ci_provider.executor_info.to_json)
228
228
  end
229
229
 
230
230
  # Run upload commands
@@ -240,7 +240,7 @@ module Publisher
240
240
  #
241
241
  # @return [void]
242
242
  def create_history_dir
243
- FileUtils.mkdir_p(path(results_path, "history"))
243
+ FileUtils.mkdir_p(path(common_info_path, "history"))
244
244
  end
245
245
  end
246
246
  end
@@ -43,7 +43,7 @@ module Publisher
43
43
  file = bucket.file(key(prefix, "history", file_name))
44
44
  raise(HistoryNotFoundError, "Allure history from previous runs not found!") unless file
45
45
 
46
- file.download(path(results_path, "history", file_name))
46
+ file.download(path(common_info_path, "history", file_name))
47
47
  end
48
48
  end
49
49
 
@@ -65,23 +65,27 @@ module Publisher
65
65
  #
66
66
  # @return [void]
67
67
  def upload_latest_copy
68
- upload_to_gcs(report_files, prefix)
68
+ upload_to_gcs(report_files, prefix, cache_control: 60)
69
69
  end
70
70
 
71
- # Upload files to s3
71
+ # Upload files to gcs
72
72
  #
73
73
  # @param [Array<Pathname>] files
74
74
  # @param [String] key_prefix
75
+ # @param [Hash] params
75
76
  # @return [Array<Hash>]
76
- def upload_to_gcs(files, key_prefix)
77
+ def upload_to_gcs(files, key_prefix, cache_control: 3600)
77
78
  args = files.map do |file|
78
79
  {
79
80
  file: file.to_s,
80
- path: key(key_prefix, file.relative_path_from(report_path))
81
+ path: key(key_prefix, file.relative_path_from(report_path)),
82
+ cache_control: "public, max-age=#{cache_control}"
81
83
  }
82
84
  end
83
85
 
84
- Parallel.each(args, in_threads: 8) { |obj| bucket.create_file(obj[:file], obj[:path]) }
86
+ Parallel.each(args, in_threads: 8) do |obj|
87
+ bucket.create_file(*obj.slice(:file, :path).values, **obj.slice(:cache_control))
88
+ end
85
89
  end
86
90
 
87
91
  # Fabricate key for s3 object
@@ -49,7 +49,7 @@ module Publisher
49
49
  def download_history
50
50
  HISTORY.each do |file|
51
51
  client.get_object(
52
- response_target: path(results_path, "history", file),
52
+ response_target: path(common_info_path, "history", file),
53
53
  key: key(prefix, "history", file),
54
54
  bucket: bucket_name
55
55
  )
@@ -76,7 +76,7 @@ module Publisher
76
76
  #
77
77
  # @return [void]
78
78
  def upload_latest_copy
79
- upload_to_s3(report_files, prefix)
79
+ upload_to_s3(report_files, prefix, cache_control: 60)
80
80
  end
81
81
 
82
82
  # Upload files to s3
@@ -84,13 +84,14 @@ module Publisher
84
84
  # @param [Array<Pathname>] files
85
85
  # @param [String] key_prefix
86
86
  # @return [Array<Hash>]
87
- def upload_to_s3(files, key_prefix)
87
+ def upload_to_s3(files, key_prefix, cache_control: 3600)
88
88
  args = files.map do |file|
89
89
  {
90
90
  body: File.new(file),
91
91
  bucket: bucket_name,
92
92
  key: key(key_prefix, file.relative_path_from(report_path)),
93
- content_type: MiniMime.lookup_by_filename(file).content_type
93
+ content_type: MiniMime.lookup_by_filename(file).content_type,
94
+ cache_control: "max-age=#{cache_control}"
94
95
  }
95
96
  end
96
97
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Publisher
4
- VERSION = "0.10.0"
4
+ VERSION = "1.0.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: 0.10.0
4
+ version: 1.0.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-08-13 00:00:00.000000000 Z
11
+ date: 2022-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -362,14 +362,14 @@ dependencies:
362
362
  requirements:
363
363
  - - "~>"
364
364
  - !ruby/object:Gem::Version
365
- version: 0.45.0
365
+ version: 0.46.0
366
366
  type: :development
367
367
  prerelease: false
368
368
  version_requirements: !ruby/object:Gem::Requirement
369
369
  requirements:
370
370
  - - "~>"
371
371
  - !ruby/object:Gem::Version
372
- version: 0.45.0
372
+ version: 0.46.0
373
373
  description: Upload allure reports to different file storage providers
374
374
  email:
375
375
  - andrejs.cunskis@gmail.com