|
7 | 7 | require 'puppet-lint/configuration' |
8 | 8 | require 'puppet-lint/data' |
9 | 9 | require 'puppet-lint/checks' |
| 10 | +require 'puppet-lint/report/github' |
10 | 11 | require 'puppet-lint/bin' |
11 | 12 | require 'puppet-lint/monkeypatches' |
12 | 13 |
|
@@ -121,6 +122,16 @@ def format_message(message) |
121 | 122 | puts " #{message[:reason]}" if message[:kind] == :ignored && !message[:reason].nil? |
122 | 123 | end |
123 | 124 |
|
| 125 | + # Internal: Format a problem message and print it to STDOUT so GitHub Actions |
| 126 | + # recognizes it as an annotation. |
| 127 | + # |
| 128 | + # message - A Hash containing all the information about a problem. |
| 129 | + # |
| 130 | + # Returns nothing. |
| 131 | + def print_github_annotation(message) |
| 132 | + puts PuppetLint::Report::GitHubActionsReporter.format_problem(path, message) |
| 133 | + end |
| 134 | + |
124 | 135 | # Internal: Get the line of the manifest on which the problem was found |
125 | 136 | # |
126 | 137 | # message - A Hash containing all the information about a problem. |
@@ -158,15 +169,17 @@ def report(problems) |
158 | 169 |
|
159 | 170 | message[:KIND] = message[:kind].to_s.upcase |
160 | 171 |
|
161 | | - if message[:kind] == :fixed || [message[:kind], :all].include?(configuration.error_level) |
162 | | - if configuration.json |
163 | | - message['context'] = get_context(message) if configuration.with_context |
164 | | - json << message |
165 | | - else |
166 | | - format_message(message) |
167 | | - print_context(message) if configuration.with_context |
168 | | - end |
| 172 | + next unless message[:kind] == :fixed || [message[:kind], :all].include?(configuration.error_level) |
| 173 | + |
| 174 | + if configuration.json |
| 175 | + message['context'] = get_context(message) if configuration.with_context |
| 176 | + json << message |
| 177 | + else |
| 178 | + format_message(message) |
| 179 | + print_context(message) if configuration.with_context |
169 | 180 | end |
| 181 | + |
| 182 | + print_github_annotation(message) if configuration.github_actions |
170 | 183 | end |
171 | 184 | puts JSON.pretty_generate(json) if configuration.json |
172 | 185 |
|
|
0 commit comments