Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

github_pr_errors: use -i to display screenshots in terminal

Christophe Bliard2d6023adab2c
diff --git a/script/github_pr_errors b/script/github_pr_errors
index 418f48fc9ef..f2b4fbc92ac 100755
--- a/script/github_pr_errors
+++ b/script/github_pr_errors
@@ -28,6 +28,7 @@ class Options
DEFAULTS = {
compact: false,
display_rerun_info: false,
+ display_images: false,
failed_jobs_logs: [],
no_cache: false,
run_id: nil,
@@ -98,6 +99,10 @@ class Options
options[:failed_jobs_logs] << path
end
+ parser.on("-i", "--images", "Download and display screenshots of failed feature tests") do
+ options[:display_images] = true
+ end
+
parser.on("-n", "--no-cache", "Do not use cached replies from GitHub API calls") do
options[:no_cache] = true
end
@@ -492,7 +497,25 @@ class Formatter
puts escaped_location(error)
display_error_attribute("loading error", error.loading_error)
display_error_attribute("html", error.page_html)
- display_error_attribute("screenshot", error.page_screenshot)
+ display_error_screenshot(error.page_screenshot)
+ end
+
+ def display_error_screenshot(screenshot_url)
+ return unless screenshot_url
+
+ display_error_attribute("screenshot", screenshot_url)
+ if Options.display_images
+ begin
+ Open3.popen2e('imgcat', '--width', '50%', '--url', screenshot_url) do |stdin, stdout_and_stderr, _thread|
+ stdin.close
+ warn stdout_and_stderr.read
+ end
+ rescue Errno::ENOENT => e
+ warn e
+ warn "To display image inline, you need to have a compatible terminal like iTerm2 or Konsole, and the 'imgcat' command installed."
+ warn "See https://iterm2.com/documentation-images.html to know more."
+ end
+ end
end
def display_error_attribute(name, value)