Commit c9c6af4c authored by Rémy Coutable's avatar Rémy Coutable

Prune flaky examples after 30 days

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent ad1f7390
......@@ -64,4 +64,4 @@ flaky-examples-check:
script:
- '[[ -f $NEW_FLAKY_SPECS_REPORT ]] || echo "{}" > ${NEW_FLAKY_SPECS_REPORT}'
- scripts/merge-reports ${NEW_FLAKY_SPECS_REPORT} rspec_flaky/new_*_*.json
- scripts/detect-new-flaky-examples $NEW_FLAKY_SPECS_REPORT
- scripts/flaky_examples/detect-new-flaky-examples $NEW_FLAKY_SPECS_REPORT
......@@ -10,7 +10,7 @@ module RspecFlaky
# This class is responsible for loading/saving JSON reports, and pruning
# outdated examples.
class Report < SimpleDelegator
OUTDATED_DAYS_THRESHOLD = 90
OUTDATED_DAYS_THRESHOLD = 30
attr_reader :flaky_examples
......
......@@ -24,5 +24,5 @@ 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 "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)
......@@ -25,7 +25,7 @@ function update_tests_metadata() {
scripts/merge-reports "${FLAKY_RSPEC_SUITE_REPORT_PATH}" rspec_flaky/all_*.json
export FLAKY_RSPEC_GENERATE_REPORT="1"
scripts/prune-old-flaky-specs "${FLAKY_RSPEC_SUITE_REPORT_PATH}"
scripts/flaky_examples/prune-old-flaky-examples "${FLAKY_RSPEC_SUITE_REPORT_PATH}"
if [[ -n ${TESTS_METADATA_S3_BUCKET} ]]; then
scripts/sync-reports put "${TESTS_METADATA_S3_BUCKET}" "${FLAKY_RSPEC_SUITE_REPORT_PATH}"
......
......@@ -3,11 +3,11 @@
require 'spec_helper'
describe RspecFlaky::Report, :aggregate_failures do
let(:a_hundred_days) { 3600 * 24 * 100 }
let(:thirty_one_days) { 3600 * 24 * 31 }
let(:collection_hash) do
{
a: { example_id: 'spec/foo/bar_spec.rb:2' },
b: { example_id: 'spec/foo/baz_spec.rb:3', first_flaky_at: (Time.now - a_hundred_days).to_s, last_flaky_at: (Time.now - a_hundred_days).to_s }
b: { example_id: 'spec/foo/baz_spec.rb:3', first_flaky_at: (Time.now - thirty_one_days).to_s, last_flaky_at: (Time.now - thirty_one_days).to_s }
}
end
let(:suite_flaky_example_report) do
......@@ -109,7 +109,7 @@ describe RspecFlaky::Report, :aggregate_failures do
end
describe '#prune_outdated' do
it 'returns a new collection without the examples older than 90 days by default' do
it 'returns a new collection without the examples older than 30 days by default' do
new_report = flaky_examples.to_h.dup.tap { |r| r.delete(:b) }
new_flaky_examples = report.prune_outdated
......@@ -119,7 +119,7 @@ describe RspecFlaky::Report, :aggregate_failures do
end
it 'accepts a given number of days' do
new_flaky_examples = report.prune_outdated(days: 200)
new_flaky_examples = report.prune_outdated(days: 32)
expect(new_flaky_examples.to_h).to eq(report.to_h)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment