Introduce scripts/prune-old-flaky-specs to prune outdated flaky specs from the report
Signed-off-by: Rémy Coutable <remy@rymai.me>
This commit is contained in:
parent
5bef32195b
commit
9bb97abf04
2 changed files with 34 additions and 0 deletions
|
@ -368,6 +368,7 @@ update-tests-metadata:
|
|||
- scripts/merge-reports ${KNAPSACK_RSPEC_SUITE_REPORT_PATH} knapsack/${CI_PROJECT_NAME}/rspec-pg_node_*.json
|
||||
- scripts/merge-reports ${KNAPSACK_SPINACH_SUITE_REPORT_PATH} knapsack/${CI_PROJECT_NAME}/spinach-pg_node_*.json
|
||||
- scripts/merge-reports ${FLAKY_RSPEC_SUITE_REPORT_PATH} rspec_flaky/all_*_*.json
|
||||
- scripts/prune-old-flaky-specs ${FLAKY_RSPEC_SUITE_REPORT_PATH}
|
||||
- '[[ -z ${TESTS_METADATA_S3_BUCKET} ]] || scripts/sync-reports put $TESTS_METADATA_S3_BUCKET $KNAPSACK_RSPEC_SUITE_REPORT_PATH $KNAPSACK_SPINACH_SUITE_REPORT_PATH'
|
||||
- '[[ -z ${TESTS_METADATA_S3_BUCKET} ]] || scripts/sync-reports put $TESTS_METADATA_S3_BUCKET $FLAKY_RSPEC_SUITE_REPORT_PATH'
|
||||
- rm -f knapsack/${CI_PROJECT_NAME}/*_node_*.json
|
||||
|
|
33
scripts/prune-old-flaky-specs
Executable file
33
scripts/prune-old-flaky-specs
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/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'
|
||||
|
||||
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
|
||||
|
||||
DAYS_THRESHOLD = 90
|
||||
|
||||
def days_from_now(days)
|
||||
Time.now - (3600 * 24 * days)
|
||||
end
|
||||
|
||||
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 "New report has #{new_collection.size} entries: #{collection.size - new_collection.size} entries older than #{DAYS_THRESHOLD} days were removed."
|
||||
|
||||
File.write(new_report_file, JSON.pretty_generate(new_collection.to_report))
|
||||
puts "Saved #{new_report_file}."
|
Loading…
Reference in a new issue