allure-report-publisher 0.1.1 → 0.3.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 +74 -16
- data/lib/allure_report_publisher/commands/upload.rb +10 -3
- data/lib/allure_report_publisher/lib/providers/_provider.rb +14 -67
- data/lib/allure_report_publisher/lib/providers/github.rb +4 -4
- data/lib/allure_report_publisher/lib/providers/gitlab.rb +50 -19
- data/lib/allure_report_publisher/lib/providers/url_section_builder.rb +97 -0
- data/lib/allure_report_publisher/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbffd321b4b96223e7e2d3d9a5a5510c9f62dd0948705d30625088ec5f3c688c
|
4
|
+
data.tar.gz: 45b8e6bdbaf9980530897b04891a6bce3ff0f3b90909de778ddde5f6e87ec093
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fba616c3eae827a4f78d0a6736f8ec06f52cd0093ea7fbc43561942490c9b142a7410812b69cb930464798fe7915a407f5abf6bff836c5e864da1f29630a94b
|
7
|
+
data.tar.gz: d9ebb7e6083ea42b23cd9e4afd9fc036b62ab37dd80c345ff4c914e58ac88d12be9113868a934eb2978bd61d260e04a8ae5545a6deff4ce403619e532ce38425
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# allure-report-publisher
|
2
|
+
|
1
3
|
[![Gem Version](https://img.shields.io/gem/v/allure-report-publisher?color=red)](https://rubygems.org/gems/allure-report-publisher)
|
2
4
|
[![Gem Pulls](https://img.shields.io/gem/dt/allure-report-publisher)](https://rubygems.org/gems/allure-report-publisher)
|
3
5
|
[![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)
|
@@ -7,31 +9,25 @@
|
|
7
9
|
[![Maintainability](https://api.codeclimate.com/v1/badges/210eaa4f74588fb08313/maintainability)](https://codeclimate.com/github/andrcuns/allure-report-publisher/maintainability)
|
8
10
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/210eaa4f74588fb08313/test_coverage)](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
|
![Demo](demo.gif)
|
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
|
-
- `Allure report link`: requires `GITHUB_AUTH_TOKEN` or `GITLAB_AUTH_TOKEN` in order to update pull request description with link to latest report
|
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",
|
@@ -39,7 +43,7 @@ module Publisher
|
|
39
43
|
|
40
44
|
def call(**args)
|
41
45
|
validate_args(args)
|
42
|
-
validate_result_files(args[:results_glob])
|
46
|
+
validate_result_files(args[:results_glob], args[:ignore_missing_results])
|
43
47
|
Helpers.pastel(force_color: args[:color] || nil)
|
44
48
|
|
45
49
|
uploader = uploaders(args[:type]).new(**args.slice(:results_glob, :bucket, :prefix, :copy_latest, :update_pr))
|
@@ -82,8 +86,11 @@ module Publisher
|
|
82
86
|
#
|
83
87
|
# @param [String] results_glob
|
84
88
|
# @return [void]
|
85
|
-
def validate_result_files(results_glob)
|
86
|
-
Dir.glob(results_glob).empty?
|
89
|
+
def validate_result_files(results_glob, ignore)
|
90
|
+
return unless Dir.glob(results_glob).empty?
|
91
|
+
|
92
|
+
log("Glob '#{results_glob}' did not match any files!", ignore ? :yellow : :red)
|
93
|
+
exit(ignore ? 0 : 1)
|
87
94
|
end
|
88
95
|
end
|
89
96
|
end
|
@@ -13,7 +13,6 @@ module Publisher
|
|
13
13
|
# Base class for CI executor info
|
14
14
|
#
|
15
15
|
class Provider
|
16
|
-
DESCRIPTION_PATTERN = /<!-- allure -->[\s\S]+<!-- allurestop -->/.freeze
|
17
16
|
ALLURE_JOB_NAME = "ALLURE_JOB_NAME".freeze
|
18
17
|
|
19
18
|
def initialize(report_url:, update_pr:)
|
@@ -82,20 +81,20 @@ module Publisher
|
|
82
81
|
raise("Not implemented!")
|
83
82
|
end
|
84
83
|
|
85
|
-
#
|
84
|
+
# Build name
|
86
85
|
#
|
87
86
|
# @return [String]
|
88
|
-
def
|
87
|
+
def build_name
|
89
88
|
raise("Not implemented!")
|
90
89
|
end
|
91
|
-
# :nocov:
|
92
90
|
|
93
|
-
#
|
91
|
+
# Commit SHA url
|
94
92
|
#
|
95
|
-
# @return [
|
96
|
-
def
|
97
|
-
|
93
|
+
# @return [String]
|
94
|
+
def sha_url
|
95
|
+
raise("Not implemented!")
|
98
96
|
end
|
97
|
+
# :nocov:
|
99
98
|
|
100
99
|
# CI run id
|
101
100
|
#
|
@@ -104,70 +103,18 @@ module Publisher
|
|
104
103
|
self.class.run_id
|
105
104
|
end
|
106
105
|
|
107
|
-
#
|
106
|
+
# Add report url as comment
|
108
107
|
#
|
109
108
|
# @return [Boolean]
|
110
|
-
def
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
# Full PR description
|
115
|
-
#
|
116
|
-
# @return [String]
|
117
|
-
def updated_pr_description
|
118
|
-
reported? ? existing_pr_description : initial_pr_descripion
|
119
|
-
end
|
120
|
-
|
121
|
-
# Updated PR description
|
122
|
-
#
|
123
|
-
# @return [String]
|
124
|
-
def existing_pr_description
|
125
|
-
pr_description.gsub(DESCRIPTION_PATTERN, pr_body).strip
|
126
|
-
end
|
127
|
-
|
128
|
-
# Initial PR description
|
129
|
-
#
|
130
|
-
# @return [String]
|
131
|
-
def initial_pr_descripion
|
132
|
-
"#{pr_description}\n\n#{pr_body}".strip
|
133
|
-
end
|
134
|
-
|
135
|
-
# Heading for report urls
|
136
|
-
#
|
137
|
-
# @return [String]
|
138
|
-
def heading
|
139
|
-
@heading ||= <<~HEADING.strip
|
140
|
-
# Allure report
|
141
|
-
`allure-report-publisher` generated allure report for #{sha_url}!
|
142
|
-
HEADING
|
143
|
-
end
|
144
|
-
|
145
|
-
# Allure report url pr description
|
146
|
-
#
|
147
|
-
# @return [String]
|
148
|
-
def pr_body
|
149
|
-
@pr_body ||= <<~DESC
|
150
|
-
<!-- allure -->
|
151
|
-
---
|
152
|
-
#{heading}
|
153
|
-
|
154
|
-
#{job_entry}
|
155
|
-
<!-- allurestop -->
|
156
|
-
DESC
|
157
|
-
end
|
158
|
-
|
159
|
-
# Allure report url comment body
|
160
|
-
#
|
161
|
-
# @return [String]
|
162
|
-
def comment_body
|
163
|
-
@comment_body ||= pr_body.gsub("---\n", "")
|
109
|
+
def comment?
|
110
|
+
update_pr == "comment"
|
164
111
|
end
|
165
112
|
|
166
|
-
#
|
113
|
+
# Report urls section creator
|
167
114
|
#
|
168
|
-
# @return [
|
169
|
-
def
|
170
|
-
@
|
115
|
+
# @return [ReportUrls]
|
116
|
+
def report_urls
|
117
|
+
@report_urls ||= UrlSectionBuilder.new(report_url: report_url, build_name: build_name, sha_url: sha_url)
|
171
118
|
end
|
172
119
|
end
|
173
120
|
end
|
@@ -58,16 +58,16 @@ module Publisher
|
|
58
58
|
#
|
59
59
|
# @return [void]
|
60
60
|
def update_pr_description
|
61
|
-
client.update_pull_request(repository, pr_id, body: updated_pr_description)
|
61
|
+
client.update_pull_request(repository, pr_id, body: report_urls.updated_pr_description(pr_description))
|
62
62
|
end
|
63
63
|
|
64
64
|
# Add comment with report url
|
65
65
|
#
|
66
66
|
# @return [void]
|
67
67
|
def add_comment
|
68
|
-
return client.add_comment(repository, pr_id, comment_body) unless comment
|
68
|
+
return client.add_comment(repository, pr_id, report_urls.comment_body) unless comment
|
69
69
|
|
70
|
-
client.update_comment(repository, comment[:id], comment_body)
|
70
|
+
client.update_comment(repository, comment[:id], report_urls.comment_body(comment[:body]))
|
71
71
|
end
|
72
72
|
|
73
73
|
# Existing comment with allure urls
|
@@ -75,7 +75,7 @@ module Publisher
|
|
75
75
|
# @return [Sawyer::Resource]
|
76
76
|
def comment
|
77
77
|
@comment ||= client.issue_comments(repository, pr_id).detect do |comment|
|
78
|
-
comment[:body]
|
78
|
+
UrlSectionBuilder.match?(comment[:body])
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -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
|
@@ -48,16 +48,16 @@ module Publisher
|
|
48
48
|
#
|
49
49
|
# @return [void]
|
50
50
|
def update_pr_description
|
51
|
-
client.update_merge_request(project, mr_iid, description: updated_pr_description)
|
51
|
+
client.update_merge_request(project, mr_iid, description: report_urls.updated_pr_description(pr_description))
|
52
52
|
end
|
53
53
|
|
54
54
|
# Add comment with report url
|
55
55
|
#
|
56
56
|
# @return [void]
|
57
57
|
def add_comment
|
58
|
-
return client.create_merge_request_comment(project, mr_iid, comment_body) unless comment
|
58
|
+
return client.create_merge_request_comment(project, mr_iid, report_urls.comment_body) unless comment
|
59
59
|
|
60
|
-
client.edit_merge_request_note(project, mr_iid, comment.id, comment_body)
|
60
|
+
client.edit_merge_request_note(project, mr_iid, comment.id, report_urls.comment_body(comment.body))
|
61
61
|
end
|
62
62
|
|
63
63
|
# Existing comment with allure urls
|
@@ -65,7 +65,7 @@ module Publisher
|
|
65
65
|
# @return [Gitlab::ObjectifiedHash]
|
66
66
|
def comment
|
67
67
|
client.merge_request_comments(project, mr_iid).auto_paginate.detect do |comment|
|
68
|
-
|
68
|
+
UrlSectionBuilder.match?(comment.body)
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -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
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Publisher
|
2
|
+
module Providers
|
3
|
+
# Urls section builder
|
4
|
+
#
|
5
|
+
class UrlSectionBuilder
|
6
|
+
DESCRIPTION_PATTERN = /<!-- allure -->[\s\S]+<!-- allurestop -->/.freeze
|
7
|
+
JOBS_PATTERN = /<!-- jobs -->\n([\s\S]+)\n<!-- jobs -->/.freeze
|
8
|
+
|
9
|
+
def initialize(report_url:, build_name:, sha_url:)
|
10
|
+
@report_url = report_url
|
11
|
+
@build_name = build_name
|
12
|
+
@sha_url = sha_url
|
13
|
+
end
|
14
|
+
|
15
|
+
# Matches url section pattern
|
16
|
+
#
|
17
|
+
# @param [String] urls_block
|
18
|
+
# @return [Boolean]
|
19
|
+
def self.match?(urls_block)
|
20
|
+
urls_block.match?(DESCRIPTION_PATTERN)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Get urls for PR update
|
24
|
+
#
|
25
|
+
# @param [String] pr
|
26
|
+
# @return [String]
|
27
|
+
def updated_pr_description(pr_description)
|
28
|
+
return "#{pr_description}\n\n#{body}" unless pr_description.match?(DESCRIPTION_PATTERN)
|
29
|
+
|
30
|
+
job_entries = jobs_section(pr_description)
|
31
|
+
pr_description.gsub(DESCRIPTION_PATTERN, body(job_entries))
|
32
|
+
end
|
33
|
+
|
34
|
+
# Allure report url comment
|
35
|
+
#
|
36
|
+
# @return [String]
|
37
|
+
def comment_body(pr_comment = nil)
|
38
|
+
return body.gsub("---\n", "") unless pr_comment
|
39
|
+
|
40
|
+
job_entries = jobs_section(pr_comment)
|
41
|
+
body(job_entries).gsub("---\n", "")
|
42
|
+
end
|
43
|
+
|
44
|
+
attr_reader :report_url, :build_name, :sha_url
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
# Allure report url pr description
|
49
|
+
#
|
50
|
+
# @return [String]
|
51
|
+
def body(job_entries = job_entry)
|
52
|
+
@body ||= <<~BODY.strip
|
53
|
+
<!-- allure -->
|
54
|
+
---
|
55
|
+
#{heading}
|
56
|
+
|
57
|
+
<!-- jobs -->
|
58
|
+
#{job_entries}
|
59
|
+
<!-- jobs -->
|
60
|
+
<!-- allurestop -->
|
61
|
+
BODY
|
62
|
+
end
|
63
|
+
|
64
|
+
# Url section heading
|
65
|
+
#
|
66
|
+
# @return [String]
|
67
|
+
def heading
|
68
|
+
@heading ||= "# Allure report\n`allure-report-publisher` generated test report for #{sha_url}!"
|
69
|
+
end
|
70
|
+
|
71
|
+
# Return updated jobs section
|
72
|
+
#
|
73
|
+
# @param [String] urls
|
74
|
+
# @return [String]
|
75
|
+
def jobs_section(urls_block)
|
76
|
+
jobs = urls_block.match(JOBS_PATTERN)[1]
|
77
|
+
return jobs.gsub(job_entry_pattern, job_entry) if jobs.match?(job_entry_pattern)
|
78
|
+
|
79
|
+
"#{jobs}\n#{job_entry}"
|
80
|
+
end
|
81
|
+
|
82
|
+
# Single job report URL entry
|
83
|
+
#
|
84
|
+
# @return [String]
|
85
|
+
def job_entry
|
86
|
+
@job_entry ||= "**#{build_name}**: 📝 [test report](#{report_url})<br />"
|
87
|
+
end
|
88
|
+
|
89
|
+
# Job entry pattern
|
90
|
+
#
|
91
|
+
# @return [RegExp]
|
92
|
+
def job_entry_pattern
|
93
|
+
@job_entry_pattern ||= %r{^\*\*#{build_name}\*\*:.*\[test report\]\(.*\)<br />$}
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
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.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-
|
11
|
+
date: 2021-06-11 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
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- lib/allure_report_publisher/lib/providers/_provider.rb
|
167
167
|
- lib/allure_report_publisher/lib/providers/github.rb
|
168
168
|
- lib/allure_report_publisher/lib/providers/gitlab.rb
|
169
|
+
- lib/allure_report_publisher/lib/providers/url_section_builder.rb
|
169
170
|
- lib/allure_report_publisher/lib/report_generator.rb
|
170
171
|
- lib/allure_report_publisher/lib/uploaders/_uploader.rb
|
171
172
|
- lib/allure_report_publisher/lib/uploaders/gcs.rb
|