summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-04-10 13:22:38 +0200
committerRémy Coutable <remy@rymai.me>2018-04-10 15:38:41 +0200
commitbcb7a99575629a2e3a8cd4fd701bad6d5714010d (patch)
tree43feef0c61fa43dab07af10260765588ed5c9b38 /scripts
parentb11e887582882bcf9c1787e18ccf34747ae50f91 (diff)
downloadgitlab-ce-bcb7a99575629a2e3a8cd4fd701bad6d5714010d.tar.gz
Use RspecFlaky::Report in scripts/prune-old-flaky-specs37721-clean-outdated-flaky-specs-from-the-flaky-specs-report
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/prune-old-flaky-specs26
1 files changed, 6 insertions, 20 deletions
diff --git a/scripts/prune-old-flaky-specs b/scripts/prune-old-flaky-specs
index 6c74b1f289c..ab03a0230cc 100755
--- a/scripts/prune-old-flaky-specs
+++ b/scripts/prune-old-flaky-specs
@@ -1,10 +1,6 @@
#!/usr/bin/env ruby
-require 'bundler/setup'
-Bundler.require(:default)
-
-require_relative '../lib/rspec_flaky/flaky_examples_collection'
-require_relative '../lib/rspec_flaky/examples_pruner'
+require_relative '../lib/rspec_flaky/report'
report_file = ARGV.shift
unless report_file
@@ -13,21 +9,11 @@ unless report_file
end
new_report_file = ARGV.shift || report_file
-
-DAYS_THRESHOLD = 90
-
-def days_from_now(days)
- Time.now - (3600 * 24 * days)
-end
-
+report = RspecFlaky::Report.load(report_file)
puts "Loading #{report_file}..."
-collection = RspecFlaky::FlakyExamplesCollection.new(JSON.parse(File.read(report_file)))
-
-puts "Current report has #{collection.size} entries."
-
-new_collection = RspecFlaky::ExamplesPruner.new(collection).prune_examples_older_than(days_from_now(DAYS_THRESHOLD))
+puts "Current report has #{report.size} entries."
-puts "New report has #{new_collection.size} entries: #{collection.size - new_collection.size} entries older than #{DAYS_THRESHOLD} days were removed."
+new_report = report.prune_outdated
-File.write(new_report_file, JSON.pretty_generate(new_collection.to_report))
-puts "Saved #{new_report_file}."
+puts "New report has #{new_report.size} entries: #{report.size - new_report.size} entries older than 90 days were removed."
+puts "Saved #{new_report_file}." if new_report.write(new_report_file)