diff --git a/.gitlab/ci/test-metadata.gitlab-ci.yml b/.gitlab/ci/test-metadata.gitlab-ci.yml index 21af0d373bc8fbd989e6aee03301451e2fd3cd52..4ec0dc70ae663b2fe4c68d060fabf17638e43b1b 100644 --- a/.gitlab/ci/test-metadata.gitlab-ci.yml +++ b/.gitlab/ci/test-metadata.gitlab-ci.yml @@ -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 diff --git a/lib/rspec_flaky/report.rb b/lib/rspec_flaky/report.rb index 9a0fb88c42432b7a0a2804c4896aa036c4fe48c0..d88233aea8e8dcef217c9987ddddedb8d70d0b0d 100644 --- a/lib/rspec_flaky/report.rb +++ b/lib/rspec_flaky/report.rb @@ -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 diff --git a/scripts/detect-new-flaky-examples b/scripts/flaky_examples/detect-new-flaky-examples similarity index 100% rename from scripts/detect-new-flaky-examples rename to scripts/flaky_examples/detect-new-flaky-examples diff --git a/scripts/prune-old-flaky-specs b/scripts/flaky_examples/prune-old-flaky-examples similarity index 90% rename from scripts/prune-old-flaky-specs rename to scripts/flaky_examples/prune-old-flaky-examples index a00a334fd6e03ba0cd456c1ffdfc3e16c73be4c5..7700b93438b1c0266ebcde539ae21f5926f2d5e1 100755 --- a/scripts/prune-old-flaky-specs +++ b/scripts/flaky_examples/prune-old-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) diff --git a/scripts/rspec_helpers.sh b/scripts/rspec_helpers.sh index 23e7698092661b72caa658aa719d66cb8948834e..8762108066dcd968b1a9410141ca61cfd8669707 100644 --- a/scripts/rspec_helpers.sh +++ b/scripts/rspec_helpers.sh @@ -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}" diff --git a/spec/lib/rspec_flaky/report_spec.rb b/spec/lib/rspec_flaky/report_spec.rb index 6a98a7a4e6b039b9806cd276ca4b781677b0b9cb..1f0eff83db06260f63b0bcfbfc90d7175205ec19 100644 --- a/spec/lib/rspec_flaky/report_spec.rb +++ b/spec/lib/rspec_flaky/report_spec.rb @@ -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 @@ 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 @@ 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