summaryrefslogtreecommitdiff
path: root/scripts/flaky_examples
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-21 21:08:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-21 21:08:54 +0000
commit36e363d33d5f75aeb75c552d4b325ed8c2d6105f (patch)
tree1ca97e2e47c613eed6b6cd4682c36c92067cab46 /scripts/flaky_examples
parentd91f5211693e913da5df110b8de841fad87e3653 (diff)
downloadgitlab-ce-36e363d33d5f75aeb75c552d4b325ed8c2d6105f.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts/flaky_examples')
-rwxr-xr-xscripts/flaky_examples/detect-new-flaky-examples21
-rwxr-xr-xscripts/flaky_examples/prune-old-flaky-examples28
2 files changed, 49 insertions, 0 deletions
diff --git a/scripts/flaky_examples/detect-new-flaky-examples b/scripts/flaky_examples/detect-new-flaky-examples
new file mode 100755
index 00000000000..3bee4f9a34b
--- /dev/null
+++ b/scripts/flaky_examples/detect-new-flaky-examples
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+
+require 'json'
+
+report_file = ARGV.shift
+unless report_file
+ puts 'usage: detect-new-flaky-examples <report-file>'
+ exit 1
+end
+
+puts "Loading #{report_file}..."
+report = JSON.parse(File.read(report_file))
+
+if report.any?
+ puts "New flaky examples were detected!\n"
+ puts JSON.pretty_generate(report)
+ exit 1
+else
+ puts "No new flaky examples detected.\n"
+ exit 0
+end
diff --git a/scripts/flaky_examples/prune-old-flaky-examples b/scripts/flaky_examples/prune-old-flaky-examples
new file mode 100755
index 00000000000..7700b93438b
--- /dev/null
+++ b/scripts/flaky_examples/prune-old-flaky-examples
@@ -0,0 +1,28 @@
+#!/usr/bin/env ruby
+
+# lib/rspec_flaky/flaky_examples_collection.rb is requiring
+# `active_support/hash_with_indifferent_access`, and we install the `activesupport`
+# gem manually on the CI
+require 'rubygems'
+
+# In newer Ruby, alias_method is not private then we don't need __send__
+singleton_class.__send__(:alias_method, :require_dependency, :require) # rubocop:disable GitlabSecurity/PublicSend
+$:.unshift(File.expand_path('../lib', __dir__))
+
+require 'rspec_flaky/report'
+
+report_file = ARGV.shift
+unless report_file
+ puts 'usage: prune-old-flaky-specs <report-file> <new-report-file>'
+ exit 1
+end
+
+new_report_file = ARGV.shift || report_file
+report = RspecFlaky::Report.load(report_file)
+puts "Loading #{report_file}..."
+puts "Current report has #{report.size} entries."
+
+new_report = report.prune_outdated
+
+puts "New report has #{new_report.size} entries: #{report.size - new_report.size} entries older than #{RspecFlaky::Report::OUTDATED_DAYS_THRESHOLD} days were removed."
+puts "Saved #{new_report_file}." if new_report.write(new_report_file)