allure-report-publisher 4.7.1 → 4.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0bb8e40a07b6be84137b396ca54ecbf9a2ed982686e7c547440d05f92fafb4f9
4
- data.tar.gz: 94ad353721fb09c4466d6d6ff185ac6179e4ce27407859edfa3f56fa49687f2d
3
+ metadata.gz: eb5c2b6dc7b110284945c9d083603b68b39a573b047f82acebd6045a8b88bd79
4
+ data.tar.gz: 81fe6d11a19b8040503ccf8a61e620d09fc164a9244423dfff07df89d6f88425
5
5
  SHA512:
6
- metadata.gz: d8557b6da70706bd0a08981ab50f8e2c3b4b6eea863d2d9fe9001d2d48c4ffbb961c451017fabe5bfaac5100ee1aff9ca9addc9e7704b867daff797968380a02
7
- data.tar.gz: 86c8500a73d8d4511088751c79976d2ff3cb19020f4ad64c8feadff9e4026c34c38ecf33c9acc666736081300e8515ce0958745754d966f71ab40073525fd28d
6
+ metadata.gz: 478172dea4924daea11efe38ce89c4f4db4a927bb19fa7d686e0038d2392930ec359c28dcd787ba992082c0b5992f491a4f5f351a1b49b5f25b7da7f9a59353d
7
+ data.tar.gz: 29484941212d4952364221f72a88cc6f5b3c00600388ee0c3b35579f79ae64876fa4215f5862d6f5736727dfe4b9f1ce117d87dbd879932a41767f072de68f19
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",
@@ -118,7 +118,7 @@ module Publisher
118
118
  # @return [String] output path
119
119
  def output
120
120
  @output ||= args[:output].then do |path|
121
- next if path
121
+ next path if path && !path.empty?
122
122
 
123
123
  gitlab_artifacts? ? "allure-report" : File.join(Dir.tmpdir, "allure-report-#{Time.now.to_i}")
124
124
  end
@@ -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
@@ -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,
@@ -60,7 +61,7 @@ module Publisher
60
61
  )
61
62
  end
62
63
  rescue StandardError => e
63
- log("Failed to download allure history: #{e.message}", :yellow)
64
+ raise(HistoryNotFoundError, e.message)
64
65
  end
65
66
 
66
67
  # Last job from previous pipeline
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Publisher
4
- VERSION = "4.7.1"
4
+ VERSION = "4.7.3"
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.1
4
+ version: 4.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrejs Cunskis