allure-report-publisher 0.2.0 → 0.3.3
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 +74 -16
- data/lib/allure_report_publisher/commands/upload.rb +12 -4
- data/lib/allure_report_publisher/lib/providers/gitlab.rb +46 -15
- data/lib/allure_report_publisher/lib/providers/url_section_builder.rb +4 -4
- data/lib/allure_report_publisher/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54d60b7dd8fe199bba542f83cdaf9cab784417050c4fa81f114ea40de9a2227e
|
4
|
+
data.tar.gz: 486c1f70aa161a59277cfb01b5986fa145b2c4e4cf1231b22a064f959195551c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a303ddf16eeeca0db453aaed7ff554b1214a1b8f9b9c51af6dc27ca082c8c4ba002001b1e4c681e72340302ed42d95c3f2934cd45ed2bab0a6bcd7d29af33751
|
7
|
+
data.tar.gz: 7688b003e010562c258fa4c705c5736df82e8ff71264ecb21f89275f1027d0b0631f504e23b877ff419a37689d07100f6b159f47647387ab9b7f4db08ca6b54e
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# allure-report-publisher
|
2
|
+
|
1
3
|
[](https://rubygems.org/gems/allure-report-publisher)
|
2
4
|
[](https://rubygems.org/gems/allure-report-publisher)
|
3
5
|
[](https://hub.docker.com/r/andrcuns/allure-report-publisher)
|
@@ -7,31 +9,25 @@
|
|
7
9
|
[](https://codeclimate.com/github/andrcuns/allure-report-publisher/maintainability)
|
8
10
|
[](https://codeclimate.com/github/andrcuns/allure-report-publisher/test_coverage)
|
9
11
|
|
10
|
-
# allure-report-publisher
|
11
|
-
|
12
12
|
Upload your report to a file storage of your choice.
|
13
13
|
|
14
14
|

|
15
15
|
|
16
|
-
|
16
|
+
# Installation
|
17
17
|
|
18
|
-
|
18
|
+
## Rubygems
|
19
19
|
|
20
20
|
```shell
|
21
21
|
gem install allure-report-uploader
|
22
22
|
```
|
23
23
|
|
24
|
-
|
24
|
+
## Docker
|
25
25
|
|
26
26
|
```shell
|
27
27
|
docker pull andrcuns/allure-report-publisher:latest
|
28
28
|
```
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
allure-report-publisher will automatically detect if used in CI environment and add relevant executor info and history
|
33
|
-
|
34
|
-
- `--update-pr=(comment|description)`: requires `GITHUB_AUTH_TOKEN` or `GITLAB_AUTH_TOKEN` in order to update pull request with links to allure reports
|
30
|
+
# Usage
|
35
31
|
|
36
32
|
```shell
|
37
33
|
$ (allure-report-publisher|docker run --rm andrcuns/allure-report-publisher:latest) upload --help
|
@@ -54,6 +50,7 @@ Options:
|
|
54
50
|
--update-pr=VALUE # Add report url to PR via comment or description update. Required: false: (comment/description)
|
55
51
|
--[no-]copy-latest # Keep copy of latest report at base prefix path, default: false
|
56
52
|
--[no-]color # Toggle color output, default: false
|
53
|
+
--[no-]ignore-missing-results # Ignore missing allure results, default: false
|
57
54
|
--help, -h # Print this help
|
58
55
|
|
59
56
|
Examples:
|
@@ -61,11 +58,15 @@ Examples:
|
|
61
58
|
allure-report-publisher upload gcs --results-glob='path/to/allure-result/**/*' --bucket=my-bucket --prefix=my-project/prs
|
62
59
|
```
|
63
60
|
|
64
|
-
|
61
|
+
# Storage providers
|
62
|
+
|
63
|
+
Multiple cloud storage providers are supported
|
64
|
+
|
65
|
+
## AWS S3
|
65
66
|
|
66
67
|
Requires environment variables `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` or credentials file `~/.aws/credentials`
|
67
68
|
|
68
|
-
|
69
|
+
## Google Cloud Storage
|
69
70
|
|
70
71
|
Requires on of the following environment variables.
|
71
72
|
|
@@ -86,20 +87,77 @@ credentials.json contents:
|
|
86
87
|
- `GOOGLE_CLOUD_KEYFILE_JSON`
|
87
88
|
- `GCLOUD_KEYFILE_JSON`
|
88
89
|
|
89
|
-
|
90
|
+
# CI
|
91
|
+
|
92
|
+
`allure-report-publisher` will automatically detect if used in CI environment and add relevant executor info and history.
|
93
|
+
|
94
|
+
Following CI providers are supported:
|
95
|
+
|
96
|
+
- Github Actions
|
97
|
+
- Gitlab CI
|
98
|
+
|
99
|
+
## Pull requests
|
100
|
+
|
101
|
+
It is possible to update pull requests with urls to published reports.
|
102
|
+
|
103
|
+
- `--update-pr=(comment|description)`: post report urls in pr description or as a comment
|
104
|
+
|
105
|
+
Example:
|
106
|
+
|
107
|
+
---
|
108
|
+
|
109
|
+
`# Allure report`
|
110
|
+
|
111
|
+
`allure-report-publisher` generated test report for [1b756f48](https://github.com/andrcuns/allure-report-publisher/commit/HEAD)!
|
112
|
+
|
113
|
+
**rspec**: 📝 [test report](https://storage.googleapis.com/allure-test-reports/allure-report-publisher/refs/heads/main/index.html)
|
114
|
+
|
115
|
+
---
|
116
|
+
|
117
|
+
## Github Actions
|
118
|
+
|
119
|
+
Additional configuration is done via environment variables
|
120
|
+
|
121
|
+
Authentication for PR updates:
|
122
|
+
|
123
|
+
- `GITHUB_AUTH_TOKEN`: github auth token with api access
|
124
|
+
|
125
|
+
Following environment variables can override default CI values:
|
126
|
+
|
127
|
+
- `ALLURE_JOB_NAME`: overrides default `GITHUB_JOB` value which is used as name for report url section
|
128
|
+
|
129
|
+
## Gitlab CI
|
130
|
+
|
131
|
+
Additional configuration is done via environment variables
|
132
|
+
|
133
|
+
Authentication for MR updates:
|
134
|
+
|
135
|
+
- `GITLAB_AUTH_TOKEN`: gitlab access token with api access
|
136
|
+
|
137
|
+
Following environment variables can override default CI values:
|
138
|
+
|
139
|
+
- `ALLURE_JOB_NAME`: overrides default `CI_JOB_NAME` value which is used as name for report url section
|
140
|
+
|
141
|
+
In case merge request triggers a downstream pipeline yet you want to update original merge request, overriding following environment variables might be useful:
|
142
|
+
|
143
|
+
- `ALLURE_PROJECT_PATH`: overrides default `CI_PROJECT_PATH` value
|
144
|
+
- `ALLURE_MERGE_REQUEST_IID`: overrides default `CI_MERGE_REQUEST_IID` value
|
145
|
+
- `ALLURE_COMMIT_SHA`: overrides default `CI_MERGE_REQUEST_SOURCE_BRANCH_SHA` or `CI_COMMIT_SHA` values
|
146
|
+
|
147
|
+
# Development
|
90
148
|
|
91
149
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
92
150
|
|
93
151
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
94
152
|
|
95
|
-
|
153
|
+
# Contributing
|
96
154
|
|
97
155
|
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).
|
98
156
|
|
99
|
-
|
157
|
+
# License
|
100
158
|
|
101
159
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
102
160
|
|
103
|
-
|
161
|
+
# Code of Conduct
|
104
162
|
|
105
163
|
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).
|
@@ -31,6 +31,10 @@ module Publisher
|
|
31
31
|
type: :boolean,
|
32
32
|
default: false,
|
33
33
|
desc: "Toggle color output"
|
34
|
+
option :ignore_missing_results,
|
35
|
+
type: :boolean,
|
36
|
+
default: false,
|
37
|
+
desc: "Ignore missing allure results"
|
34
38
|
|
35
39
|
example [
|
36
40
|
"s3 --results-glob='path/to/allure-result/**/*' --bucket=my-bucket",
|
@@ -38,10 +42,11 @@ module Publisher
|
|
38
42
|
]
|
39
43
|
|
40
44
|
def call(**args)
|
41
|
-
validate_args(args)
|
42
|
-
validate_result_files(args[:results_glob])
|
43
45
|
Helpers.pastel(force_color: args[:color] || nil)
|
44
46
|
|
47
|
+
validate_args(args)
|
48
|
+
validate_result_files(args[:results_glob], args[:ignore_missing_results])
|
49
|
+
|
45
50
|
uploader = uploaders(args[:type]).new(**args.slice(:results_glob, :bucket, :prefix, :copy_latest, :update_pr))
|
46
51
|
|
47
52
|
log("Generating allure report")
|
@@ -82,8 +87,11 @@ module Publisher
|
|
82
87
|
#
|
83
88
|
# @param [String] results_glob
|
84
89
|
# @return [void]
|
85
|
-
def validate_result_files(results_glob)
|
86
|
-
Dir.glob(results_glob).empty?
|
90
|
+
def validate_result_files(results_glob, ignore)
|
91
|
+
return unless Dir.glob(results_glob).empty?
|
92
|
+
|
93
|
+
log("Glob '#{results_glob}' did not match any files!", ignore ? :yellow : :red)
|
94
|
+
exit(ignore ? 0 : 1)
|
87
95
|
end
|
88
96
|
end
|
89
97
|
end
|
@@ -16,7 +16,7 @@ module Publisher
|
|
16
16
|
#
|
17
17
|
# @return [Boolean]
|
18
18
|
def pr?
|
19
|
-
ENV["CI_PIPELINE_SOURCE"] == "merge_request_event"
|
19
|
+
(allure_project && allure_mr_iid) || ENV["CI_PIPELINE_SOURCE"] == "merge_request_event"
|
20
20
|
end
|
21
21
|
|
22
22
|
# Get executor info
|
@@ -74,59 +74,90 @@ module Publisher
|
|
74
74
|
# @return [Gitlab::Client]
|
75
75
|
def client
|
76
76
|
@client ||= begin
|
77
|
-
raise("Missing GITLAB_AUTH_TOKEN environment variable!") unless
|
77
|
+
raise("Missing GITLAB_AUTH_TOKEN environment variable!") unless env("GITLAB_AUTH_TOKEN")
|
78
78
|
|
79
79
|
::Gitlab::Client.new(
|
80
80
|
endpoint: "#{server_url}/api/v4",
|
81
|
-
private_token:
|
81
|
+
private_token: env("GITLAB_AUTH_TOKEN")
|
82
82
|
)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
+
# Custom repository name
|
87
|
+
#
|
88
|
+
# @return [String]
|
89
|
+
def allure_project
|
90
|
+
@allure_project ||= env("ALLURE_PROJECT_PATH")
|
91
|
+
end
|
92
|
+
|
93
|
+
# Custom mr iid name
|
94
|
+
#
|
95
|
+
# @return [String]
|
96
|
+
def allure_mr_iid
|
97
|
+
@allure_mr_iid ||= env("ALLURE_MERGE_REQUEST_IID")
|
98
|
+
end
|
99
|
+
|
100
|
+
# Custom sha
|
101
|
+
#
|
102
|
+
# @return [String]
|
103
|
+
def allure_sha
|
104
|
+
@allure_sha ||= env("ALLURE_COMMIT_SHA")
|
105
|
+
end
|
106
|
+
|
107
|
+
# Gitlab project path
|
108
|
+
#
|
109
|
+
# @return [String]
|
110
|
+
def project
|
111
|
+
@project ||= allure_project || env("CI_PROJECT_PATH")
|
112
|
+
end
|
113
|
+
|
86
114
|
# Merge request iid
|
87
115
|
#
|
88
116
|
# @return [Integer]
|
89
117
|
def mr_iid
|
90
|
-
@mr_iid ||=
|
118
|
+
@mr_iid ||= allure_mr_iid || env("CI_MERGE_REQUEST_IID")
|
91
119
|
end
|
92
120
|
|
93
121
|
# Server url
|
94
122
|
#
|
95
123
|
# @return [String]
|
96
124
|
def server_url
|
97
|
-
@server_url ||=
|
125
|
+
@server_url ||= env("CI_SERVER_URL")
|
98
126
|
end
|
99
127
|
|
100
128
|
# Build url
|
101
129
|
#
|
102
130
|
# @return [String]
|
103
131
|
def build_url
|
104
|
-
@build_url ||=
|
132
|
+
@build_url ||= env("CI_PIPELINE_URL")
|
105
133
|
end
|
106
134
|
|
107
135
|
# Job name
|
108
136
|
#
|
109
137
|
# @return [String]
|
110
138
|
def build_name
|
111
|
-
@build_name ||=
|
112
|
-
end
|
113
|
-
|
114
|
-
# Gitlab repository
|
115
|
-
#
|
116
|
-
# @return [String]
|
117
|
-
def project
|
118
|
-
@project ||= ENV["CI_PROJECT_PATH"]
|
139
|
+
@build_name ||= env(ALLURE_JOB_NAME) || env("CI_JOB_NAME")
|
119
140
|
end
|
120
141
|
|
121
142
|
# Commit sha url
|
122
143
|
#
|
123
144
|
# @return [String]
|
124
145
|
def sha_url
|
125
|
-
sha =
|
146
|
+
sha = allure_sha || env("CI_MERGE_REQUEST_SOURCE_BRANCH_SHA") || env("CI_COMMIT_SHA")
|
126
147
|
short_sha = sha[0..7]
|
127
148
|
|
128
149
|
"[#{short_sha}](#{server_url}/#{project}/-/merge_requests/#{mr_iid}/diffs?commit_id=#{sha})"
|
129
150
|
end
|
151
|
+
|
152
|
+
# Return non empty environment variable value
|
153
|
+
#
|
154
|
+
# @param [String] name
|
155
|
+
# @return [String, nil]
|
156
|
+
def env(name)
|
157
|
+
return unless ENV[name] && !ENV[name].empty?
|
158
|
+
|
159
|
+
ENV[name]
|
160
|
+
end
|
130
161
|
end
|
131
162
|
end
|
132
163
|
end
|
@@ -48,7 +48,7 @@ module Publisher
|
|
48
48
|
# Allure report url pr description
|
49
49
|
#
|
50
50
|
# @return [String]
|
51
|
-
def body(job_entries =
|
51
|
+
def body(job_entries = job_entry)
|
52
52
|
@body ||= <<~BODY.strip
|
53
53
|
<!-- allure -->
|
54
54
|
---
|
@@ -65,7 +65,7 @@ module Publisher
|
|
65
65
|
#
|
66
66
|
# @return [String]
|
67
67
|
def heading
|
68
|
-
@heading ||= "# Allure report\n`allure-report-publisher` generated
|
68
|
+
@heading ||= "# Allure report\n`allure-report-publisher` generated test report for #{sha_url}!"
|
69
69
|
end
|
70
70
|
|
71
71
|
# Return updated jobs section
|
@@ -83,14 +83,14 @@ module Publisher
|
|
83
83
|
#
|
84
84
|
# @return [String]
|
85
85
|
def job_entry
|
86
|
-
@job_entry ||= "**#{build_name}**: 📝 [
|
86
|
+
@job_entry ||= "**#{build_name}**: 📝 [test report](#{report_url})<br />"
|
87
87
|
end
|
88
88
|
|
89
89
|
# Job entry pattern
|
90
90
|
#
|
91
91
|
# @return [RegExp]
|
92
92
|
def job_entry_pattern
|
93
|
-
@job_entry_pattern ||=
|
93
|
+
@job_entry_pattern ||= %r{^\*\*#{build_name}\*\*:.*\[test report\]\(.*\)<br />$}
|
94
94
|
end
|
95
95
|
end
|
96
96
|
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.
|
4
|
+
version: 0.3.3
|
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-06-12 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.
|
22
|
+
version: 1.97.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.
|
32
|
+
version: 1.97.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: dry-cli
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|