allure-report-publisher 0.0.1 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +42 -11
- data/lib/allure_report_publisher.rb +4 -5
- data/lib/allure_report_publisher/commands/upload.rb +90 -0
- data/lib/allure_report_publisher/{helpers.rb → lib/helpers/helpers.rb} +25 -25
- data/lib/allure_report_publisher/lib/helpers/spinner.rb +109 -0
- data/lib/allure_report_publisher/lib/providers/_provider.rb +111 -0
- data/lib/allure_report_publisher/lib/providers/github.rb +102 -0
- data/lib/allure_report_publisher/lib/providers/gitlab.rb +103 -0
- data/lib/allure_report_publisher/lib/report_generator.rb +4 -7
- data/lib/allure_report_publisher/lib/uploaders/_uploader.rb +146 -24
- data/lib/allure_report_publisher/lib/uploaders/gcs.rb +104 -0
- data/lib/allure_report_publisher/lib/uploaders/s3.rb +107 -0
- data/lib/allure_report_publisher/version.rb +1 -1
- metadata +60 -7
- data/lib/allure_report_publisher/commands/upload_s3.rb +0 -41
- data/lib/allure_report_publisher/lib/uploaders/s3_uploader.rb +0 -96
@@ -0,0 +1,104 @@
|
|
1
|
+
require "google/cloud/storage"
|
2
|
+
|
3
|
+
module Publisher
|
4
|
+
module Uploaders
|
5
|
+
# Google cloud storage uploader implementation
|
6
|
+
#
|
7
|
+
class GCS < Uploader
|
8
|
+
private
|
9
|
+
|
10
|
+
# GCS client
|
11
|
+
#
|
12
|
+
# @return [Google::Cloud::Storage::Project]
|
13
|
+
def client
|
14
|
+
@client ||= Google::Cloud::Storage.new
|
15
|
+
end
|
16
|
+
|
17
|
+
# GCS bucket
|
18
|
+
#
|
19
|
+
# @return [Google::Cloud::Storage::Bucket]
|
20
|
+
def bucket
|
21
|
+
@bucket ||= client.bucket(bucket_name, skip_lookup: true)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Report url
|
25
|
+
#
|
26
|
+
# @return [String]
|
27
|
+
def report_url
|
28
|
+
@report_url ||= url(full_prefix)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Latest report url
|
32
|
+
#
|
33
|
+
# @return [String]
|
34
|
+
def latest_report_url
|
35
|
+
@latest_report_url ||= url(prefix)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Download allure history
|
39
|
+
#
|
40
|
+
# @return [void]
|
41
|
+
def download_history
|
42
|
+
HISTORY.each do |file_name|
|
43
|
+
file = bucket.file(key(prefix, "history", file_name))
|
44
|
+
raise(HistoryNotFoundError, "Allure history from previous runs not found!") unless file
|
45
|
+
|
46
|
+
file.download(path(results_dir, "history", file_name))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# Upload allure history
|
51
|
+
#
|
52
|
+
# @return [void]
|
53
|
+
def upload_history
|
54
|
+
upload_to_gcs(report_files.select { |file| file.fnmatch?("*/history/*") }, prefix)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Upload allure report
|
58
|
+
#
|
59
|
+
# @return [void]
|
60
|
+
def upload_report
|
61
|
+
upload_to_gcs(report_files, full_prefix)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Upload copy of latest run
|
65
|
+
#
|
66
|
+
# @return [void]
|
67
|
+
def upload_latest_copy
|
68
|
+
upload_to_gcs(report_files, prefix)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Upload files to s3
|
72
|
+
#
|
73
|
+
# @param [Array<Pathname>] files
|
74
|
+
# @param [String] key_prefix
|
75
|
+
# @return [Array<Hash>]
|
76
|
+
def upload_to_gcs(files, key_prefix)
|
77
|
+
args = files.map do |file|
|
78
|
+
{
|
79
|
+
file: file.to_s,
|
80
|
+
path: key(key_prefix, file.relative_path_from(report_dir))
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
Parallel.each(args, in_threads: 8) { |obj| bucket.create_file(obj[:file], obj[:path]) }
|
85
|
+
end
|
86
|
+
|
87
|
+
# Fabricate key for s3 object
|
88
|
+
#
|
89
|
+
# @param [String] *args
|
90
|
+
# @return [String]
|
91
|
+
def key(*args)
|
92
|
+
args.compact.join("/")
|
93
|
+
end
|
94
|
+
|
95
|
+
# Report url
|
96
|
+
#
|
97
|
+
# @param [String] path_prefix
|
98
|
+
# @return [String]
|
99
|
+
def url(path_prefix)
|
100
|
+
["https://storage.googleapis.com", bucket_name, path_prefix, "index.html"].compact.join("/")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require "aws-sdk-s3"
|
2
|
+
|
3
|
+
module Publisher
|
4
|
+
module Uploaders
|
5
|
+
# Report upload to AWS S3 bucket
|
6
|
+
#
|
7
|
+
class S3 < Uploader
|
8
|
+
private
|
9
|
+
|
10
|
+
# S3 client
|
11
|
+
#
|
12
|
+
# @return [Aws::S3::Client]
|
13
|
+
def client
|
14
|
+
@client ||= Aws::S3::Client.new(region: ENV["AWS_REGION"] || "us-east-1")
|
15
|
+
rescue Aws::Sigv4::Errors::MissingCredentialsError
|
16
|
+
raise(<<~MSG.strip)
|
17
|
+
missing aws credentials, provide credentials with one of the following options:
|
18
|
+
- AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables
|
19
|
+
- ~/.aws/credentials file
|
20
|
+
MSG
|
21
|
+
end
|
22
|
+
|
23
|
+
# Report url
|
24
|
+
#
|
25
|
+
# @return [String]
|
26
|
+
def report_url
|
27
|
+
@report_url ||= url(full_prefix)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Latest report url
|
31
|
+
#
|
32
|
+
# @return [String]
|
33
|
+
def latest_report_url
|
34
|
+
@latest_report_url ||= url(prefix)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Add allure history
|
38
|
+
#
|
39
|
+
# @return [void]
|
40
|
+
def download_history
|
41
|
+
HISTORY.each do |file|
|
42
|
+
client.get_object(
|
43
|
+
response_target: path(results_dir, "history", file),
|
44
|
+
key: key(prefix, "history", file),
|
45
|
+
bucket: bucket_name
|
46
|
+
)
|
47
|
+
end
|
48
|
+
rescue Aws::S3::Errors::NoSuchKey
|
49
|
+
raise(HistoryNotFoundError, "Allure history from previous runs not found!")
|
50
|
+
end
|
51
|
+
|
52
|
+
# Upload allure history
|
53
|
+
#
|
54
|
+
# @return [void]
|
55
|
+
def upload_history
|
56
|
+
upload_to_s3(report_files.select { |file| file.fnmatch?("*/history/*") }, prefix)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Upload allure report
|
60
|
+
#
|
61
|
+
# @return [void]
|
62
|
+
def upload_report
|
63
|
+
upload_to_s3(report_files, full_prefix)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Upload copy of latest run
|
67
|
+
#
|
68
|
+
# @return [void]
|
69
|
+
def upload_latest_copy
|
70
|
+
upload_to_s3(report_files, prefix)
|
71
|
+
end
|
72
|
+
|
73
|
+
# Upload files to s3
|
74
|
+
#
|
75
|
+
# @param [Array<Pathname>] files
|
76
|
+
# @param [String] key_prefix
|
77
|
+
# @return [Array<Hash>]
|
78
|
+
def upload_to_s3(files, key_prefix)
|
79
|
+
args = files.map do |file|
|
80
|
+
{
|
81
|
+
body: File.new(file),
|
82
|
+
bucket: bucket_name,
|
83
|
+
key: key(key_prefix, file.relative_path_from(report_dir))
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
Parallel.each(args, in_threads: 8) { |obj| client.put_object(obj) }
|
88
|
+
end
|
89
|
+
|
90
|
+
# Fabricate key for s3 object
|
91
|
+
#
|
92
|
+
# @param [String] *args
|
93
|
+
# @return [String]
|
94
|
+
def key(*args)
|
95
|
+
args.compact.join("/")
|
96
|
+
end
|
97
|
+
|
98
|
+
# Report url
|
99
|
+
#
|
100
|
+
# @param [String] path_prefix
|
101
|
+
# @return [String]
|
102
|
+
def url(path_prefix)
|
103
|
+
["http://#{bucket_name}.s3.amazonaws.com", path_prefix, "index.html"].compact.join("/")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: allure-report-publisher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrejs Cunskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.93.1
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.95.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 1.93.1
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.95.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: dry-cli
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +44,48 @@ dependencies:
|
|
38
44
|
- - "~>"
|
39
45
|
- !ruby/object:Gem::Version
|
40
46
|
version: 0.6.0
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: gitlab
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '4.17'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '4.17'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: google-cloud-storage
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.31'
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.31'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: octokit
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '4.21'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '4.21'
|
41
89
|
- !ruby/object:Gem::Dependency
|
42
90
|
name: parallel
|
43
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,12 +153,17 @@ files:
|
|
105
153
|
- README.md
|
106
154
|
- bin/allure-report-publisher
|
107
155
|
- lib/allure_report_publisher.rb
|
108
|
-
- lib/allure_report_publisher/commands/
|
156
|
+
- lib/allure_report_publisher/commands/upload.rb
|
109
157
|
- lib/allure_report_publisher/commands/version.rb
|
110
|
-
- lib/allure_report_publisher/helpers.rb
|
158
|
+
- lib/allure_report_publisher/lib/helpers/helpers.rb
|
159
|
+
- lib/allure_report_publisher/lib/helpers/spinner.rb
|
160
|
+
- lib/allure_report_publisher/lib/providers/_provider.rb
|
161
|
+
- lib/allure_report_publisher/lib/providers/github.rb
|
162
|
+
- lib/allure_report_publisher/lib/providers/gitlab.rb
|
111
163
|
- lib/allure_report_publisher/lib/report_generator.rb
|
112
164
|
- lib/allure_report_publisher/lib/uploaders/_uploader.rb
|
113
|
-
- lib/allure_report_publisher/lib/uploaders/
|
165
|
+
- lib/allure_report_publisher/lib/uploaders/gcs.rb
|
166
|
+
- lib/allure_report_publisher/lib/uploaders/s3.rb
|
114
167
|
- lib/allure_report_publisher/version.rb
|
115
168
|
homepage: https://github.com/andrcuns/allure-report-uploader
|
116
169
|
licenses:
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module Publisher
|
2
|
-
module Commands
|
3
|
-
# Upload allure report
|
4
|
-
#
|
5
|
-
class UploadS3 < Dry::CLI::Command
|
6
|
-
include Helpers
|
7
|
-
|
8
|
-
desc "Generate and upload allure report"
|
9
|
-
|
10
|
-
option :result_files_glob, desc: "Allure results files glob. Required: true"
|
11
|
-
option :bucket, desc: "Bucket name. Required: true"
|
12
|
-
option :project, desc: "Project name for multiple reports inside single bucket. Required: false"
|
13
|
-
|
14
|
-
example [
|
15
|
-
"--result-files-glob='path/to/allure-result/**/*' --bucket=my-bucket",
|
16
|
-
"--result-files-glob='path/to/allure-result/**/*' --bucket=my-bucket --project=my-project"
|
17
|
-
]
|
18
|
-
|
19
|
-
def call(**args)
|
20
|
-
validate_args(args)
|
21
|
-
|
22
|
-
Uploaders::S3.new(
|
23
|
-
args[:result_files_glob],
|
24
|
-
args[:bucket],
|
25
|
-
args[:project]
|
26
|
-
).execute
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
# Validate required args
|
32
|
-
#
|
33
|
-
# @param [Hash] args
|
34
|
-
# @return [void]
|
35
|
-
def validate_args(args)
|
36
|
-
error("Missing argument --result-files-glob!") unless args[:result_files_glob]
|
37
|
-
error("Missing argument --bucket!") unless args[:bucket]
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,96 +0,0 @@
|
|
1
|
-
require "aws-sdk-s3"
|
2
|
-
|
3
|
-
module Publisher
|
4
|
-
module Uploaders
|
5
|
-
# Report upload to AWS S3 bucket
|
6
|
-
#
|
7
|
-
class S3 < Uploader
|
8
|
-
def execute
|
9
|
-
generate_report
|
10
|
-
upload_history_and_report
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
# S3 client
|
16
|
-
#
|
17
|
-
# @return [Aws::S3::Client]
|
18
|
-
def s3
|
19
|
-
@s3 ||= Aws::S3::Client.new
|
20
|
-
end
|
21
|
-
|
22
|
-
# Report url
|
23
|
-
#
|
24
|
-
# @return [String]
|
25
|
-
def report_url
|
26
|
-
@report_url ||= ["http://#{bucket}.s3.amazonaws.com", prefix, "index.html"].compact.join("/")
|
27
|
-
end
|
28
|
-
|
29
|
-
# Fetch allure history
|
30
|
-
#
|
31
|
-
# @return [void]
|
32
|
-
def fetch_history
|
33
|
-
log("Fetching allure history")
|
34
|
-
spin("fetching history") do
|
35
|
-
create_history_dir
|
36
|
-
HISTORY.each do |file|
|
37
|
-
s3.get_object(
|
38
|
-
response_target: path(results_dir, "history", file),
|
39
|
-
key: key(project, "history", file),
|
40
|
-
bucket: bucket
|
41
|
-
)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# Upload report to s3
|
47
|
-
#
|
48
|
-
# @return [void]
|
49
|
-
def upload_history_and_report
|
50
|
-
log("\nUploading report to s3")
|
51
|
-
spin("uploading report", done_message: "done. #{report_url}") do
|
52
|
-
upload_history
|
53
|
-
upload_report
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# Upload allure history
|
58
|
-
#
|
59
|
-
# @return [void]
|
60
|
-
def upload_history
|
61
|
-
return unless run_id
|
62
|
-
|
63
|
-
upload_to_s3(report_files.select { |file| file.fnmatch?("*/history/*") }, project)
|
64
|
-
end
|
65
|
-
|
66
|
-
def upload_report
|
67
|
-
upload_to_s3(report_files)
|
68
|
-
end
|
69
|
-
|
70
|
-
# Upload files to s3
|
71
|
-
#
|
72
|
-
# @param [Array<Pathname>] files
|
73
|
-
# @param [String] key_prefix
|
74
|
-
# @return [Array<Hash>]
|
75
|
-
def upload_to_s3(files, key_prefix = prefix)
|
76
|
-
args = files.map do |file|
|
77
|
-
{
|
78
|
-
body: File.new(file),
|
79
|
-
bucket: bucket,
|
80
|
-
key: key(key_prefix, file.relative_path_from(report_dir))
|
81
|
-
}
|
82
|
-
end
|
83
|
-
|
84
|
-
Parallel.each(args, in_threads: 8) { |obj| s3.put_object(obj) }
|
85
|
-
end
|
86
|
-
|
87
|
-
# Fabricate key for s3 object
|
88
|
-
#
|
89
|
-
# @param [String] *args
|
90
|
-
# @return [String]
|
91
|
-
def key(*args)
|
92
|
-
args.compact.join("/")
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|