summaryrefslogtreecommitdiff
path: root/scripts/prune-old-flaky-specs
blob: 59f97e833b5c37db58a44e98f2541c717d7da03c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/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'

singleton_class.__send__(:alias_method, :require_dependency, :require)
$LOAD_PATH.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 90 days were removed."
puts "Saved #{new_report_file}." if new_report.write(new_report_file)