allure-report-publisher 4.7.2 → 4.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a9194381dcb70e7baa4e84f45701be5a52f2092e9247b082a8728ddc1a7e50e
4
- data.tar.gz: 5831373722f1cc7fba6c15a7c560a6dbe14813c484e654ccbe8b6608997437f4
3
+ metadata.gz: 7b42958bc772951cf42ff0866ff1b6817f83a8c7adb27d1bc010d853bed1cf08
4
+ data.tar.gz: 3dbb36855c6252822622e96ce6c793fe2af42ff9d5da5bca7bf7cd6700bdd32e
5
5
  SHA512:
6
- metadata.gz: 0ae5230e086cfd5567bc08f40b6e08ddaabf0311303c8e9d8f96482f35aff969ad0e16107eb42aa59ec2ce507cad7be22c9f9080a46ee2b72a7744f3dde9fd95
7
- data.tar.gz: f58585e71f8f4277052dbf058ef22ee82c554bccb85f15c9d21157914fcee568f65a63eda029c41487f5d065ee277c0e8b41855b45249bc3eab4f1e1c8cd27d6
6
+ metadata.gz: 85f21038dff84dbe1a2d0f2ca6ab8045606d0b664d975df2b567f4cb5c532b4d49a979eb6e45afbabd92c475b7a162c71bc42e8076f25494435d906223da2c10
7
+ data.tar.gz: b7a77a045f429c315772d4e9441d55e03ed451e0ab9c2ff8fe4a9d81a3c39875f51709fc97fe23751804f5527abe2c3dcfe0f14ca5ca5252c9fb5265d34738b9
data/README.md CHANGED
@@ -48,7 +48,7 @@ Options:
48
48
  --report-name=VALUE # Custom report name in final Allure report. Required: false
49
49
  --summary=VALUE # Additionally add summary table to PR comment or description. Required: false: (behaviors/suites/packages/total), default: "total"
50
50
  --summary-table-type=VALUE # Summary table type. Required: false: (ascii/markdown), default: "ascii"
51
- --base-url=VALUE # Use custom base url instead of default cloud provider one. Required: false. Ignored for gitlab-artifacts
51
+ --base-url=VALUE # Use custom base url instead of default cloud provider one. Required: false. For gitlab-artifacts, replaces default gitlab.io pages hostname
52
52
  --parallel=VALUE # Number of parallel threads to use for report file upload to cloud storage. Required: false, default: 8
53
53
  --[no-]flaky-warning-status # Mark run with a '!' status in PR comment/description if report contains flaky tests, default: false
54
54
  --[no-]collapse-summary # Create summary as a collapsible section, default: false
@@ -57,7 +57,7 @@ module Publisher
57
57
  ]
58
58
  option :base_url,
59
59
  type: :string,
60
- desc: "Use custom base url instead of default cloud provider one. Required: false. Ignored for gitlab-artifacts"
60
+ desc: "Use custom base url instead of default cloud provider one. Required: false. For gitlab-artifacts, replaces default gitlab.io pages hostname"
61
61
  option :parallel,
62
62
  type: :integer,
63
63
  desc: "Number of parallel threads to use for report file upload to cloud storage. Required: false",
@@ -191,7 +191,7 @@ module Publisher
191
191
  #
192
192
  # @return [void]
193
193
  def validate_base_url!
194
- return unless args[:base_url] && !gitlab_artifacts?
194
+ return unless args[:base_url]
195
195
 
196
196
  URI.parse(args[:base_url])
197
197
  rescue URI::InvalidURIError
@@ -58,18 +58,11 @@ module Publisher
58
58
  @job_id ||= env_int("CI_JOB_ID")
59
59
  end
60
60
 
61
- # Gitlab pages hostname
61
+ # Full project path
62
62
  #
63
- # @return [String]
64
- def pages_hostname
65
- @pages_hostname ||= env("CI_PAGES_HOSTNAME")
66
- end
67
-
68
- # CI project name
69
- #
70
- # @return [String]
71
- def project_name
72
- @project_name ||= env("CI_PROJECT_NAME")
63
+ # @return [String] full project path
64
+ def project_path
65
+ @project_path ||= env("CI_PROJECT_PATH")
73
66
  end
74
67
 
75
68
  # CI project ID
@@ -177,6 +177,13 @@ module Publisher
177
177
  .reject(&:directory?)
178
178
  end
179
179
 
180
+ # History files array
181
+ #
182
+ # @return [Array<Pathname>]
183
+ def history_files
184
+ @history_files ||= report_files.select { |file| file.fnmatch?("*/history/*") }
185
+ end
186
+
180
187
  # Get run id
181
188
  #
182
189
  # @return [String]
@@ -41,12 +41,13 @@ module Publisher
41
41
  def download_history
42
42
  log_debug("Downloading previous run history")
43
43
  HISTORY.each do |file_name|
