Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
safafa committed Jan 18, 2024
1 parent 819e3a5 commit c6cec95
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ jobs:
test:
name: Test failing spec detector
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ci_node_total: [3]
ci_node_index: [0, 1, 2]

steps:
- uses: actions/checkout@v3
Expand All @@ -22,17 +27,21 @@ jobs:
- name: Lint files
run: bundle exec rake rubocop
- name: Run tests
env:
RAILS_ENV: test
CI_NODE_TOTAL: ${{ matrix.ci_node_total }}
CI_NODE_INDEX: ${{ matrix.ci_node_index }}
run: bundle exec rake spec
- name: Upload Failures
uses: actions/upload-artifact@v3
with:
name: Failures
path: failures_log_*.yml
path: spec/failing_spec_detector/failures
- name: Upload Exceptions
uses: actions/upload-artifact@v3
with:
name: Exceptions
path: exceptions_log_*.yml
path: spec/failing_spec_detector/exceptions

print_log:
name: Test print logs task
Expand All @@ -50,10 +59,12 @@ jobs:
uses: actions/download-artifact@v3
with:
name: Failures
path: spec/failing_spec_detector/failures
- name: Download Exceptions
uses: actions/download-artifact@v3
with:
name: Exceptions
path: spec/failing_spec_detector/exceptions
- name: Run print_log task
run: bundle exec rake failing_specs_detector:print_log

4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
.rspec_status

# log files
exceptions_log_*.yml
failures_log_*.yml
exceptions/
failures/
5 changes: 3 additions & 2 deletions lib/failing_spec_detector/failing_spec_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ def initialize(output)
super(output)
@failures = []
@exceptions = []
@failures_filename = "failures_log_#{ENV.fetch('TEST_ENV_NUMBER', nil)}.yml"
@exceptions_filename = "exceptions_log_#{ENV.fetch('TEST_ENV_NUMBER', nil)}.yml"
@failures_filename = "spec/failing_spec_detector/failures/failures_log_#{ENV.fetch('TEST_ENV_NUMBER', nil)}.yml"
@exceptions_filename = "spec/failing_spec_detector/exceptions/exceptions_log_#{ENV.fetch('TEST_ENV_NUMBER',
nil)}.yml"
end

def example_failed(failure)
Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/failing_spec_detector/print_log.rake
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace :failing_specs_detector do
task :print_log do
failures = []
exceptions = []
failures_file_paths = Dir['failures_log_*.yml']
exceptions_file_paths = Dir['exceptions_log_*.yml']
failures_file_paths = Dir['spec/failing_spec_detector/failures/failures_log_*.yml']
exceptions_file_paths = Dir['spec/failing_spec_detector/exceptions/exceptions_log_*.yml']
failures_file_paths.each do |file_path|
failures.concat(YAML.load_file(file_path, permitted_classes: [FailingSpecDetector::Failure]))
File.delete(file_path)
Expand Down
4 changes: 2 additions & 2 deletions spec/failing_spec_detector/failing_spec_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
let(:output) { Tempfile.new('./output_to_close') }
let(:expected_failures_file_path) { './spec/support/expected_failures_log_.yml' }
let(:expected_exceptions_file_path) { './spec/support/expected_exceptions_log_.yml' }
let(:actual_failures_file_path) { './failures_log_.yml' }
let(:actual_exceptions_file_path) { './exceptions_log_.yml' }
let(:actual_failures_file_path) { './spec/failing_spec_detector/failures/failures_log_.yml' }
let(:actual_exceptions_file_path) { './spec/failing_spec_detector/exceptions/exceptions_log_.yml' }
let(:expected_failures_file) { File.new(expected_failures_file_path, 'r') }
let(:expected_exceptions_file) { File.new(expected_exceptions_file_path, 'r') }
let(:actual_failures_file) { File.new(actual_failures_file_path, 'r') }
Expand Down

0 comments on commit c6cec95

Please sign in to comment.