allure-report-publisher 0.1.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2212afd20c080df89b88eab18ae8fa96a6b8d00027af95b2b606e9b851b83dde
4
- data.tar.gz: b6473ed381ddb267af1fcaee0ef6080a3c8063dac4d56ea5cbf0589457c7598e
3
+ metadata.gz: 95dbd5a6e6f9c26a3a2e3623be240fdd6946acd1be0bbab199ba17f764b7dab4
4
+ data.tar.gz: 1f59fb0652c77dfed7178cae2c6d44cbf7308471c545f17df421998398d5d939
5
5
  SHA512:
6
- metadata.gz: e28a752bdaaf619bf293c6a4f995a17e7cdea913c6c1c89be07dcb14c575a2b78264bbb6fad03d2b1ec574c2d0c72fd04ce84431e7920e6ac7180b5f4006c54c
7
- data.tar.gz: aa8f768c03494a14b6dcafc9ada76764b028f750f6ff104627bb669c431321074fbac76ae81ab84df6510988d7cf161a9863c796c6615e343193ae2708979419
6
+ metadata.gz: 72825f58185c1096d04c39733fb3292c87135681793fd9818e052dbe770204b6d9eb28b305a59df3b1d07536b723b48b2229993f1786eee279fb2c3bfc05e7a7
7
+ data.tar.gz: 43ef3a41b8f81f7d067dbba7602e37d9e8ed574ffc7e7d8dbd696a39fedc85e05c92ed90b4ee713c8c9619fd537bd3a062d6da662242aaefad7d377c28d34778
data/README.md CHANGED
@@ -1,35 +1,33 @@
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)
4
+ [![Gem Pulls](https://img.shields.io/gem/dt/allure-report-publisher)](https://rubygems.org/gems/allure-report-publisher)
2
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)
6
+ [![Docker Pulls](https://img.shields.io/docker/pulls/andrcuns/allure-report-publisher)](https://hub.docker.com/r/andrcuns/allure-report-publisher)
3
7
  ![Workflow status](https://github.com/andrcuns/allure-report-publisher/workflows/Test/badge.svg)
4
- [![Test Report](https://img.shields.io/badge/report-allure-blue.svg)](http://allure-reports-andrcuns.s3.amazonaws.com/allure-report-publisher/refs/heads/main/index.html)
8
+ [![Test Report](https://img.shields.io/badge/report-allure-blue.svg)](https://storage.googleapis.com/allure-test-reports/allure-report-publisher/refs/heads/main/index.html)
5
9
  [![Maintainability](https://api.codeclimate.com/v1/badges/210eaa4f74588fb08313/maintainability)](https://codeclimate.com/github/andrcuns/allure-report-publisher/maintainability)
6
10
  [![Test Coverage](https://api.codeclimate.com/v1/badges/210eaa4f74588fb08313/test_coverage)](https://codeclimate.com/github/andrcuns/allure-report-publisher/test_coverage)
7
11
 
8
- # allure-report-publisher
9
-
10
12
  Upload your report to a file storage of your choice.
11
13
 
12
14
  ![Demo](demo.gif)
13
15
 
14
- ## Installation
16
+ # Installation
15
17
 
16
- ### Rubygems
18
+ ## Rubygems
17
19
 
18
20
  ```shell
19
21
  gem install allure-report-uploader
20
22
  ```
21
23
 
22
- ### Docker
24
+ ## Docker
23
25
 
24
26
  ```shell
25
27
  docker pull andrcuns/allure-report-publisher:latest
26
28
  ```
27
29
 
28
- ## Usage
29
-
30
- allure-report-publisher will automatically detect if used in CI environment and add relevant executor info and history
31
-
32
- - `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
33
31
 
34
32
  ```shell
35
33
  $ (allure-report-publisher|docker run --rm andrcuns/allure-report-publisher:latest) upload --help
@@ -43,44 +41,122 @@ Description:
43
41
  Generate and upload allure report
44
42
 
45
43
  Arguments:
46
- TYPE # REQUIRED Cloud storage type: (s3/gcs)
44
+ TYPE # REQUIRED Cloud storage type: (s3/gcs)
47
45
 
48
46
  Options:
49
- --results-glob=VALUE # Allure results files glob. Required: true
50
- --bucket=VALUE # Bucket name. Required: true
51
- --prefix=VALUE # Optional prefix for report path. Required: false
52
- --[no-]update-pr # Update pull request description with url to allure report, default: false
53
- --[no-]copy-latest # Keep copy of latest report at base prefix path, default: false
54
- --[no-]color # Toggle color output, default: false
55
- --help, -h # Print this help
47
+ --results-glob=VALUE # Allure results files glob. Required: true
48
+ --bucket=VALUE # Bucket name. Required: true
49
+ --prefix=VALUE # Optional prefix for report path. Required: false
50
+ --update-pr=VALUE # Add report url to PR via comment or description update. Required: false: (comment/description)
51
+ --[no-]copy-latest # Keep copy of latest report at base prefix path, default: false
52
+ --[no-]color # Toggle color output, default: false
53
+ --help, -h # Print this help
56
54
 
57
55
  Examples:
58
56
  allure-report-publisher upload s3 --results-glob='path/to/allure-result/**/*' --bucket=my-bucket
59
57
  allure-report-publisher upload gcs --results-glob='path/to/allure-result/**/*' --bucket=my-bucket --prefix=my-project/prs
60
58
  ```
61
59
 
62
- ### AWS S3
60
+ # Storage providers
61
+
62
+ Multiple cloud storage providers are supported
63
+
64
+ ## AWS S3
65
+
66
+ Requires environment variables `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` or credentials file `~/.aws/credentials`
67
+
68
+ ## Google Cloud Storage
69
+
70
+ Requires on of the following environment variables.
71
+
72
+ credentials.json file location:
73
+
74
+ - `STORAGE_CREDENTIALS`
75
+ - `STORAGE_KEYFILE`
76
+ - `GOOGLE_CLOUD_CREDENTIALS`
77
+ - `GOOGLE_CLOUD_KEYFILE`
78
+ - `GCLOUD_KEYFILE`
79
+
80
+ credentials.json contents:
81
+
82
+ - `GOOGLE_CLOUD_CREDENTIALS_JSON`
83
+ - `STORAGE_CREDENTIALS_JSON`
84
+ - `STORAGE_KEYFILE_JSON`
85
+ - `GOOGLE_CLOUD_CREDENTIALS_JSON`
86
+ - `GOOGLE_CLOUD_KEYFILE_JSON`
87
+ - `GCLOUD_KEYFILE_JSON`
88
+
89
+ # CI
90
+
91
+ `allure-report-publisher` will automatically detect if used in CI environment and add relevant executor info and history.
92
+
93
+ Following CI providers are supported:
94
+
95
+ - Github Actions
96
+ - Gitlab CI
97
+
98
+ ## Pull requests
99
+
100
+ It is possible to update pull requests with urls to published reports.
101
+
102
+ - `--update-pr=(comment|description)`: post report urls in pr description or as a comment
103
+
104
+ Example:
105
+
106
+ ---
107
+
108
+ `# Allure report`
109
+
110
+ `allure-report-publisher` generated test report for [1b756f48](https://github.com/andrcuns/allure-report-publisher/commit/HEAD)!
111
+
112
+ **rspec**: 📝 [test report](https://storage.googleapis.com/allure-test-reports/allure-report-publisher/refs/heads/main/index.html)
113
+
114
+ ---
115
+
116
+ ## Github Actions
117
+
118
+ Additional configuration is done via environment variables
119
+
120
+ Authentication for PR updates:
121
+
122
+ - `GITHUB_AUTH_TOKEN`: github auth token with api access
123
+
124
+ Following environment variables can override default CI values:
125
+
126
+ - `ALLURE_JOB_NAME`: overrides default `GITHUB_JOB` value which is used as name for report url section
127
+
128
+ ## Gitlab CI
129
+
130
+ Additional configuration is done via environment variables
131
+
132
+ Authentication for MR updates:
133
+
134
+ - `GITLAB_AUTH_TOKEN`: gitlab access token with api access
135
+
136
+ Following environment variables can override default CI values:
63
137
 
64
- - `AWS authentication`: requires environment variables `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` or credentials file `~/.aws/credentials`
138
+ - `ALLURE_JOB_NAME`: overrides default `CI_JOB_NAME` value which is used as name for report url section
65
139
 
66
- ### Google Cloud Storage
140
+ In case merge request triggers a downstream pipeline yet you want to update original merge request, overriding following environment variables might be useful:
67
141
 
68
- - `GCS authentication`: requires environment variable `GOOGLE_CLOUD_CREDENTIALS_JSON` with contents of credentials.json
142
+ - `ALLURE_PROJECT_PATH`: overrides default `CI_PROJECT_PATH` value
143
+ - `ALLURE_MERGE_REQUEST_IID`: overrides default `CI_MERGE_REQUEST_IID` value
144
+ - `ALLURE_COMMIT_SHA`: overrides default `CI_MERGE_REQUEST_SOURCE_BRANCH_SHA` or `CI_COMMIT_SHA` values
69
145
 
70
- ## Development
146
+ # Development
71
147
 
72
148
  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.
73
149
 
74
150
  To install this gem onto your local machine, run `bundle exec rake install`.
75
151
 
76
- ## Contributing
152
+ # Contributing
77
153
 
78
154
  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).
79
155
 
80
- ## License
156
+ # License
81
157
 
82
158
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
83
159
 
84
- ## Code of Conduct
160
+ # Code of Conduct
85
161
 
86
162
  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).
@@ -22,7 +22,7 @@ module Publisher
22
22
  option :update_pr,
23
23
  type: :string,
24
24
  values: %w[comment description],
25
- desc: "Add report url to PR via comment or description update"
25
+ desc: "Add report url to PR via comment or description update. Required: false"
26
26
  option :copy_latest,
27
27
  type: :boolean,
28
28
  default: false,
@@ -52,7 +52,7 @@ module Publisher
52
52
  uploader.report_urls.each { |k, v| log("#{k}: #{v}", :green) }
53
53
  return unless args[:update_pr] && uploader.pr?
54
54
 
55
- log("Updating pull request description")
55
+ log("Adding reports urls")
56
56
  Spinner.spin("updating", exit_on_error: false) { uploader.add_url_to_pr }
57
57
  end
58
58
 
@@ -99,7 +99,7 @@ module Publisher
99
99
  # @param [String] error_message
100
100
  # @return [void]
101
101
  def spinner_error(error_message)
102
- colored_message = colorize(error_message, error_color)
102
+ colored_message = colorize("failed\n#{error_message}", error_color)
103
103
  return spinner.error(colored_message) if tty?
104
104
 
105
105
  spinner.stop
@@ -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
- # Commit SHA url
84
+ # Build name
86
85
  #
87
86
  # @return [String]
88
- def sha_url
87
+ def build_name
89
88
  raise("Not implemented!")
90
89
  end
91
- # :nocov:
92
90
 
93
- # Add report url as comment
91
+ # Commit SHA url
94
92
  #
95
- # @return [Boolean]
96
- def comment?
97
- update_pr == "comment"
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
- # Check if PR already has report urls
106
+ # Add report url as comment
108
107
  #
109
108
  # @return [Boolean]
110
- def reported?
111
- @reported ||= pr_description.match?(DESCRIPTION_PATTERN)
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
- # Single job report URL entry
113
+ # Report urls section creator
167
114
  #
168
- # @return [String]
169
- def job_entry
170
- @job_entry ||= "**#{build_name}**: 📝 [allure report](#{report_url})"
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].match?(DESCRIPTION_PATTERN)
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
- comment.body.match?(DESCRIPTION_PATTERN)
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 ENV["GITLAB_AUTH_TOKEN"]
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: ENV["GITLAB_AUTH_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 ||= ENV["CI_MERGE_REQUEST_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 ||= ENV["CI_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 ||= ENV["CI_PIPELINE_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 ||= ENV[ALLURE_JOB_NAME] || ENV["CI_JOB_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 = ENV["CI_MERGE_REQUEST_SOURCE_BRANCH_SHA"] || ENV["CI_COMMIT_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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Publisher
4
- VERSION = "0.1.0"
4
+ VERSION = "0.3.1"
5
5
  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.1.0
4
+ version: 0.3.1
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-21 00:00:00.000000000 Z
11
+ date: 2021-05-27 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.95.0
22
+ version: 1.96.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.95.0
32
+ version: 1.96.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