44
- file = bucket.file(key(prefix, "history", file_name))
44
+ source_file = key(prefix, "history", file_name)
45
+ file = bucket.file(source_file)
45
46
  raise(HistoryNotFoundError, "Allure history from previous runs not found!") unless file
46
47
 
47
48
  file_path = path(common_info_path, "history", file_name)
48
49
  file.download(file_path)
49
- log_debug("Downloaded '#{file_name}' as '#{file_path}'")
50
+ log_debug("Downloaded '#{source_file}' to '#{file_path}'")
50
51
  end
51
52
  end
52
53
 
@@ -55,7 +56,7 @@ module Publisher
55
56
  # @return [void]
56
57
  def upload_history
57
58
  log_debug("Uploading report history")
58
- upload_to_gcs(report_files.select { |file| file.fnmatch?("*/history/*") }, prefix)
59
+ upload_to_gcs(history_files, prefix)
59
60
  end
60
61
 
61
62
  # Upload allure report
@@ -5,6 +5,8 @@ module Publisher
5
5
  class GitlabArtifacts < Uploader
6
6
  extend Forwardable
7
7
 
8
+ DEFAULT_PAGES_DOMAIN = "gitlab.io".freeze
9
+
8
10
  def initialize(**args)
9
11
  super
10
12
 
@@ -16,7 +18,7 @@ module Publisher
16
18
  #
17
19
  # @return [String]
18
20
  def report_url
19
- @report_url ||= "https://#{pages_hostname}/-/#{project_name}/-/jobs/#{job_id}/artifacts/#{report_path}/index.html"
21
+ @report_url ||= "#{pages_hostname}/-/#{project_name}/-/jobs/#{job_id}/artifacts/#{report_path}/index.html"
20
22
  end
21
23
 
22
24
  # No-op method as gitlab does not expose api to upload artifacts
@@ -29,8 +31,7 @@ module Publisher
29
31
  private
30
32
 
31
33
  def_delegators :ci_info,
32
- :pages_hostname,
33
- :project_name,
34
+ :project_path,
34
35
  :project_id,
35
36
  :job_name,
36
37
  :job_id,
@@ -95,8 +96,29 @@ module Publisher
95
96
  @pipelines ||= client.pipelines(project_id, ref: branch, per_page: 10)
96
97
  end
97
98
 
98
- def latest_job
99
- @latest_job ||= pipelines.max_by(&:id)
99
+ # Top level group name
100
+ #
101
+ # @return [String]
102
+ def top_level_group
103
+ @top_level_group ||= project_path.split("/").first
104
+ end
105
+
106
+ # Project path without top level group name
107
+ #
108
+ # @return [String]
109
+ def project_name
110
+ @project_name ||= project_path.split("/")[1..].join("/")
111
+ end
112
+
113
+ # Pages hostname
114
+ #
115
+ # @return [String]
116
+ def pages_hostname
117
+ # built in variables of gitlab CI return incorrect pages hostname so it needs to be built manually
118
+ return "https://#{top_level_group}.#{DEFAULT_PAGES_DOMAIN}" unless base_url
119
+
120
+ host, scheme = URI.parse(base_url).then { |uri| [uri.host, uri.scheme || "https"] }
121
+ "#{scheme}://#{top_level_group}.#{host}"
100
122
  end
101
123
 
102
124
  # CI info
@@ -117,7 +139,7 @@ module Publisher
117
139
  # this will only work with history json files, see: https://github.com/NARKOZ/gitlab/issues/621
118
140
  response = client.download_job_artifact_file(project_id, job_id, artifact_path)
119
141
 
120
- File.write(local_path, response.to_json)
142
+ File.write(local_path, response.string)
121
143
  end
122
144
  end
123
145
  end
@@ -63,13 +63,14 @@ module Publisher
63
63
  def download_history
64
64
  log_debug("Downloading previous run history")
65
65
  HISTORY.each do |file_name|
66
+ source_file = key(prefix, "history", file_name)
66
67
  file_path = path(common_info_path, "history", file_name)
67
68
  client.get_object(
68
69
  response_target: file_path,
69
- key: key(prefix, "history", file_name),
70
+ key: source_file,
70
71
  bucket: bucket_name
71
72
  )
72
- log_debug("Downloaded '#{file_name}' as '#{file_path}'")
73
+ log_debug("Downloaded '#{source_file}' to '#{file_path}'")
73
74
  end
74
75
  rescue Aws::S3::Errors::NoSuchKey
75
76
  raise(HistoryNotFoundError, "Allure history from previous runs not found!")
@@ -80,7 +81,7 @@ module Publisher
80
81
  # @return [void]
81
82
  def upload_history
82
83
  log_debug("Uploading report history")
83
- upload_to_s3(report_files.select { |file| file.fnmatch?("*/history/*") }, prefix)
84
+ upload_to_s3(history_files, prefix)
84
85
  end
85
86
 
86
87
  # Upload allure report
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Publisher
4
- VERSION = "4.7.2"
4
+ VERSION = "4.7.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allure-report-publisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.2
4
+ version: 4.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrejs Cunskis