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

Add --compact option to output all on one line

Christophe Bliard4f8efc6734ce
diff --git a/script/github_pr_errors b/script/github_pr_errors
index 2f28c8ede42..ae937282cc9 100755
--- a/script/github_pr_errors
+++ b/script/github_pr_errors
@@ -5,10 +5,11 @@ require 'bundler'
Bundler.setup(:default, :development)
require 'colored2'
-require 'pathname'
require 'json'
-require 'rest-client'
+require 'optparse'
+require 'pathname'
require 'pry'
+require 'rest-client'
require 'yaml'
GITHUB_API_OPENPROJECT_PREFIX = "https://api.github.com/repos/opf/openproject"
@@ -21,6 +22,38 @@ elsif !ENV['GITHUB_TOKEN']
raise "Missing GITHUB_TOKEN env, go to https://github.com/settings/tokens and create one with 'repo' access"
end
+def parse_options
+ options = {}
+ opt_parser = OptionParser.new do |parser|
+ parser.banner = <<~BANNER
+ Usage: #{$0} [options]
+
+ Fetches rspec failures from last completed GitHub actions on current
+ branch, and outputs them on standard output, one by line.
+
+ Information is printed on standard error to preserve standard output.
+
+ Use this script with xargs to run failing specs locally:
+
+ #{$0} | xargs --no-run-if-empty bundle exec rspec
+
+
+ Options:
+ BANNER
+
+ parser.on("-c", "--compact", "Output all failing rspec files on one line") do
+ options[:compact] = true
+ end
+
+ parser.on("-h", "--help", "Prints this help") do
+ puts parser
+ exit
+ end
+ end
+ opt_parser.parse!
+ options
+end
+
# Returns current branch
def branch_name
@branch_name ||= `git rev-parse --abbrev-ref HEAD`.strip
@@ -156,6 +189,8 @@ end
##########
+options = parse_options
+
warn "Looking for the last 'Test suite' workflow run in branch #{branch_name}"
last_test_action = get_last_test_action
@@ -191,5 +226,7 @@ if is_successful
elsif errors.empty?
warn "No rspec errors found :-/"
else
- puts errors.map { "'#{_1}'" }
+ errors = errors.map { "'#{_1}'" }
+ errors = errors.join(" ") if options[:compact]
+ puts errors
end