allure-report-publisher 0.0.3 → 0.0.4
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 +5 -4
- data/lib/allure_report_publisher/commands/base.rb +5 -1
- data/lib/allure_report_publisher/commands/upload_s3.rb +7 -9
- data/lib/allure_report_publisher/lib/uploaders/_uploader.rb +46 -11
- data/lib/allure_report_publisher/lib/uploaders/s3_uploader.rb +38 -27
- data/lib/allure_report_publisher/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0a1bb3d8d9d7a22c080bcb2ce71fcf4d082d49b8ffd528fb3ef409d4afbf0ef
|
4
|
+
data.tar.gz: 992e16c2cb4ee7feabefd9250efb13f824804e2a30bec5c6f031666f41e8f9a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9806755fe1c216f8c590e183e0b667060a92017d42991a65663ed74aa8519d8e390e2eafe6dd35d67dacd0f40df3e1c75feab23498869073fe343d2514c02767
|
7
|
+
data.tar.gz: 6a04f0503833d6378c3f4923b159a2567e8b3a9fc3ee642825ec45ef921d514616a2b93c39d50204cd29573dc88723b4ef2c47f9d3c05a30942dff63f6d91433
|
data/README.md
CHANGED
@@ -45,16 +45,17 @@ Description:
|
|
45
45
|
Generate and upload allure report
|
46
46
|
|
47
47
|
Options:
|
48
|
-
--[no-]color # Toggle color output
|
48
|
+
--[no-]color # Toggle color output, default: false
|
49
49
|
--[no-]update-pr # Update pull request description with url to allure report, default: false
|
50
|
-
--
|
50
|
+
--[no-]copy-latest # Keep copy of latest report at base prefix path, default: false
|
51
|
+
--results-glob=VALUE # Allure results files glob. Required: true
|
51
52
|
--bucket=VALUE # Bucket name. Required: true
|
52
53
|
--prefix=VALUE # Optional prefix for report path. Required: false
|
53
54
|
--help, -h # Print this help
|
54
55
|
|
55
56
|
Examples:
|
56
|
-
allure-report-publisher upload s3 --
|
57
|
-
allure-report-publisher upload s3 --
|
57
|
+
allure-report-publisher upload s3 --results-glob='path/to/allure-result/**/*' --bucket=my-bucket
|
58
|
+
allure-report-publisher upload s3 --results-glob='path/to/allure-result/**/*' --bucket=my-bucket --project=my-project/prs
|
58
59
|
```
|
59
60
|
|
60
61
|
## Development
|
@@ -5,11 +5,15 @@ module Publisher
|
|
5
5
|
module CommonOptions
|
6
6
|
def self.included(mod)
|
7
7
|
mod.instance_eval do
|
8
|
-
option :color, type: :boolean, desc: "Toggle color output"
|
8
|
+
option :color, type: :boolean, desc: "Toggle color output, default: false"
|
9
9
|
option :update_pr,
|
10
10
|
type: :boolean,
|
11
11
|
default: false,
|
12
12
|
desc: "Update pull request description with url to allure report"
|
13
|
+
option :copy_latest,
|
14
|
+
type: :boolean,
|
15
|
+
default: false,
|
16
|
+
desc: "Keep copy of latest report at base prefix path"
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
@@ -8,24 +8,22 @@ module Publisher
|
|
8
8
|
|
9
9
|
desc "Generate and upload allure report"
|
10
10
|
|
11
|
-
option :
|
11
|
+
option :results_glob, desc: "Allure results files glob. Required: true"
|
12
12
|
option :bucket, desc: "Bucket name. Required: true"
|
13
13
|
option :prefix, desc: "Optional prefix for report path. Required: false"
|
14
14
|
|
15
15
|
example [
|
16
|
-
"--
|
17
|
-
"--
|
16
|
+
"--results-glob='path/to/allure-result/**/*' --bucket=my-bucket",
|
17
|
+
"--results-glob='path/to/allure-result/**/*' --bucket=my-bucket --project=my-project/prs"
|
18
18
|
]
|
19
19
|
|
20
20
|
def call(**args)
|
21
21
|
validate_args(args)
|
22
22
|
Helpers.pastel(force_color: args[:color])
|
23
23
|
|
24
|
-
Uploaders::S3
|
25
|
-
args
|
26
|
-
|
27
|
-
args[:prefix]
|
28
|
-
).execute(update_pr: args[:update_pr])
|
24
|
+
Uploaders::S3
|
25
|
+
.new(**args.slice(:results_glob, :bucket, :prefix, :copy_latest, :update_pr))
|
26
|
+
.execute
|
29
27
|
end
|
30
28
|
|
31
29
|
private
|
@@ -35,7 +33,7 @@ module Publisher
|
|
35
33
|
# @param [Hash] args
|
36
34
|
# @return [void]
|
37
35
|
def validate_args(args)
|
38
|
-
error("Missing argument --
|
36
|
+
error("Missing argument --results-glob!") unless args[:results_glob]
|
39
37
|
error("Missing argument --bucket!") unless args[:bucket]
|
40
38
|
end
|
41
39
|
end
|
@@ -13,10 +13,12 @@ module Publisher
|
|
13
13
|
"retry-trend.json"
|
14
14
|
].freeze
|
15
15
|
|
16
|
-
def initialize(results_glob
|
16
|
+
def initialize(results_glob:, bucket:, update_pr: false, prefix: nil, copy_latest: false)
|
17
17
|
@results_glob = results_glob
|
18
18
|
@bucket = bucket
|
19
19
|
@prefix = prefix
|
20
|
+
@update_pr = update_pr
|
21
|
+
@copy_latest = Providers.provider && copy_latest # copy latest for ci only
|
20
22
|
end
|
21
23
|
|
22
24
|
# :nocov:
|
@@ -24,19 +26,19 @@ module Publisher
|
|
24
26
|
# Execute allure report generation and upload
|
25
27
|
#
|
26
28
|
# @return [void]
|
27
|
-
def execute
|
29
|
+
def execute
|
28
30
|
check_client_configured
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
generate
|
33
|
+
upload
|
34
|
+
add_url_to_pr
|
33
35
|
rescue StandardError => e
|
34
36
|
error(e.message)
|
35
37
|
end
|
36
38
|
|
37
39
|
private
|
38
40
|
|
39
|
-
attr_reader :results_glob, :bucket, :prefix
|
41
|
+
attr_reader :results_glob, :bucket, :prefix, :update_pr, :copy_latest
|
40
42
|
|
41
43
|
# Validate if client is properly configured
|
42
44
|
# and raise error if it is not
|
@@ -53,13 +55,28 @@ module Publisher
|
|
53
55
|
raise("Not Implemented!")
|
54
56
|
end
|
55
57
|
|
58
|
+
# Upload history to s3
|
59
|
+
#
|
60
|
+
# @return [void]
|
61
|
+
def upload_history
|
62
|
+
raise("Not implemented!")
|
63
|
+
end
|
64
|
+
|
56
65
|
# Upload report to s3
|
57
66
|
#
|
58
67
|
# @return [void]
|
59
|
-
def
|
68
|
+
def upload_report
|
60
69
|
raise("Not implemented!")
|
61
70
|
end
|
62
71
|
|
72
|
+
# Upload copy of latest run
|
73
|
+
#
|
74
|
+
# @return [void]
|
75
|
+
def upload_latest_copy
|
76
|
+
raise("Not implemented!")
|
77
|
+
end
|
78
|
+
# :nocov:
|
79
|
+
|
63
80
|
# Add allure history
|
64
81
|
#
|
65
82
|
# @return [void]
|
@@ -86,25 +103,43 @@ module Publisher
|
|
86
103
|
# Generate allure report
|
87
104
|
#
|
88
105
|
# @return [void]
|
89
|
-
def
|
106
|
+
def generate
|
90
107
|
add_history
|
91
108
|
add_executor_info
|
92
109
|
|
93
110
|
ReportGenerator.new(results_glob, results_dir, report_dir).generate
|
94
111
|
end
|
95
112
|
|
113
|
+
# Upload report to storage provider
|
114
|
+
#
|
115
|
+
# @return [void]
|
116
|
+
def upload
|
117
|
+
log("Uploading report")
|
118
|
+
Helpers::Spinner.spin("uploading report") { run_uploads }
|
119
|
+
log("Run report: #{report_url}", :green)
|
120
|
+
log("Latest report: #{latest_report_url}", :green) if copy_latest
|
121
|
+
end
|
122
|
+
|
123
|
+
# Run upload commands
|
124
|
+
#
|
125
|
+
# @return [void]
|
126
|
+
def run_uploads
|
127
|
+
upload_history unless copy_latest # latest report will add a common history folder
|
128
|
+
upload_report
|
129
|
+
upload_latest_copy if copy_latest
|
130
|
+
end
|
131
|
+
|
96
132
|
# Add allure report url to pull request description
|
97
133
|
#
|
98
134
|
# @return [void]
|
99
|
-
def
|
100
|
-
return unless ci_provider
|
135
|
+
def add_url_to_pr
|
136
|
+
return unless update_pr && ci_provider
|
101
137
|
|
102
138
|
log("Adding allure report link to pr description")
|
103
139
|
Helpers::Spinner.spin("adding link", exit_on_error: false) do
|
104
140
|
ci_provider.add_report_url
|
105
141
|
end
|
106
142
|
end
|
107
|
-
# :nocov:
|
108
143
|
|
109
144
|
# Get run id
|
110
145
|
#
|
@@ -7,6 +7,19 @@ module Publisher
|
|
7
7
|
class S3 < Uploader
|
8
8
|
private
|
9
9
|
|
10
|
+
# S3 client
|
11
|
+
#
|
12
|
+
# @return [Aws::S3::Client]
|
13
|
+
def s3
|
14
|
+
@s3 ||= 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
|
+
|
10
23
|
# Validate if client is properly configured
|
11
24
|
# and raise error if it is not
|
12
25
|
#
|
@@ -19,7 +32,14 @@ module Publisher
|
|
19
32
|
#
|
20
33
|
# @return [String]
|
21
34
|
def report_url
|
22
|
-
@report_url ||=
|
35
|
+
@report_url ||= url(full_prefix)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Latest report url
|
39
|
+
#
|
40
|
+
# @return [String]
|
41
|
+
def latest_report_url
|
42
|
+
@latest_report_url ||= url(prefix)
|
23
43
|
end
|
24
44
|
|
25
45
|
# Add allure history
|
@@ -39,30 +59,6 @@ module Publisher
|
|
39
59
|
end
|
40
60
|
end
|
41
61
|
|
42
|
-
# Upload report to s3
|
43
|
-
#
|
44
|
-
# @return [void]
|
45
|
-
def upload_history_and_report
|
46
|
-
log("Uploading report to s3")
|
47
|
-
Helpers::Spinner.spin("uploading report", done_message: "done. #{report_url}") do
|
48
|
-
upload_history
|
49
|
-
upload_report
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# S3 client
|
54
|
-
#
|
55
|
-
# @return [Aws::S3::Client]
|
56
|
-
def s3
|
57
|
-
@s3 ||= Aws::S3::Client.new(region: ENV["AWS_REGION"] || "us-east-1")
|
58
|
-
rescue Aws::Sigv4::Errors::MissingCredentialsError
|
59
|
-
raise(<<~MSG.strip)
|
60
|
-
missing aws credentials, provide credentials with one of the following options:
|
61
|
-
- AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables
|
62
|
-
- ~/.aws/credentials file
|
63
|
-
MSG
|
64
|
-
end
|
65
|
-
|
66
62
|
# Upload allure history
|
67
63
|
#
|
68
64
|
# @return [void]
|
@@ -74,7 +70,14 @@ module Publisher
|
|
74
70
|
#
|
75
71
|
# @return [void]
|
76
72
|
def upload_report
|
77
|
-
upload_to_s3(report_files)
|
73
|
+
upload_to_s3(report_files, full_prefix)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Upload copy of latest run
|
77
|
+
#
|
78
|
+
# @return [void]
|
79
|
+
def upload_latest_copy
|
80
|
+
upload_to_s3(report_files, prefix)
|
78
81
|
end
|
79
82
|
|
80
83
|
# Upload files to s3
|
@@ -82,7 +85,7 @@ module Publisher
|
|
82
85
|
# @param [Array<Pathname>] files
|
83
86
|
# @param [String] key_prefix
|
84
87
|
# @return [Array<Hash>]
|
85
|
-
def upload_to_s3(files, key_prefix
|
88
|
+
def upload_to_s3(files, key_prefix)
|
86
89
|
args = files.map do |file|
|
87
90
|
{
|
88
91
|
body: File.new(file),
|
@@ -101,6 +104,14 @@ module Publisher
|
|
101
104
|
def key(*args)
|
102
105
|
args.compact.join("/")
|
103
106
|
end
|
107
|
+
|
108
|
+
# Report url
|
109
|
+
#
|
110
|
+
# @param [String] path_prefix
|
111
|
+
# @return [String]
|
112
|
+
def url(path_prefix)
|
113
|
+
["http://#{bucket}.s3.amazonaws.com", path_prefix, "index.html"].compact.join("/")
|
114
|
+
end
|
104
115
|
end
|
105
116
|
end
|
106
117
|
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.0.
|
4
|
+
version: 0.0.4
|
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-05-
|
11
|
+
date: 2021-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|