allure-report-publisher 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -6
- data/lib/allure_report_publisher.rb +3 -1
- data/lib/allure_report_publisher/commands/base.rb +13 -0
- data/lib/allure_report_publisher/commands/upload_s3.rb +5 -3
- data/lib/allure_report_publisher/lib/ci/_base.rb +63 -0
- data/lib/allure_report_publisher/lib/ci/github_actions.rb +50 -0
- data/lib/allure_report_publisher/{helpers.rb → lib/helpers/helpers.rb} +24 -24
- data/lib/allure_report_publisher/lib/helpers/spinner.rb +109 -0
- data/lib/allure_report_publisher/lib/report_generator.rb +2 -2
- data/lib/allure_report_publisher/lib/uploaders/_uploader.rb +52 -13
- data/lib/allure_report_publisher/lib/uploaders/s3_uploader.rb +12 -14
- data/lib/allure_report_publisher/version.rb +1 -1
- metadata +15 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7267f00f39421165f5b1fb7c4e975cff6e856d7ff321bf5b90ac7ab629fff6a
|
4
|
+
data.tar.gz: 6189da5c7b8743ee4fb102b01f07e9e419996a249b90a8a43601658f2c1ef6cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52e25db16ed4068c4556162fd4bfe917b138f2e814dd2d0bf6a019b8dd462014ba7af39cbc6ebe62f0d547bee4ca5ea0813e0719f138fb4cc0890ee2f501ea33
|
7
|
+
data.tar.gz: 6e1a0903f7923fd2abb0538819f24fce3530827280dd1e568be1dc16942f8bdbdca2c03fe4816e7d3bb00d3b631cfe8a7d4bea0f9af77f3e6c8a9afcfed4ab62
|
data/README.md
CHANGED
@@ -1,22 +1,37 @@
|
|
1
|
+
[![Gem Version](https://img.shields.io/gem/v/allure-report-publisher?color=red)](https://rubygems.org/gems/allure-report-publisher)
|
2
|
+
[![Docker Image Version (latest semver)](https://img.shields.io/docker/v/andrcuns/allure-report-publisher?color=blue&label=docker&sort=semver)](https://hub.docker.com/r/andrcuns/allure-report-publisher)
|
3
|
+
![Workflow status](https://github.com/andrcuns/allure-report-publisher/workflows/Test/badge.svg)
|
1
4
|
[![Maintainability](https://api.codeclimate.com/v1/badges/210eaa4f74588fb08313/maintainability)](https://codeclimate.com/github/andrcuns/allure-report-publisher/maintainability)
|
2
5
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/210eaa4f74588fb08313/test_coverage)](https://codeclimate.com/github/andrcuns/allure-report-publisher/test_coverage)
|
3
6
|
|
4
|
-
# allure-report-
|
7
|
+
# allure-report-publisher
|
5
8
|
|
6
9
|
Upload your report to a file storage of your choice.
|
7
10
|
|
11
|
+
![Demo](demo.gif)
|
12
|
+
|
8
13
|
## Installation
|
9
14
|
|
10
|
-
|
15
|
+
### Rubygems
|
16
|
+
|
17
|
+
```shell
|
11
18
|
gem install allure-report-uploader
|
12
19
|
```
|
13
20
|
|
21
|
+
### Docker
|
22
|
+
|
23
|
+
```shell
|
24
|
+
docker pull andrcuns/allure-report-publisher:latest
|
25
|
+
```
|
26
|
+
|
14
27
|
## Usage
|
15
28
|
|
29
|
+
allure-report-publisher will automatically detect if used in CI environment and add relevant executor info and history
|
30
|
+
|
16
31
|
### AWS S3
|
17
32
|
|
18
33
|
```shell
|
19
|
-
$ allure-report-publisher upload s3 --help
|
34
|
+
$ (allure-report-publisher|docker run --rm andrcuns/allure-report-publisher:latest) upload s3 --help
|
20
35
|
Command:
|
21
36
|
allure-report-publisher upload s3
|
22
37
|
|
@@ -27,13 +42,15 @@ Description:
|
|
27
42
|
Generate and upload allure report
|
28
43
|
|
29
44
|
Options:
|
45
|
+
--[no-]color # Toggle color output
|
30
46
|
--result-files-glob=VALUE # Allure results files glob. Required: true
|
31
47
|
--bucket=VALUE # Bucket name. Required: true
|
32
|
-
--
|
48
|
+
--prefix=VALUE # Optional prefix for report path. Required: false
|
33
49
|
--help, -h # Print this help
|
34
50
|
|
35
51
|
Examples:
|
36
52
|
allure-report-publisher upload s3 --result-files-glob='path/to/allure-result/**/*' --bucket=my-bucket
|
53
|
+
allure-report-publisher upload s3 --result-files-glob='path/to/allure-result/**/*' --bucket=my-bucket --project=my-project/prs
|
37
54
|
```
|
38
55
|
|
39
56
|
## Development
|
@@ -44,7 +61,7 @@ To install this gem onto your local machine, run `bundle exec rake install`.
|
|
44
61
|
|
45
62
|
## Contributing
|
46
63
|
|
47
|
-
Bug reports and pull requests are welcome on GitHub at <https://github.com/andrcuns/allure-report-
|
64
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/andrcuns/allure-report-publisher>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/andrcuns/allure-report-publisher/blob/main/CODE_OF_CONDUCT.md).
|
48
65
|
|
49
66
|
## License
|
50
67
|
|
@@ -52,4 +69,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
52
69
|
|
53
70
|
## Code of Conduct
|
54
71
|
|
55
|
-
Everyone interacting in the
|
72
|
+
Everyone interacting in the allure-report-publisher project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/andrcuns/allure-report-publisher/blob/main/CODE_OF_CONDUCT.md).
|
@@ -4,7 +4,7 @@ require "require_all"
|
|
4
4
|
require "parallel"
|
5
5
|
require "dry/cli"
|
6
6
|
|
7
|
-
require_rel "allure_report_publisher/helpers"
|
7
|
+
require_rel "allure_report_publisher/lib/helpers/*.rb"
|
8
8
|
require_rel "allure_report_publisher/**/*.rb"
|
9
9
|
|
10
10
|
module Publisher
|
@@ -20,3 +20,5 @@ module Publisher
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
24
|
+
Publisher::Commands.before("upload s3") { Publisher::Helpers.validate_allure_cli_present }
|
@@ -3,26 +3,28 @@ module Publisher
|
|
3
3
|
# Upload allure report
|
4
4
|
#
|
5
5
|
class UploadS3 < Dry::CLI::Command
|
6
|
+
include CommonOptions
|
6
7
|
include Helpers
|
7
8
|
|
8
9
|
desc "Generate and upload allure report"
|
9
10
|
|
10
11
|
option :result_files_glob, desc: "Allure results files glob. Required: true"
|
11
12
|
option :bucket, desc: "Bucket name. Required: true"
|
12
|
-
option :
|
13
|
+
option :prefix, desc: "Optional prefix for report path. Required: false"
|
13
14
|
|
14
15
|
example [
|
15
16
|
"--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
|
+
"--result-files-glob='path/to/allure-result/**/*' --bucket=my-bucket --project=my-project/prs"
|
17
18
|
]
|
18
19
|
|
19
20
|
def call(**args)
|
20
21
|
validate_args(args)
|
22
|
+
Helpers.pastel(force_color: args[:color])
|
21
23
|
|
22
24
|
Uploaders::S3.new(
|
23
25
|
args[:result_files_glob],
|
24
26
|
args[:bucket],
|
25
|
-
args[:
|
27
|
+
args[:prefix]
|
26
28
|
).execute
|
27
29
|
end
|
28
30
|
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Publisher
|
2
|
+
# CI provider utilities
|
3
|
+
#
|
4
|
+
module CI
|
5
|
+
# Detect CI provider
|
6
|
+
#
|
7
|
+
# @return [Publisher::CI::Base]
|
8
|
+
def self.provider
|
9
|
+
return GithubActions if ENV["GITHUB_WORKFLOW"]
|
10
|
+
end
|
11
|
+
|
12
|
+
# Base class for CI executor info
|
13
|
+
#
|
14
|
+
class Base
|
15
|
+
EXECUTOR_JSON = "executor.json".freeze
|
16
|
+
|
17
|
+
def initialize(results_path, report_url)
|
18
|
+
@results_path = results_path
|
19
|
+
@report_url = report_url
|
20
|
+
end
|
21
|
+
|
22
|
+
# :nocov:
|
23
|
+
|
24
|
+
# Get ci run ID without creating instance of ci provider
|
25
|
+
#
|
26
|
+
# @return [String]
|
27
|
+
def self.run_id
|
28
|
+
raise("Not implemented!")
|
29
|
+
end
|
30
|
+
# :nocov:
|
31
|
+
|
32
|
+
# Write executor info file
|
33
|
+
#
|
34
|
+
# @return [void]
|
35
|
+
def write_executor_info
|
36
|
+
File.open("#{results_path}/#{EXECUTOR_JSON}", "w") do |file|
|
37
|
+
file.write(executor_info.to_json)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
attr_reader :results_path, :report_url
|
44
|
+
|
45
|
+
# :nocov:
|
46
|
+
|
47
|
+
# Get executor info
|
48
|
+
#
|
49
|
+
# @return [Hash]
|
50
|
+
def executor_info
|
51
|
+
raise("Not implemented!")
|
52
|
+
end
|
53
|
+
# :nocov:
|
54
|
+
|
55
|
+
# CI run id
|
56
|
+
#
|
57
|
+
# @return [String]
|
58
|
+
def run_id
|
59
|
+
self.class.run_id
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Publisher
|
2
|
+
module CI
|
3
|
+
# Github actions executor info
|
4
|
+
#
|
5
|
+
class GithubActions < Base
|
6
|
+
# Run id
|
7
|
+
#
|
8
|
+
# @return [String]
|
9
|
+
def self.run_id
|
10
|
+
@run_id ||= ENV["GITHUB_RUN_ID"]
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
# Executor info
|
16
|
+
#
|
17
|
+
# @return [Hash]
|
18
|
+
def executor_info
|
19
|
+
{
|
20
|
+
name: "Github",
|
21
|
+
type: "github",
|
22
|
+
reportName: "AllureReport",
|
23
|
+
url: server_url,
|
24
|
+
reportUrl: report_url,
|
25
|
+
buildUrl: build_url,
|
26
|
+
buildOrder: run_id,
|
27
|
+
buildName: build_name
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
# Server url
|
32
|
+
#
|
33
|
+
# @return [String]
|
34
|
+
def server_url
|
35
|
+
@server_url ||= ENV["GITHUB_SERVER_URL"]
|
36
|
+
end
|
37
|
+
|
38
|
+
# Build url
|
39
|
+
#
|
40
|
+
# @return [String]
|
41
|
+
def build_url
|
42
|
+
@build_url ||= "#{server_url}/#{ENV['GITHUB_REPOSITORY']}/actions/runs/#{run_id}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def build_name
|
46
|
+
@build_name ||= ENV["GITHUB_JOB"]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -1,18 +1,37 @@
|
|
1
|
-
require "tty-spinner"
|
2
1
|
require "pastel"
|
3
2
|
require "open3"
|
4
3
|
|
5
4
|
module Publisher
|
6
|
-
#
|
5
|
+
# Helpers
|
7
6
|
#
|
8
7
|
module Helpers
|
8
|
+
# Global instance of pastel
|
9
|
+
#
|
10
|
+
# @param [Boolean] force_color
|
11
|
+
# @return [Pastel]
|
12
|
+
def self.pastel(force_color: nil)
|
13
|
+
@pastel ||= Pastel.new(enabled: force_color)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Check allure cli is installed and executable
|
17
|
+
#
|
18
|
+
# @return [void]
|
19
|
+
def self.validate_allure_cli_present
|
20
|
+
_out, status = Open3.capture2("which allure")
|
21
|
+
return if status.success?
|
22
|
+
|
23
|
+
Helpers.error(
|
24
|
+
"Allure cli is missing! See https://docs.qameta.io/allure/#_installing_a_commandline on how to install it!"
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
9
28
|
# Colorize string
|
10
29
|
#
|
11
30
|
# @param [String] message
|
12
31
|
# @param [Symbol] color
|
13
32
|
# @return [String]
|
14
33
|
def colorize(message, color)
|
15
|
-
|
34
|
+
Helpers.pastel.decorate(message, color)
|
16
35
|
end
|
17
36
|
|
18
37
|
# Log message to stdout
|
@@ -41,27 +60,6 @@ module Publisher
|
|
41
60
|
File.join(args).to_s
|
42
61
|
end
|
43
62
|
|
44
|
-
# Execute code inside spinner
|
45
|
-
#
|
46
|
-
# @param [String] message
|
47
|
-
# @param [Boolean] auto_debrief
|
48
|
-
# @param [String] done_message
|
49
|
-
# @return [Boolean]
|
50
|
-
def spin(message, done_message: "done")
|
51
|
-
spinner = TTY::Spinner.new(
|
52
|
-
"[:spinner] #{message} ...",
|
53
|
-
format: :dots,
|
54
|
-
success_mark: colorize(TTY::Spinner::TICK, :green),
|
55
|
-
error_mark: colorize(TTY::Spinner::CROSS, :red)
|
56
|
-
)
|
57
|
-
spinner.auto_spin
|
58
|
-
yield
|
59
|
-
spinner.success(done_message)
|
60
|
-
rescue StandardError => e
|
61
|
-
spinner.error(colorize(e.message, :red))
|
62
|
-
exit(1)
|
63
|
-
end
|
64
|
-
|
65
63
|
# Execute shell command
|
66
64
|
#
|
67
65
|
# @param [String] command
|
@@ -72,5 +70,7 @@ module Publisher
|
|
72
70
|
|
73
71
|
out
|
74
72
|
end
|
73
|
+
|
74
|
+
module_function :colorize, :log, :error, :path, :execute_shell
|
75
75
|
end
|
76
76
|
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require "tty-spinner"
|
2
|
+
|
3
|
+
module Publisher
|
4
|
+
# Helpers
|
5
|
+
#
|
6
|
+
module Helpers
|
7
|
+
# Spinner helper class
|
8
|
+
#
|
9
|
+
class Spinner
|
10
|
+
include Helpers
|
11
|
+
|
12
|
+
def initialize(spinner_message, exit_on_error: true)
|
13
|
+
@spinner_message = spinner_message
|
14
|
+
@exit_on_error = exit_on_error
|
15
|
+
end
|
16
|
+
|
17
|
+
# Run code block inside spinner
|
18
|
+
#
|
19
|
+
# @param [String] spinner_message
|
20
|
+
# @param [String] done_message
|
21
|
+
# @param [Boolean] exit_on_error
|
22
|
+
# @param [Proc] &block
|
23
|
+
# @return [void]
|
24
|
+
def self.spin(spinner_message, done_message: "done", exit_on_error: true, &block)
|
25
|
+
new(spinner_message, exit_on_error: exit_on_error).spin(done_message, &block)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Run code block inside spinner
|
29
|
+
#
|
30
|
+
# @param [String] done_message
|
31
|
+
# @return [Boolean]
|
32
|
+
def spin(done_message = "done")
|
33
|
+
spinner.auto_spin
|
34
|
+
yield
|
35
|
+
spinner_success(done_message)
|
36
|
+
rescue StandardError => e
|
37
|
+
spinner_error(e.message)
|
38
|
+
exit(1) if exit_on_error
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
attr_reader :spinner_message, :exit_on_error
|
45
|
+
|
46
|
+
# Error message color
|
47
|
+
#
|
48
|
+
# @return [Symbol]
|
49
|
+
def error_color
|
50
|
+
@error_color ||= exit_on_error ? :red : :yellow
|
51
|
+
end
|
52
|
+
|
53
|
+
# Success mark
|
54
|
+
#
|
55
|
+
# @return [String]
|
56
|
+
def success_mark
|
57
|
+
@success_mark ||= colorize(TTY::Spinner::TICK, :green)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Error mark
|
61
|
+
#
|
62
|
+
# @return [String]
|
63
|
+
def error_mark
|
64
|
+
colorize(TTY::Spinner::CROSS, error_color)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Spinner instance
|
68
|
+
#
|
69
|
+
# @return [TTY::Spinner]
|
70
|
+
def spinner
|
71
|
+
@spinner ||= TTY::Spinner.new(
|
72
|
+
"[:spinner] #{spinner_message} ...",
|
73
|
+
format: :dots,
|
74
|
+
success_mark: success_mark,
|
75
|
+
error_mark: error_mark
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Check tty
|
80
|
+
#
|
81
|
+
# @return [Boolean]
|
82
|
+
def tty?
|
83
|
+
spinner.send(:tty?)
|
84
|
+
end
|
85
|
+
|
86
|
+
# Return spinner success
|
87
|
+
#
|
88
|
+
# @param [String] done_message
|
89
|
+
# @return [void]
|
90
|
+
def spinner_success(done_message)
|
91
|
+
return spinner.success(done_message) if tty?
|
92
|
+
|
93
|
+
spinner.stop
|
94
|
+
puts("[#{success_mark}] #{spinner_message} ... #{done_message}")
|
95
|
+
end
|
96
|
+
|
97
|
+
# Return spinner error
|
98
|
+
#
|
99
|
+
# @param [String] error_message
|
100
|
+
# @return [void]
|
101
|
+
def spinner_error(error_message)
|
102
|
+
colored_message = colorize(error_message, error_color)
|
103
|
+
return spinner.error(colored_message) if tty?
|
104
|
+
|
105
|
+
spinner.stop
|
106
|
+
puts("[#{error_mark}] #{spinner_message} ... #{colored_message}")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -20,8 +20,8 @@ module Publisher
|
|
20
20
|
#
|
21
21
|
# @return [void]
|
22
22
|
def generate
|
23
|
-
log("
|
24
|
-
spin("generating report") do
|
23
|
+
log("Generating allure report")
|
24
|
+
Helpers::Spinner.spin("generating report") do
|
25
25
|
aggregate_results
|
26
26
|
generate_report
|
27
27
|
end
|
@@ -13,22 +13,27 @@ module Publisher
|
|
13
13
|
"retry-trend.json"
|
14
14
|
].freeze
|
15
15
|
|
16
|
-
def initialize(results_glob, bucket,
|
16
|
+
def initialize(results_glob, bucket, prefix = nil)
|
17
17
|
@results_glob = results_glob
|
18
18
|
@bucket = bucket
|
19
|
-
@
|
19
|
+
@prefix = prefix
|
20
20
|
end
|
21
21
|
|
22
|
+
# :nocov:
|
23
|
+
|
22
24
|
# Execute allure report generation and upload
|
23
25
|
#
|
24
26
|
# @return [void]
|
25
27
|
def execute
|
26
28
|
raise(StandardError, "Not Implemented!")
|
27
29
|
end
|
30
|
+
# :nocov:
|
28
31
|
|
29
32
|
private
|
30
33
|
|
31
|
-
attr_reader :results_glob, :bucket, :
|
34
|
+
attr_reader :results_glob, :bucket, :prefix
|
35
|
+
|
36
|
+
# :nocov:
|
32
37
|
|
33
38
|
# Report url
|
34
39
|
#
|
@@ -36,6 +41,46 @@ module Publisher
|
|
36
41
|
def report_url
|
37
42
|
raise(StandardError, "Not Implemented!")
|
38
43
|
end
|
44
|
+
# :nocov:
|
45
|
+
|
46
|
+
# Get run id
|
47
|
+
#
|
48
|
+
# @return [String]
|
49
|
+
def run_id
|
50
|
+
@run_id ||= CI.provider&.run_id
|
51
|
+
end
|
52
|
+
|
53
|
+
# Get CI provider
|
54
|
+
#
|
55
|
+
# @return [Publisher::CI::Base]
|
56
|
+
def ci_provider
|
57
|
+
return @ci_provider if defined?(@ci_provider)
|
58
|
+
|
59
|
+
@ci_provider = CI.provider&.new(results_dir, report_url)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Add allure history
|
63
|
+
#
|
64
|
+
# @return [void]
|
65
|
+
def add_history
|
66
|
+
log("Adding allure history")
|
67
|
+
Helpers::Spinner.spin("adding history", exit_on_error: false) do
|
68
|
+
create_history_dir
|
69
|
+
yield
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Add CI executor info
|
74
|
+
#
|
75
|
+
# @return [void]
|
76
|
+
def add_executor_info
|
77
|
+
return unless ci_provider
|
78
|
+
|
79
|
+
log("Adding executor info")
|
80
|
+
Helpers::Spinner.spin("adding") do
|
81
|
+
ci_provider.write_executor_info
|
82
|
+
end
|
83
|
+
end
|
39
84
|
|
40
85
|
# Fetch allure report history
|
41
86
|
#
|
@@ -47,21 +92,14 @@ module Publisher
|
|
47
92
|
# Report path prefix
|
48
93
|
#
|
49
94
|
# @return [String]
|
50
|
-
def
|
51
|
-
@
|
95
|
+
def full_prefix
|
96
|
+
@full_prefix ||= [prefix, run_id].compact.yield_self do |pre|
|
52
97
|
break if pre.empty?
|
53
98
|
|
54
99
|
pre.join("/")
|
55
100
|
end
|
56
101
|
end
|
57
102
|
|
58
|
-
# Run ID
|
59
|
-
#
|
60
|
-
# @return [String]
|
61
|
-
def run_id
|
62
|
-
@run_id ||= ENV["RUN_ID"]
|
63
|
-
end
|
64
|
-
|
65
103
|
# Aggregated results directory
|
66
104
|
#
|
67
105
|
# @return [String]
|
@@ -89,7 +127,8 @@ module Publisher
|
|
89
127
|
#
|
90
128
|
# @return [void]
|
91
129
|
def generate_report
|
92
|
-
|
130
|
+
add_history
|
131
|
+
add_executor_info
|
93
132
|
|
94
133
|
ReportGenerator.new(results_glob, results_dir, report_dir).generate
|
95
134
|
end
|
@@ -16,30 +16,30 @@ module Publisher
|
|
16
16
|
#
|
17
17
|
# @return [Aws::S3::Client]
|
18
18
|
def s3
|
19
|
-
@s3 ||= Aws::S3::Client.new
|
19
|
+
@s3 ||= Aws::S3::Client.new(region: ENV["AWS_REGION"] || "us-east-1")
|
20
20
|
end
|
21
21
|
|
22
22
|
# Report url
|
23
23
|
#
|
24
24
|
# @return [String]
|
25
25
|
def report_url
|
26
|
-
@report_url ||= ["http://#{bucket}.s3.amazonaws.com",
|
26
|
+
@report_url ||= ["http://#{bucket}.s3.amazonaws.com", full_prefix, "index.html"].compact.join("/")
|
27
27
|
end
|
28
28
|
|
29
|
-
#
|
29
|
+
# Add allure history
|
30
30
|
#
|
31
31
|
# @return [void]
|
32
|
-
def
|
33
|
-
|
34
|
-
spin("fetching history") do
|
35
|
-
create_history_dir
|
32
|
+
def add_history
|
33
|
+
super do
|
36
34
|
HISTORY.each do |file|
|
37
35
|
s3.get_object(
|
38
36
|
response_target: path(results_dir, "history", file),
|
39
|
-
key: key(
|
37
|
+
key: key(prefix, "history", file),
|
40
38
|
bucket: bucket
|
41
39
|
)
|
42
40
|
end
|
41
|
+
rescue Aws::S3::Errors::NoSuchKey
|
42
|
+
raise("Allure history from previous runs not found!")
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -47,8 +47,8 @@ module Publisher
|
|
47
47
|
#
|
48
48
|
# @return [void]
|
49
49
|
def upload_history_and_report
|
50
|
-
log("
|
51
|
-
spin("uploading report", done_message: "done. #{report_url}") do
|
50
|
+
log("Uploading report to s3")
|
51
|
+
Helpers::Spinner.spin("uploading report", done_message: "done. #{report_url}") do
|
52
52
|
upload_history
|
53
53
|
upload_report
|
54
54
|
end
|
@@ -58,9 +58,7 @@ module Publisher
|
|
58
58
|
#
|
59
59
|
# @return [void]
|
60
60
|
def upload_history
|
61
|
-
|
62
|
-
|
63
|
-
upload_to_s3(report_files.select { |file| file.fnmatch?("*/history/*") }, project)
|
61
|
+
upload_to_s3(report_files.select { |file| file.fnmatch?("*/history/*") }, prefix)
|
64
62
|
end
|
65
63
|
|
66
64
|
def upload_report
|
@@ -72,7 +70,7 @@ module Publisher
|
|
72
70
|
# @param [Array<Pathname>] files
|
73
71
|
# @param [String] key_prefix
|
74
72
|
# @return [Array<Hash>]
|
75
|
-
def upload_to_s3(files, key_prefix =
|
73
|
+
def upload_to_s3(files, key_prefix = full_prefix)
|
76
74
|
args = files.map do |file|
|
77
75
|
{
|
78
76
|
body: File.new(file),
|
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.2
|
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-04-
|
11
|
+
date: 2021-04-29 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
|
@@ -105,9 +111,13 @@ files:
|
|
105
111
|
- README.md
|
106
112
|
- bin/allure-report-publisher
|
107
113
|
- lib/allure_report_publisher.rb
|
114
|
+
- lib/allure_report_publisher/commands/base.rb
|
108
115
|
- lib/allure_report_publisher/commands/upload_s3.rb
|
109
116
|
- lib/allure_report_publisher/commands/version.rb
|
110
|
-
- lib/allure_report_publisher/
|
117
|
+
- lib/allure_report_publisher/lib/ci/_base.rb
|
118
|
+
- lib/allure_report_publisher/lib/ci/github_actions.rb
|
119
|
+
- lib/allure_report_publisher/lib/helpers/helpers.rb
|
120
|
+
- lib/allure_report_publisher/lib/helpers/spinner.rb
|
111
121
|
- lib/allure_report_publisher/lib/report_generator.rb
|
112
122
|
- lib/allure_report_publisher/lib/uploaders/_uploader.rb
|
113
123
|
- lib/allure_report_publisher/lib/uploaders/s3_uploader.rb
|