allure-report-publisher 0.5.1 → 0.5.2

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: ef51790888932877d33ebf9edc9307bc14211088fbe41ba34398e9668980f1a0
4
- data.tar.gz: 4a3fcce060bcea96aadcc9ab8e37f523148c606bb4f0ca8081798e8a6a239ac3
3
+ metadata.gz: 41262f49694d870733005c690d1384d2f95493efe3dd1f4af0f57bdf27871c51
4
+ data.tar.gz: c4c115289ce0ad2f21adc359b96e6c61d06534227086f9e18808568dfd8dae69
5
5
  SHA512:
6
- metadata.gz: 40ccf342af3d5b90cb8b9eb9473bc63379e225c4a8e45466a9e66bc4c16476afd1573edade5101abf63d8f4a7936fd42ef87d61dfcfda950ab3da276c7425766
7
- data.tar.gz: 59f451092604006ba5b742aa679c240f37eda76b9bc034b329c1965bd52163bd2ef371e543faca7b4349ffd586fc38497c1563db532405395b1cf98c9f4822ee
6
+ metadata.gz: 8da58fa175adce43b0e8a5a06d7ade6157b99ab8c31f566da1e9cfbc082ee89251da8ba54a3c9bcd37bef72e8554456fd17cb3eecedf839e7864270b6558f3ae
7
+ data.tar.gz: cdfeefbee4ebdf742614e664e0ab691977b0f5ce4445928ef219bc071a9d98c2410b2ac7b0f69a6a3dd634cf3f3f3731fbf8af7f2a5221279423900176bd84e5
@@ -29,26 +29,30 @@ module Publisher
29
29
  urls_block.match?(DESCRIPTION_PATTERN)
30
30
  end
31
31
 
32
- # Get urls for PR update
32
+ # PR description with allure report urls
33
33
  #
34
- # @param [String] pr
34
+ # @param [String] pr_description
35
35
  # @return [String]
36
36
  def updated_pr_description(pr_description)
37
- return strip_separator(body) unless pr_description
38
- return "#{pr_description}\n\n#{body}" unless pr_description.match?(DESCRIPTION_PATTERN)
37
+ stripped_description = (pr_description || "").strip
38
+
39
+ return url_section(separator: false) if stripped_description == ""
40
+ return "#{pr_description}\n\n#{url_section}" unless pr_description.match?(DESCRIPTION_PATTERN)
39
41
 
40
42
  job_entries = jobs_section(pr_description)
41
- pr_description.gsub(DESCRIPTION_PATTERN, body(job_entries))
43
+ non_empty = stripped_description != pr_description.match(DESCRIPTION_PATTERN)[0]
44
+ pr_description.gsub(DESCRIPTION_PATTERN, url_section(job_entries: job_entries, separator: non_empty))
42
45
  end
43
46
 
44
- # Allure report url comment without description separator
47
+ # Comment body with allure report urls
45
48
  #
49
+ # @param [String] pr_comment
46
50
  # @return [String]
47
51
  def comment_body(pr_comment = nil)
48
- return strip_separator(body) unless pr_comment
52
+ return url_section(separator: false) unless pr_comment
49
53
 
50
54
  job_entries = jobs_section(pr_comment)
51
- strip_separator(body(job_entries))
55
+ url_section(job_entries: job_entries, separator: false)
52
56
  end
53
57
 
54
58
  attr_reader :report_url,
@@ -59,22 +63,6 @@ module Publisher
59
63
 
60
64
  private
61
65
 
62
- # Allure report url pr description
63
- #
64
- # @return [String]
65
- def body(job_entries = job_entry)
66
- @body ||= <<~BODY.strip
67
- <!-- allure -->
68
- ---
69
- #{heading}
70
-
71
- <!-- jobs -->
72
- #{job_entries}
73
- <!-- jobs -->
74
- <!-- allurestop -->
75
- BODY
76
- end
77
-
78
66
  # Url section heading
79
67
  #
80
68
  # @return [String]
@@ -110,6 +98,24 @@ module Publisher
110
98
  @job_entry_pattern ||= /<!-- #{build_name} -->\n([\s\S]+)\n<!-- #{build_name} -->/
111
99
  end
112
100
 
101
+ # Allure report url section
102
+ #
103
+ # @return [String]
104
+ def url_section(job_entries: job_entry, separator: true)
105
+ reports = <<~BODY.strip
106
+ <!-- allure -->
107
+ ---
108
+ #{heading}
109
+
110
+ <!-- jobs -->
111
+ #{job_entries}
112
+ <!-- jobs -->
113
+ <!-- allurestop -->
114
+ BODY
115
+
116
+ separator ? reports : reports.gsub("---\n", "")
117
+ end
118
+
113
119
  # Return updated jobs section
114
120
  #
115
121
  # @param [String] urls
@@ -120,14 +126,6 @@ module Publisher
120
126
 
121
127
  "#{jobs}\n#{job_entry}"
122
128
  end
123
-
124
- # Strip separator from allure results section
125
- #
126
- # @param [String] body
127
- # @return [String]
128
- def strip_separator(body)
129
- body.gsub("---\n", "")
130
- end
131
129
  end
132
130
  end
133
131
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Publisher
4
- VERSION = "0.5.1"
4
+ VERSION = "0.5.2"
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: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrejs Cunskis